From e39269387d42d43cbc1a45e8615bb21c3dfcfb99 Mon Sep 17 00:00:00 2001 From: Laurent Rene de Cotret Date: Wed, 13 Nov 2024 09:37:42 -0500 Subject: [PATCH] Transition to pyproject.toml --- .github/workflows/ci.yml | 30 +++++--------- .readthedocs.yml | 6 ++- CONTRIBUTING.md | 5 +-- MANIFEST.in | 2 - dev-requirements.txt | 11 ------ docs/installation.rst | 2 +- pyproject.toml | 75 +++++++++++++++++++++++++++++++++++ requirements.txt | 9 ----- setup.cfg | 5 --- setup.py | 85 ---------------------------------------- 10 files changed, 92 insertions(+), 138 deletions(-) delete mode 100644 dev-requirements.txt create mode 100644 pyproject.toml delete mode 100644 requirements.txt delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ccc842a2..ebc43e46 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,42 +32,32 @@ jobs: if: startsWith(runner.os, 'Linux') with: path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt') }} + key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }} - uses: actions/cache@v4 if: startsWith(runner.os, 'macOS') with: path: ~/Library/Caches/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt') }} + key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }} - uses: actions/cache@v4 if: startsWith(runner.os, 'Windows') with: path: ~\AppData\Local\pip\Cache - key: ${{ runner.os }}-py${{ matrix.python-version }}-pip-${{ hashFiles('**/*requirements.txt') }} + key: ${{ runner.os }}-py${{ matrix.python-version }}-pip-${{ hashFiles('pyproject.toml') }} - name: Install dependencies run: | python -m pip install --upgrade pip - pip install numpy wheel - pip install -r requirements.txt - pip install -r dev-requirements.txt + pip install .[development] - # We run the tests on the installed package, with all optional dependencies - # Note the use of the -Wa flag to show DeprecationWarnings - - name: Unit tests + - name: Unit tests and doc tests run: | - python -m pip install .[diffshow] - cd ~ - python -Wa -m pytest --pyargs skued --import-mode=importlib + python -Wa -m pytest - name: Build documentation run: | - python setup.py build_sphinx - - - name: Doctests - run: | - python -m sphinx -b doctest docs build + sphinx-build -M html docs build/docs release: @@ -87,8 +77,8 @@ jobs: - name: Install dependencies run: | - pip install -r requirements.txt - pip install -r dev-requirements.txt + pip install build + pip install .[development] - name: Create release description run: | @@ -97,7 +87,7 @@ jobs: - name: Create source distribution run: | - python setup.py sdist + python -m build - name: Create release uses: softprops/action-gh-release@v2 diff --git a/.readthedocs.yml b/.readthedocs.yml index 32bc2079..6862b15e 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -14,5 +14,7 @@ build: python: install: - - requirements: requirements.txt - - requirements: dev-requirements.txt \ No newline at end of file + - method: pip + path: . + extra_requirements: + - development \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bd8307ca..522c6eb5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -115,10 +115,9 @@ Once you've fixed all merge conflicts, do: ### Build environment setup -To create an appropriate development environment, you need to install the base requirements (`requirements.txt`) as well as extra, development requirements (`dev-requirements.txt`) +To create an appropriate development environment, you need to install the base requirements as well as extra, development requirements: - pip install -r requirements - pip install -r dev-requirements + pip install .[development] ## Guidelines diff --git a/MANIFEST.in b/MANIFEST.in index 4ecd9a85..811ec51a 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,8 +1,6 @@ include README.md include CHANGELOG.rst include LICENSE.txt -include requirements.txt -include dev-requirements.txt recursive-include skued/baseline/data * recursive-include skued/simulation/data * diff --git a/dev-requirements.txt b/dev-requirements.txt deleted file mode 100644 index 8879afbb..00000000 --- a/dev-requirements.txt +++ /dev/null @@ -1,11 +0,0 @@ -setuptools; python_version >= '3.12' -# The ability to build documentation using `python setup.py build_sphinx` -# has been removed as of Sphinx v7. -# Until the setup script `setup.py` has been changed to setup.cfg -# we cannot use sphinx 7+ -Sphinx >= 3, <7 -sphinx_rtd_theme >= 0.4 -cython >= 0.25 -pytest >= 6 -black -wheel \ No newline at end of file diff --git a/docs/installation.rst b/docs/installation.rst index 9e0b2de3..07e37f3d 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -9,7 +9,7 @@ Installation Requirements ============ -Scikit-ued works on Linux, Mac OS X and Windows. It requires Python 3.7+. Packages requirements are `listed here `_. +Scikit-ued works on Linux, Mac OS X and Windows. It requires Python 3.7+. Packages requirements are `listed here `_. Install scikit-ued ================== diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..9762b9c1 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,75 @@ +[build-system] +requires = ["build", "setuptools>=61.0"] +build-backend = "setuptools.build_meta" + +[tool.setuptools.dynamic] +version = {attr = "skued.__version__"} + +[project] +name = "scikit-ued" +dynamic = ["version"] +authors = [ + { name="Laurent P. René de Cotret", email="laurent.decotret@outlook.com" }, +] +maintainers = [ + { name="Laurent P. René de Cotret", email="laurent.decotret@outlook.com" }, +] +description = "Collection of algorithms and functions for ultrafast electron scattering" +readme = "README.md" +license = {file = "LICENSE"} +requires-python = ">=3.7, <4" +dependencies = [ + "crystals >= 1.3.1, < 2", + "npstreams >= 1.6.5, < 2", + "numpy >= 1.17, < 3", + "pywavelets >= 1.0.0, < 2", + "scikit-image >= 0.19, < 1", + # See https://github.com/scipy/scipy/issues/17740 + "scipy >= 1.5.0, < 2, != 1.10.0", + "pyyaml >= 3.1", + "matplotlib >= 3.5, <4", +] +keywords=["ultrafast electron scattering"] +classifiers = [ + "Environment :: Console", + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", + "Natural Language :: English", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Topic :: Scientific/Engineering", + "Topic :: Scientific/Engineering :: Physics", +] + +[project.optional-dependencies] +development = [ + "Sphinx >= 3, <7", + "sphinx_rtd_theme >= 0.4", + "pytest >= 6", + "black", +] +diffshow = ["pyqtgraph>=0.12,<1", "PyQt5"] + +[project.urls] +Documentation = "https://crystals.readthedocs.io/" +Repository = "https://github.com/LaurentRDC/crystals" +"Bug Tracker" = "https://github.com/LaurentRDC/crystals/issues" + +[project.scripts] +skued-cli = "skued.__main__:main" + +[tool.black] +line-length = 120 +include = '\.pyi?$' + +[tool.isort] +profile = "black" + +[tool.pytest.ini_options] +minversion = "6.0" +log_cli_level = "INFO" +# Very cool ability for pytest to also run doctests on package contents with `-doctest-modules` +addopts = [ + "--doctest-modules", +] \ No newline at end of file diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 75a1c7b4..00000000 --- a/requirements.txt +++ /dev/null @@ -1,9 +0,0 @@ -crystals >= 1.3.1, < 2 -npstreams >= 1.6.5, < 2 -numpy >= 1.17, < 3 -pywavelets >= 1.0.0, < 2 -scikit-image >= 0.19, < 1 -# See https://github.com/scipy/scipy/issues/17740 -scipy >= 1.5.0, < 2, != 1.10.0 -pyyaml >= 3.1 -matplotlib >= 3.5, <4 diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index dd84e9d3..00000000 --- a/setup.cfg +++ /dev/null @@ -1,5 +0,0 @@ -[bdist_wheel] -universal = 0 - -[metadata] -description-file = README.md \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index 1c3d7463..00000000 --- a/setup.py +++ /dev/null @@ -1,85 +0,0 @@ -# -*- coding: utf-8 -*- -import re -from pathlib import Path - -# import numpy -# from Cython.Build import cythonize -from setuptools import find_packages, setup - -PACKAGE_NAME = "scikit-ued" -DESCRIPTION = "Collection of algorithms and functions for ultrafast electron scattering" -URL = "http://scikit-ued.readthedocs.io" -DOWNLOAD_URL = "http://github.com/LaurentRDC/scikit-ued" -AUTHOR = "Laurent P. René de Cotret" -AUTHOR_EMAIL = "laurent.decotret@outlook.com" -BASE_PACKAGE = "skued" - -base_path = Path(__file__).parent -with open(base_path / BASE_PACKAGE / "__init__.py") as f: - module_content = f.read() - VERSION = ( - re.compile(r".*__version__ = \"(.*?)\"", re.S).match(module_content).group(1) - ) - LICENSE = ( - re.compile(r".*__license__ = \"(.*?)\"", re.S).match(module_content).group(1) - ) - -with open("README.md") as f: - README = f.read() - -with open("requirements.txt") as f: - REQUIREMENTS = [line for line in f.read().split("\n") if len(line.strip())] - -exclude = {"exclude": ["external*", "docs", "*cache"]} -PACKAGES = [ - BASE_PACKAGE + "." + x - for x in find_packages(str(base_path / BASE_PACKAGE), **exclude) -] -if BASE_PACKAGE not in PACKAGES: - PACKAGES.append(BASE_PACKAGE) - - -if __name__ == "__main__": - setup( - name=PACKAGE_NAME, - description=DESCRIPTION, - long_description=README, - long_description_content_type="text/markdown", - license=LICENSE, - url=URL, - download_url=DOWNLOAD_URL, - version=VERSION, - author=AUTHOR, - author_email=AUTHOR_EMAIL, - maintainer=AUTHOR, - maintainer_email=AUTHOR_EMAIL, - install_requires=REQUIREMENTS, - extras_require={"diffshow": ["pyqtgraph>=0.12,<1", "PyQt5"]}, - keywords="ultrafast electron scattering", - project_urls={ - "Documentation": "https://scikit-ued.readthedocs.io/", - "Source": "https://github.com/LaurentRDC/scikit-ued", - }, - python_requires=">=3.7", - packages=PACKAGES, - entry_points={"console_scripts": ["skued = skued.__main__:main"]}, - include_package_data=True, - zip_safe=False, - # include_dirs = [numpy.get_include()], - # ext_modules = cythonize("skued/*/**.pyx", - # compiler_directives = {'language_level':3, - # 'boundscheck': False}), - # list of possible classifiers: - # https://pypi.python.org/pypi?%3Aaction=list_classifiers - classifiers=[ - "Environment :: Console", - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Science/Research", - "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", - "Natural Language :: English", - "Operating System :: OS Independent", - "Programming Language :: Python :: 3", - "Topic :: Scientific/Engineering", - "Topic :: Scientific/Engineering :: Physics", - ], - )