diff --git a/.gitignore b/.gitignore index 16d2f2a..c2bc12c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ /* -taxtastic/data/ver +taxtastic/taxtastic.egg-info/ __pycache__ -!setup.py +!pyproject.toml !MANINFEST.in !README.rst !taxtastic/ diff --git a/CHANGES.rst b/CHANGES.rst index 644f9de..582d85e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -2,6 +2,11 @@ change log for taxtastic ========================== +0.11.2-dev +========== + +* Migrated setup.py to pyproject.toml [GH-172] + 0.11.1 ====== diff --git a/Dockerfile b/Dockerfile index b4f2bdd..e1400cc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,17 +2,18 @@ FROM python:3.11-slim-bullseye ARG VERSION -ENV PIP_ROOT_USER_ACTION=ignore TAXTASTIC_VERSION=${VERSION#v} +ENV PIP_ROOT_USER_ACTION=ignore -RUN apt-get -y update && apt-get upgrade -y && apt-get install -y unzip wget +RUN apt-get -y update && apt-get upgrade -y && apt-get install -y git unzip wget WORKDIR /opt/build COPY dev/install_pplacer.sh ./ RUN /opt/build/install_pplacer.sh /usr/local -COPY setup.py MANIFEST.in README.rst ./ +COPY pyproject.toml MANIFEST.in README.rst ./ COPY taxtastic/ ./taxtastic/ +COPY .git/ ./.git/ RUN pip3 install --upgrade pip && pip3 install . WORKDIR /opt/run diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..bdef864 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,50 @@ +[build-system] +requires = ["setuptools>=64", "setuptools-scm>=8"] +build-backend = "setuptools.build_meta" + +[project] +authors = [ + {email = "ngh2@uw.edu", name = "Noah Hoffman"} +] +classifiers = [ +"Development Status :: 3 - Alpha", +"Programming Language :: Python :: 3.8", +"Programming Language :: Python :: 3.9", +"Programming Language :: Python :: 3.10", +"Programming Language :: Python :: 3.11", +"Programming Language :: Python :: 3.12", +"Topic :: Scientific/Engineering :: Bio-Informatics" +] +dependencies = [ +"decorator", +"DendroPy", +"fastalite", +"jinja2", +"psycopg-binary", +"psycopg2-binary", +"PyYAML", +"sqlalchemy>=2", +"sqlparse" +] +description = "Tools for taxonomic naming and annotation" +dynamic = ["version"] # https://setuptools-scm.readthedocs.io/en/latest/ +license = {text = "GPL-3.0-only"} +maintainers = [ + {email = "crosenth@gmail.com", name = "Chris Rosenthal"}, + {email = "dhoogest@uw.edu", name="Dan Hoogestraat"} +] +name = "taxtastic" +readme = "README.rst" +requires-python = ">=3.8" + +[project.urls] +repository = "https://github.com/fhcrc/taxtastic" + +[project.scripts] +taxit = "taxtastic.scripts.taxit:main" + +[tool.setuptools.packages.find] +exclude = ["testfiles", "tests"] + +[tool.setuptools_scm] +# can be empty if no extra settings are needed, presence enables setuptools-scm diff --git a/setup.py b/setup.py deleted file mode 100644 index 144ec45..0000000 --- a/setup.py +++ /dev/null @@ -1,67 +0,0 @@ -""" -Create unix package: python setup.py sdist -Upload to pypi: python setup.py sdist upload -""" - -import subprocess -import os -from setuptools import setup, find_packages -# To use a consistent encoding -from os import path - -subprocess.call( - ('mkdir -p taxtastic/data && ' - 'git describe --tags --dirty > taxtastic/data/ver.tmp' - '&& mv taxtastic/data/ver.tmp taxtastic/data/ver ' - '|| rm -f taxtastic/data/ver.tmp'), - shell=True, stderr=open(os.devnull, 'w', encoding='utf-8')) - -# must import __version__ *after* running 'git describe' above -from taxtastic import __version__ - -# Get the long description from the README file -here = path.abspath(path.dirname(__file__)) -with open(path.join(here, 'README.rst'), encoding='utf-8') as fi: - long_description = fi.read() - - -params = {'name': 'taxtastic', - 'author': 'Noah Hoffman', - 'author_email': 'ngh2@uw.edu', - 'maintainer': 'Chris Rosenthal', - 'maintainer_email': 'crosenth@uw.edu', - 'description': 'Tools for taxonomic naming and annotation', - 'long_description': long_description, - 'packages': find_packages(exclude=['testfiles', 'tests']), - 'package_dir': {'taxtastic': 'taxtastic'}, - 'python_requires': '>=3.8', - 'url': 'https://github.com/fhcrc/taxtastic', - 'version': __version__, - 'license': 'GPL', - 'classifiers': [ - 'License :: OSI Approved :: GNU General Public License (GPL)', - 'Development Status :: 3 - Alpha', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - 'Programming Language :: Python :: 3.12', - 'Topic :: Scientific/Engineering :: Bio-Informatics'], - 'download_url': 'https://github.com/fhcrc/taxtastic', - 'include_package_data': True, - 'entry_points': { - 'console_scripts': ['taxit = taxtastic.scripts.taxit:main']}, - 'test_suite': 'tests', - 'install_requires': [ - 'decorator', - 'DendroPy', - 'fastalite', - 'jinja2', - 'psycopg-binary', - 'psycopg2-binary', - 'PyYAML', - 'sqlalchemy>=2', - 'sqlparse', - ]} - -setup(**params) diff --git a/taxtastic/__init__.py b/taxtastic/__init__.py index e99e930..65ea81d 100644 --- a/taxtastic/__init__.py +++ b/taxtastic/__init__.py @@ -1,11 +1,8 @@ -import os +from importlib.metadata import version, PackageNotFoundError -ver = os.path.join(os.path.dirname(__file__), 'data', 'ver') -if 'TAXTASTIC_VERSION' in os.environ: - __version__ = os.environ['TAXTASTIC_VERSION'] -elif os.path.isfile(ver): - with open(ver) as f: - __version__ = f.read().strip().replace('-', '+', 1).replace('-', '.') - __version__ = __version__.lstrip('v') -else: - __version__ = '' +# https://setuptools-scm.readthedocs.io/en/latest/usage/#at-runtime +try: + __version__ = version("taxtastic") +except PackageNotFoundError: + # package is not installed + pass