From b81be0ec0226dd197493d5cc549525763813b603 Mon Sep 17 00:00:00 2001 From: Bradley Lowekamp Date: Wed, 14 Jun 2023 13:52:34 -0400 Subject: [PATCH] Use pyproject.toml inplace of setup.py Correct zarr to be an optional dependency. Update version to use generation _version.py file. Update GH Actions in main. Update minimum version of Python to 3.8 --- .github/workflows/main.yml | 31 +++++----------------- .gitignore | 1 + docs/requirements.txt | 3 ++- pyproject.toml | 35 ++++++++++++++++++++++++- requirements-dev.txt | 3 --- requirements.txt | 1 - setup.py | 53 -------------------------------------- sitkibex/__init__.py | 15 ++--------- 8 files changed, 45 insertions(+), 97 deletions(-) delete mode 100644 requirements-dev.txt delete mode 100644 setup.py diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f15858a..ce174f2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -40,7 +40,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.7, 3.8, 3.9, '3.10', '3.11'] + python-version: [3.8, 3.9, '3.10', '3.11'] steps: - uses: actions/checkout@v3 @@ -53,7 +53,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -r requirements.txt -r requirements-dev.txt + pip install -e .[zarr,dev] - name: Test with pytest run: | python -m pytest @@ -65,14 +65,14 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 - - name: Set up Python 3.7 + - name: Set up Python 3.11 uses: actions/setup-python@v4 with: - python-version: 3.7 + python-version: 3.11 - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install -r requirements.txt -r docs/requirements.txt twine build + python -m pip install -e .[zarr] twine build - name: Build package run: | python -m build --wheel --sdist @@ -86,8 +86,7 @@ jobs: path: dist - name: Build Sphinx Documentation run: | - # install so that setuptools_scm generate version for package - pip install -e . + pip install -r docs/requirements.txt make -C docs html - name: Upload documentation if: github.event_name == 'push' @@ -109,21 +108,3 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.github_token }} TARGET_BRANCH: 'gh-pages' - - github_release: - if: startsWith(github.ref, 'refs/tags/v') - needs: package_docs - runs-on: ubuntu-latest - steps: - - uses: actions/download-artifact@v3 - id: download - with: - name: python-packages - - name: Create Release and Upload - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') - id: create_release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gh release create ${{ github.ref_name }} --repo ${{ github.repository }} --verify-tag --generate-notes --title "Release ${{ github.ref_name }}" - gh release upload ${{ github.ref_name }} --repo ${{ github.repository }} ${{steps.download.outputs.download-path}}/* diff --git a/.gitignore b/.gitignore index efe20bf..de0ab43 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ build dist sitkibex.dist-info sitkibex.egg-info +_version.py \ No newline at end of file diff --git a/docs/requirements.txt b/docs/requirements.txt index 8f0c0f4..ce28aa3 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,2 +1,3 @@ sphinx -sphinx-click \ No newline at end of file +sphinx-click +-r ../requirements.txt diff --git a/pyproject.toml b/pyproject.toml index c141328..7342e9e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,38 @@ [build-system] -requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4"] +requires = ["setuptools>=61.0", "wheel", "setuptools_scm[toml]>=6.2"] +build-backend = "setuptools.build_meta" + +[project] +name = "sitkibex" +authors = [ + { name="Bradley Lowekamp", email="bioinformatics@niaid.nih.gov" }, +] +description = "Image registration for iterative fluorescence microscopy" +readme = "README.rst" +requires-python = ">=3.8" +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: Apache Software License", + "Operating System :: OS Independent", +] +dynamic = ["dependencies", "version"] + + +[project.optional-dependencies] +zarr= ["zarr"] +dev = [ + "pytest", + "flake8", +] + +[tool.setuptools.dynamic] +dependencies = {file = ["requirements.txt"]} + + +[tool.setuptools_scm] +write_to = "sitkibex/_version.py" +local_scheme = "dirty-tag" + [tool.pytest.ini_options] junit_family = "xunit2" diff --git a/requirements-dev.txt b/requirements-dev.txt deleted file mode 100644 index 93e7587..0000000 --- a/requirements-dev.txt +++ /dev/null @@ -1,3 +0,0 @@ -flake8 -pytest >= 6.0 -setuptools_scm \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 83c538e..f932a57 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ SimpleITK >= 2.0.0 click numpy -zarr \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index a54b3f7..0000000 --- a/setup.py +++ /dev/null @@ -1,53 +0,0 @@ -# -# Copyright Bradley Lowekamp -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0.txt -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -from setuptools import setup, find_packages - -with open("README.rst", "r") as fp: - long_description = fp.read() - -with open("requirements.txt", "r") as fp: - requirements = list(filter(bool, (line.strip() for line in fp))) - -with open("requirements-dev.txt", "r") as fp: - dev_requirements = list(filter(bool, (line.strip() for line in fp))) - - -setup( - name="sitkibex", - use_scm_version={"local_scheme": "dirty-tag"}, - author=["Bradley Lowekamp"], - author_email="bioinformatics@niaid.nih.gov", - description="Image registration for iterative fluorescence microscopy", - long_description=long_description, - long_description_content_type="text/x-rst", - url="https://github.com/niaid/sitk-ibex", - packages=find_packages(exclude=("test",)), - license="Apache 2.0", - entry_points={"console_scripts": ["sitkibex = sitkibex.cli:cli"]}, - classifiers=[ - "Development Status :: 2 - Pre-Alpha", - "Programming Language :: Python :: 3", - "License :: OSI Approved :: Apache Software License", - "Operating System :: OS Independent", - ], - python_requires=">=3.5", - install_requires=requirements, - tests_require=dev_requirements, - extras_require={ - "zarr": ["zarr"], - }, - setup_requires=["setuptools_scm"], -) diff --git a/sitkibex/__init__.py b/sitkibex/__init__.py index 28cfc97..58c3886 100644 --- a/sitkibex/__init__.py +++ b/sitkibex/__init__.py @@ -17,20 +17,9 @@ from .resample import resample try: - from importlib.metadata import version, PackageNotFoundError - - __version__ = version(__name__) + from ._version import version as __version__ except ImportError: - from pkg_resources import get_distribution, DistributionNotFound - - try: - __version__ = get_distribution(__name__).version - except DistributionNotFound: - # package is not installed - pass -except PackageNotFoundError: - # package is not installed - pass + __version__ = "unknown version" __author__ = ["Bradley Lowekamp"]