From 4df4a409593b5418a5113e7e785760f53c754f94 Mon Sep 17 00:00:00 2001 From: Sergio Tessaris <tessaris@inf.unibz.it> Date: Wed, 9 Mar 2022 16:18:58 +0100 Subject: [PATCH] build: declarative package definition --- setup.cfg | 21 ++++++++++++++++++ setup.py | 64 ++++--------------------------------------------------- 2 files changed, 25 insertions(+), 60 deletions(-) create mode 100644 setup.cfg diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..6a0ee98 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,21 @@ +[metadata] +name = wumpus +version = attr:wumpus.__version__ +description = My package description +long_description = file: README.md +license = MIT +author = Sergio Tessaris +author_email = tessaris@inf.unibz.it + +[options] +zip_safe = False +include_package_data = True +packages = find: +python_requires = >=3.7 + +[options.entry_points] +console_scripts = + gridrunner = wumpus.cli:main + +[options.extras_require] +gym = gym diff --git a/setup.py b/setup.py index 1d62e8c..868f97c 100644 --- a/setup.py +++ b/setup.py @@ -1,61 +1,5 @@ -from setuptools import setup, find_packages -import re -import codecs -import os -import subprocess +#!/usr/bin/env python +import setuptools -# Hack to allow non-normalised versions -# see <https://github.com/pypa/setuptools/issues/308> -from setuptools.extern.packaging import version -version.Version = version.LegacyVersion - -_INCLUDE_GIT_REV_ = False - - -# see <https://stackoverflow.com/a/39671214> and -# <https://packaging.python.org/guides/single-sourcing-package-version> -def find_version(*pkg_path): - pkg_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)), *pkg_path) - version_file = codecs.open(os.path.join(pkg_dir, '__init__.py'), 'r').read() - version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", - version_file, re.M) - _git_revision_ = None - if _INCLUDE_GIT_REV_: - try: - _git_revision_ = subprocess.check_output(['git', 'describe', '--always', '--dirty'], encoding='utf-8').strip() - except subprocess.CalledProcessError: - pass - if version_match: - return version_match.group(1) + ('' if _git_revision_ is None else '+' + _git_revision_) - elif _git_revision_: - return _git_revision_ - raise RuntimeError("Unable to find version string.") - - -def long_description_md(fname='README.md'): - this_directory = os.path.abspath(os.path.dirname(__file__)) - with open(os.path.join(this_directory, fname), encoding='utf-8') as f: - long_description = f.read() - return long_description - - -setup( - name='wumpus', - version=find_version('wumpus'), - description='Wumpus world simulator', - long_description=long_description_md(), - long_description_content_type='text/markdown', - author='Sergio Tessaris', - author_email='tessaris@inf.unibz.it', - packages=find_packages(), - include_package_data=True, - entry_points= { - 'console_scripts': ['gridrunner=wumpus.cli:main'] - }, - install_requires=[ - ], - extras_require={ - 'gym': ['gym'] - }, - exclude_package_data={'': ['.gitignore']}, -) +if __name__ == "__main__": + setuptools.setup() \ No newline at end of file -- GitLab