From 141478739a4ae7bf692db3a556be9bc587a65f9c Mon Sep 17 00:00:00 2001 From: dvezinet Date: Fri, 6 Feb 2026 21:41:18 +0000 Subject: [PATCH 1/6] [#88] pyproject.toml --- pyproject.toml | 66 +++++++++++++++++++++++++++++++++++++++++++++--- requirements.txt | 5 ---- 2 files changed, 63 insertions(+), 8 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ea97b8e..2c00587 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,4 +1,64 @@ [build-system] -requires = ["setuptools>=40.8.0", - "wheel", - ] +requires = ["setuptools", "setuptools_scm"] +build-backend = "setuptools.build_meta" + + +[tool.setuptools] +packages = ["spectrally", "spectrally.tests"] + + +[tool.setuptools_scm] +version_file = "spectrally/_version.py" + + +[tool.setuptools.dynamic] +classifiers = {file = ["CLASSIFIERS.txt"]} + + +[project] +name = "spectrally" +readme = "README.md" +license = {text = "MIT"} +dynamic = ["version", "classifiers"] +description = "Generic spectrum fitting library with multiple constraints" +authors = [ + {name = "Didier VEZINET", email = "didier.vezinet@gmail.com"}, +] +maintainers = [ + {name = "Didier VEZINET", email = "didier.vezinet@gmail.com"}, +] +keywords = [ + "data", "spectrum fitting", "Collection", +] +# due to astropy >= 6.1 and to end-of-life of 3.9 +# see https://devguide.python.org/versions/ +requires-python = ">=3.10" +dependencies = [ + "bsplines2d>=0.0.30", + "pandas", + "requests", +] + + +[project.urls] +Homepage = "https://github.com/ToFuProject/spectrally" +Issues = "https://github.com/ToFuProject/spectrally/issues" + + +[project.entry-points."spectrally"] +spectrally = "scripts.main:main" + + +[dependency-groups] +dev = [ + "pytest", +] + + +[project.optional-dependencies] +linting = [ + 'ruff' +] +formatting = [ + 'ruff' +] diff --git a/requirements.txt b/requirements.txt index d99c493..cc1f87f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,3 @@ ####### Requirements without Version Specifiers ####### -numpy -scipy -matplotlib pandas -astropy requests -bsplines2d>=0.0.19 From 74e1d4e55568a7a669cb26e66d459dd92160452c Mon Sep 17 00:00:00 2001 From: dvezinet Date: Fri, 6 Feb 2026 21:55:53 +0000 Subject: [PATCH 2/6] [88] Updated / cleanup --- _updateversion.py | 33 -------- pyproject.toml | 4 +- requirements.txt | 3 - setup.py | 186 ---------------------------------------------- 4 files changed, 3 insertions(+), 223 deletions(-) delete mode 100644 _updateversion.py delete mode 100644 requirements.txt delete mode 100644 setup.py diff --git a/_updateversion.py b/_updateversion.py deleted file mode 100644 index 90924c5..0000000 --- a/_updateversion.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env/python -# coding=utf-8 - - -import os -import subprocess - - -_HERE = os.path.abspath(os.path.dirname(__file__)) - - -def updateversion(path=_HERE): - - # Fetch version from git tags, and write to version.py - # Also, when git is not available (PyPi package), use stored version.py - version_py = os.path.join(path, 'spectrally', 'version.py') - try: - version_git = subprocess.check_output( - ["git", "describe"] - ).rstrip().decode() - - except subprocess.CalledProcessError: - with open(version_py, 'r') as fh: - version_git = fh.read().strip().split("=")[-1].replace("'", '') - - version_git = version_git.lower().replace('v', '').replace(' ', '') - - version_msg = "# Do not edit, pipeline versioning governed by git tags!" - with open(version_py, "w") as fh: - msg = "{0}__version__ = '{1}'{0}".format(os.linesep, version_git) - fh.write(version_msg + msg) - - return version_git diff --git a/pyproject.toml b/pyproject.toml index 2c00587..cb0dd61 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,7 +46,9 @@ Issues = "https://github.com/ToFuProject/spectrally/issues" [project.entry-points."spectrally"] -spectrally = "scripts.main:main" +spectrally = "spectrally.scripts.spectrally_bash:main" +spectrally-version = 'spectrally.scripts.spectrallyversion:main', +specrally-custom = 'spectrally.scripts.spectrallycustom:main', [dependency-groups] diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index cc1f87f..0000000 --- a/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -####### Requirements without Version Specifiers ####### -pandas -requests diff --git a/setup.py b/setup.py deleted file mode 100644 index b48a5fe..0000000 --- a/setup.py +++ /dev/null @@ -1,186 +0,0 @@ -""" A tomography library for fusion devices - -See: -https://github.com/ToFuProject/spectrally -""" - -# Built-in -import os -import subprocess -from codecs import open -# ... setup tools -from setuptools import setup, find_packages - - -# ... local script -import _updateversion as up - - -# == Getting version ===================================================== -_HERE = os.path.abspath(os.path.dirname(__file__)) - -version = up.updateversion() - -print("") -print("Version for setup.py : ", version) -print("") - - -# ============================================================================= -# Get the long description from the README file -# Get the readme file whatever its extension (md vs rst) - -_README = [ - ff - for ff in os.listdir(_HERE) - if len(ff) <= 10 and ff[:7] == "README." -] -assert len(_README) == 1 -_README = _README[0] -with open(os.path.join(_HERE, _README), encoding="utf-8") as f: - long_description = f.read() -if _README.endswith(".md"): - long_description_content_type = "text/markdown" -else: - long_description_content_type = "text/x-rst" - - -# ============================================================================= - - -# ============================================================================= -# Compiling files - -setup( - name="spectrally", - version=f"{version}", - # Use scm to get code version from git tags - # cf. https://pypi.python.org/pypi/setuptools_scm - # Versions should comply with PEP440. For a discussion on single-sourcing - # the version across setup.py and the project code, see - # https://packaging.python.org/en/latest/single_source_version.html - # The version is stored only in the setup.py file and read from it (option - # 1 in https://packaging.python.org/en/latest/single_source_version.html) - use_scm_version=False, - - # Description of what library does - description="A python library for spectral fitting", - long_description=long_description, - long_description_content_type=long_description_content_type, - - # The project's main homepage. - url="https://github.com/ToFuProject/spectrally", - # Author details - author="Didier VEZINET", - author_email="didier.vezinet@gmail.com", - - # Choose your license - license="MIT", - - # See https://pypi.python.org/pypi?%3Aaction=list_classifiers - classifiers=[ - # How mature is this project? Common values are - # 3 - Alpha - # 4 - Beta - # 5 - Production/Stable - "Development Status :: 4 - Beta", - # Indicate who your project is intended for - "Intended Audience :: Science/Research", - "Topic :: Scientific/Engineering :: Physics", - # Pick your license as you wish (should match "license" above) - "License :: OSI Approved :: MIT License", - # Specify the Python versions you support here. In particular, ensure - # that you indicate whether you support Python 2, Python 3 or both. - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - # In which language most of the code is written ? - "Natural Language :: English", - ], - - # What does your project relate to? - keywords="spectral fit gaussian lorentzian voigt", - - # You can just specify the packages manually here if your project is - # simple. Or you can use find_packages(). - packages=find_packages( - exclude=[ - "doc", - ] - ), - - # Alternatively, if you want to distribute just a my_module.py, uncomment - # this: - # py_modules=["my_module"], - # List run-time dependencies here. These will be installed by pip when - # your project is installed. For an analysis of "install_requires" vs pip's - # requirements files see: - # https://packaging.python.org/en/latest/requirements.html - install_requires=[ - "numpy", - "scipy", - "matplotlib", - "pandas", - "requests", - "bsplines2d>=0.0.19", - ], - python_requires=">=3.6", - - # List additional groups of dependencies here (e.g. development - # dependencies). You can install these using the following syntax, - # for example: - # $ pip install -e .[dev,test] - extras_require={ - "dev": [ - "check-manifest", - "coverage", - "pytest", - "sphinx", - "sphinx-gallery", - "sphinx_bootstrap_theme", - ] - }, - - # If there are data files included in your packages that need to be - # installed, specify them here. If using Python 2.6 or less, then these - # have to be included in MANIFEST.in as well. - # package_data={ - # # If any package contains *.txt, *.rst or *.npz files, include them: - # '': ['*.txt', '*.rst', '*.npz'], - # # And include any *.csv files found in the 'ITER' package, too: - # 'ITER': ['*.csv'], - # }, - package_data={ - 'spectrally.tests.input': ['.npz', '.npy', '.json', '.hist'], - 'spectrally': ['.csv'], - }, - include_package_data=True, - - # Although 'package_data' is the preferred approach, in some case you may - # need to place data files outside of your packages. See: - # http://docs.python.org/3.4/distutils/setupscript.html - # installing-additional-files # noqa - # In this case, 'data_file' will be installed into '/my_data' - # data_files=[('my_data', ['data/data_file'])], - - # executable scripts can be declared here - # They can be python or non-python scripts - # scripts=[ - # ], - - # entry_points point to functions in the package - # Theye are generally preferable over scripts because they provide - # cross-platform support and allow pip to create the appropriate form - # of executable for the target platform. - entry_points={ - 'console_scripts': [ - 'spectrally-version=spectrally.scripts.spectrallyversion:main', - 'specrally-custom=spectrally.scripts.spectrallycustom:main', - 'spectrally=spectrally.scripts.spectrally_bash:main', - ], - }, - # include_dirs=[np.get_include()], - - py_modules=['_updateversion'], -) From 60dcae7dfecdecc43e4ad65fd7c2a469ef7f1205 Mon Sep 17 00:00:00 2001 From: dvezinet Date: Fri, 6 Feb 2026 21:57:38 +0000 Subject: [PATCH 3/6] [#88] MANIFEST --- MANIFEST.in | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index bd62c3f..1d79101 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -3,6 +3,4 @@ include MANIFEST.in include LICENSE.txt include pyproject.toml -include _updateversion.py -recursive-include spectrally/tests/input * -recursive-include spectrally/ *.csv \ No newline at end of file +include CLASSIFIERS.txt From 2ace2dbf83d8de20e1298b8e00a673907d074572 Mon Sep 17 00:00:00 2001 From: dvezinet Date: Fri, 6 Feb 2026 21:58:35 +0000 Subject: [PATCH 4/6] [#88] CLASSIFIERS --- CLASSIFIERS.txt | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 CLASSIFIERS.txt diff --git a/CLASSIFIERS.txt b/CLASSIFIERS.txt new file mode 100644 index 0000000..03978c1 --- /dev/null +++ b/CLASSIFIERS.txt @@ -0,0 +1,9 @@ +Development Status :: 5 - Production/Stable +Intended Audience :: Science/Research +Programming Language :: Python :: 3 +Programming Language :: Python :: 3.10 +Programming Language :: Python :: 3.11 +Programming Language :: Python :: 3.12 +Programming Language :: Python :: 3.13 +Programming Language :: Python :: 3.14 +Natural Language :: English From 251fab11c18e358b6ff8363693fd60c7a92f5514 Mon Sep 17 00:00:00 2001 From: dvezinet Date: Fri, 6 Feb 2026 22:09:55 +0000 Subject: [PATCH 5/6] [#88] Updated tests and publish GA --- .github/workflows/python-publish-sdist.yml | 34 ++++++++++++++++++ .github/workflows/python-publish-wheel.yml | 39 ++++++++++++++++++++ .github/workflows/python-testing-matrix.yml | 40 ++++++++++----------- spectrally/tests/prepublish.py | 3 ++ 4 files changed, 94 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/python-publish-sdist.yml create mode 100644 .github/workflows/python-publish-wheel.yml create mode 100644 spectrally/tests/prepublish.py diff --git a/.github/workflows/python-publish-sdist.yml b/.github/workflows/python-publish-sdist.yml new file mode 100644 index 0000000..b2b8d27 --- /dev/null +++ b/.github/workflows/python-publish-sdist.yml @@ -0,0 +1,34 @@ +# This workflow will upload a Python Package using Twine when a release is created +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Upload Python Package + +on: + push: + tags: + - '*' + branches: + - main + release: + types: [created] + +jobs: + pypi: + name: Publish sdist to Pypi + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: astral-sh/setup-uv@v5 + with: + python-version: '3.11' + - run: uv build --sdist + # Check that basic features work and we didn't miss to include crucial files + - name: import test (sdist) + run: uv run --isolated --no-project -p 3.11 --with dist/*.tar.gz spectrally/tests/prepublish.py + - name: publish + run: uv publish -t ${{ secrets.PYPI_API_TOKEN }} diff --git a/.github/workflows/python-publish-wheel.yml b/.github/workflows/python-publish-wheel.yml new file mode 100644 index 0000000..665a7ed --- /dev/null +++ b/.github/workflows/python-publish-wheel.yml @@ -0,0 +1,39 @@ +# This workflow will upload a Python Package using Twine when a release is created +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Upload Python Package wheels + +on: + push: + tags: + - '*' + branches: + - main + release: + types: [created] + +jobs: + pypi: + name: Publish wheel to Pypi + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + python-version: ["3.10", "3.11", "3.12"] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - uses: astral-sh/setup-uv@v5 + with: + python-version: ${{ matrix.python-version }} + - run: uv build --wheel + # Check that basic features work and we didn't miss to include crucial files + - name: import test (wheel) + run: uv run --isolated --no-project -p ${{ matrix.python-version }} --with dist/*.whl spectrally/tests/prepublish.py + - name: publish + run: uv publish -t ${{ secrets.PYPI_API_TOKEN }} diff --git a/.github/workflows/python-testing-matrix.yml b/.github/workflows/python-testing-matrix.yml index 3dd1469..5c8bb08 100644 --- a/.github/workflows/python-testing-matrix.yml +++ b/.github/workflows/python-testing-matrix.yml @@ -18,28 +18,24 @@ jobs: fail-fast: true matrix: os: [ubuntu-latest, windows-latest, macos-latest] - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] steps: - - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + + # git checkout + - uses: actions/checkout@v4 + + # Install uv + - name: Install uv + uses: astral-sh/setup-uv@v5 with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install flake8 pytest - pip install -r requirements.txt - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: install spectrally - run: | - pip install -e ".[dev]" # --no-build-isolation - - name: Test with pytest - run: | - pytest spectrally/tests -v -x + python-version: ${{ matrix.python-version }} + + # Install library + - name: Install the project + run: uv sync --all-extras --dev + + # Run tests + - name: Run tests + # For example, using `pytest` + run: uv run pytest spectrally/tests diff --git a/spectrally/tests/prepublish.py b/spectrally/tests/prepublish.py new file mode 100644 index 0000000..c762d35 --- /dev/null +++ b/spectrally/tests/prepublish.py @@ -0,0 +1,3 @@ +print('test import spectrally') +import spectrally as sp +print('import spectrally ok') From 2eaf3e862c517ce2e12e8ad9cadf51f91de9d491 Mon Sep 17 00:00:00 2001 From: dvezinet Date: Fri, 6 Feb 2026 22:13:40 +0000 Subject: [PATCH 6/6] [#88] Updated minor fix --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index cb0dd61..9dff644 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,8 +47,8 @@ Issues = "https://github.com/ToFuProject/spectrally/issues" [project.entry-points."spectrally"] spectrally = "spectrally.scripts.spectrally_bash:main" -spectrally-version = 'spectrally.scripts.spectrallyversion:main', -specrally-custom = 'spectrally.scripts.spectrallycustom:main', +spectrally-version = 'spectrally.scripts.spectrallyversion:main' +specrally-custom = 'spectrally.scripts.spectrallycustom:main' [dependency-groups]