diff --git a/.github/workflows/build_python_package.yml b/.github/workflows/build_python_package.yml new file mode 100644 index 0000000..0e4e58a --- /dev/null +++ b/.github/workflows/build_python_package.yml @@ -0,0 +1,41 @@ +name: Build and Test Package + +on: + push: + branches: + - master + pull_request: + +jobs: + build-and-test: + runs-on: ubuntu-latest + + steps: + # Checkout the repository + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 # Fetch all history to ensure tags are available + + # Set up Python + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.12 # Change to the desired Python version + + # Install dependencies + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + + # Build the package + - name: Build the package + run: | + python -m build + + # Test importing the package + - name: Test the package import + run: | + python -m pip install dist/*.whl + python -c "import pymirc; print('pymirc version:', pymirc.__version__)" diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index 7d0110a..3e00f81 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -21,6 +21,8 @@ jobs: steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Fetch all history to ensure tags are available - name: Set up Python 3.12 uses: actions/setup-python@v4 with: diff --git a/pymirc/__init__.py b/pymirc/__init__.py index 1edd318..f9f1321 100644 --- a/pymirc/__init__.py +++ b/pymirc/__init__.py @@ -3,10 +3,9 @@ from . import metrics from . import viewer -from pkg_resources import get_distribution, DistributionNotFound +from importlib.metadata import version, PackageNotFoundError try: - __version__ = get_distribution(__name__).version -except DistributionNotFound: - # package is not installed - pass + __version__ = version("pymirc") +except PackageNotFoundError: + __version__ = "unknown" diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..a9544f9 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,43 @@ +[build-system] +requires = ["setuptools >= 61.0", "wheel", "setuptools-scm"] +build-backend = "setuptools.build_meta" + +[tool.setuptools] +packages = { find = { include = ["pymirc*"], exclude = ["tutorial*"] } } + +[tool.setuptools_scm] +version_scheme = "post-release" +local_scheme = "dirty-tag" + +[project] +name = "pymirc" +dynamic = ["version"] +dependencies = [ + "numpy>=1.15", + "scipy>=1.1", + "matplotlib>=2.2.2", + "pydicom>=2.0", + "scikit-image>=0.14", + "numba>=0.39", + "nibabel>=3.0", +] +requires-python = ">=3.8" +authors = [ + {name = "Georg Schramm"}, + {name = "Tom Eelbode"}, + {name = "Jeroen Bertels"}, +] +maintainers = [ + {name = "Georg Schramm", email = "georg.schramm@kuleuven.be"} +] +description = "Python imaging utilities developed in the medical imaging research center of KU Leuven" +readme = "README.md" +license = {file = "LICENSE"} +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)", + "Operating System :: OS Independent", +] + +[project.urls] +Repository = "https://github.com/gschramm/pymirc" diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 9b5dc37..0000000 --- a/requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -numpy>=1.15.0 -scipy>=1.1.0 -numba>=0.39.0 -matplotlib>=2.2.2 -pydicom>=1.1.0 diff --git a/setup.py b/setup.py deleted file mode 100644 index 1d3ff01..0000000 --- a/setup.py +++ /dev/null @@ -1,31 +0,0 @@ -import setuptools - -setuptools.setup( - name="pymirc", - use_scm_version={"fallback_version": "unkown"}, - setup_requires=["setuptools_scm", "setuptools_scm_git_archive"], - author="Georg Schramm, Tom Eelbode, Jeroen Bertels", - author_email="georg.schramm@kuleuven.be", - description="Python imaging utilities developed in the medical imaging research center of KU Leuven", - long_description="Python imaging utilities developed in the medical imaging research center of KU Leuven", - license="LGPL-3.0-or-later", - license_files=("LICENSE",), - long_description_content_type="text/markdown", - url="https://github.com/gschramm/pymirc", - packages=setuptools.find_packages(exclude=["data", "examples", "tutorial"]), - classifiers=[ - "Programming Language :: Python :: 3", - "License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)", - "Operating System :: OS Independent", - ], - python_requires=">=3.6", - install_requires=[ - "numpy>=1.15", - "scipy>=1.1", - "matplotlib>=2.2.2", - "pydicom>=2.0", - "scikit-image>=0.14", - "numba>=0.39", - "nibabel>=3.0", - ], -) diff --git a/style_guide.md b/style_guide.md index 65d6f9b..b0a07a8 100644 --- a/style_guide.md +++ b/style_guide.md @@ -1,6 +1,5 @@ -Style guide for pymirc -====================== +# Style guide for pymirc -* no tabs in source code (use spaces) -* use 2 or 4 spaces for indentation -* use numpy style for docstrings https://sphinxcontrib-napoleon.readthedocs.io/en/latest/ +- no tabs in source code (use spaces) +- use numpy style for docstrings https://sphinxcontrib-napoleon.readthedocs.io/en/latest/ +- use black formatter