diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish-sdist.yml similarity index 53% rename from .github/workflows/python-publish.yml rename to .github/workflows/python-publish-sdist.yml index adc9be7..3a6be63 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish-sdist.yml @@ -18,24 +18,17 @@ on: types: [created] jobs: - deploy: - + pypi: + name: Publish sdist to Pypi runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: '3.8' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install setuptools wheel twine build - - name: Build package - run: python -m build - - name: Publish package - uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 - with: - user: __token__ - password: ${{ secrets.PYPI_API_TOKEN }} + - 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 bsplines2d/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..7e5c882 --- /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.8", "3.9", "3.10", "3.11"] + 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 bsplines2d/tests/prepublish.py + - name: publish + run: uv publish -t ${{ secrets.PYPI_API_TOKEN }} diff --git a/.github/workflows/python-testing-branch.yml b/.github/workflows/python-testing-branch.yml deleted file mode 100644 index afd3927..0000000 --- a/.github/workflows/python-testing-branch.yml +++ /dev/null @@ -1,51 +0,0 @@ -# This workflow will install Python dependencies, run tests and lint with a variety of Python versions -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - -name: Testing matrix - -on: - push: - branches: - - '**' # matches every branch - - '!main' # excludes master - - '!devel' # excludes devel - pull_request: - branches: - - '**' # matches every branch - - '!main' # excludes master - - '!devel' # excludes devel - -jobs: - build: - - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: true - matrix: - os: [ubuntu-latest] - python-version: ["3.9"] - - steps: - - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - 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 - run: | - pip install -e ".[dev]" # --no-build-isolation - - name: Test with pytest - run: | - pytest bsplines2d/tests -v -x diff --git a/.github/workflows/python-testing-matrix-devel.yml b/.github/workflows/python-testing-matrix-devel.yml deleted file mode 100644 index f173429..0000000 --- a/.github/workflows/python-testing-matrix-devel.yml +++ /dev/null @@ -1,45 +0,0 @@ -# This workflow will install Python dependencies, run tests and lint with a variety of Python versions -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - -name: Testing matrix - -on: - push: - branches: [ devel ] - pull_request: - branches: [ devel ] - -jobs: - build: - - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: true - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - python-version: ["3.8", "3.9", "3.10"] - - steps: - - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - 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 - run: | - pip install -e ".[dev]" # --no-build-isolation - - name: Test with pytest - run: | - pytest bsplines2d/tests -v -x diff --git a/.github/workflows/python-testing-matrix.yml b/.github/workflows/python-testing-matrix.yml new file mode 100644 index 0000000..0c3ddd8 --- /dev/null +++ b/.github/workflows/python-testing-matrix.yml @@ -0,0 +1,41 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Testing matrix + +on: + push: + branches: [ devel ] + pull_request: + branches: [ devel ] + +jobs: + build: + + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: true + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + python-version: ["3.8", "3.9", "3.10", "3.11"] + + steps: + + # git checkout + - uses: actions/checkout@v4 + + # Install uv + - name: Install uv + uses: astral-sh/setup-uv@v5 + with: + 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 bsplines2d/tests diff --git a/CLASSIFIERS.txt b/CLASSIFIERS.txt new file mode 100644 index 0000000..61c547f --- /dev/null +++ b/CLASSIFIERS.txt @@ -0,0 +1,10 @@ +Development Status :: 5 - Production/Stable +Intended Audience :: Science/Research +Programming Language :: Python :: 3 +Programming Language :: Python :: 3.6 +Programming Language :: Python :: 3.7 +Programming Language :: Python :: 3.8 +Programming Language :: Python :: 3.9 +Programming Language :: Python :: 3.10 +Programming Language :: Python :: 3.11 +Natural Language :: English diff --git a/LICENSE b/LICENSE deleted file mode 100644 index dc8b1e1..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2023 ToFuProject - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 257fcf4..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,7 +0,0 @@ -# all files to be included - -include MANIFEST.in -include LICENSE.txt -include pyproject.toml -include _updateversion.py -recursive-include bsplines2d/tests/test_data *.npz diff --git a/_updateversion.py b/_updateversion.py deleted file mode 100644 index d9e79e5..0000000 --- a/_updateversion.py +++ /dev/null @@ -1,32 +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, 'bsplines2d', '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/bsplines2d/tests/prepublish.py b/bsplines2d/tests/prepublish.py new file mode 100644 index 0000000..3422791 --- /dev/null +++ b/bsplines2d/tests/prepublish.py @@ -0,0 +1,3 @@ +print('test import datastock') +import datastock as ds +print('import datastock ok') diff --git a/pyproject.toml b/pyproject.toml index ade200c..b2eaaa6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,58 +1,61 @@ +[build-system] +requires = ["setuptools", "setuptools_scm"] +build-backend = "setuptools.build_meta" + + +#[tool.setuptools.packages.find] +#where = ["datastock"] +#include = ["datastock*"] +#namespaces = false + +[tool.setuptools] +packages = ["bsplines2d", "bsplines2d.tests", "bsplines2d.tests.test_data"] + + +[tool.setuptools_scm] +version_file = "bsplines2d/_version.py" + +[tool.setuptools.package-data] +mypkg = ["*.txt", "*.npz"] + + +[tool.setuptools.dynamic] +classifiers = {file = ["CLASSIFIERS.txt"]} + + [project] name = "bsplines2d" -license = {file = "LICENSE"} -dynamic = ["version"] -description = "Generic handler for multiple bsplines basis" readme = "README.md" -requires-python = ">=3.6" +license = {text = "MIT"} +dynamic = ["version", "classifiers"] +description = "Generic handler for 1d and 1d bsplines meshes, uses datastock" authors = [ - {name = "Didier VEZINET", email = "didier.vezinet@gmail.com"}, + {name = "Didier VEZINET", email = "didier.vezinet@gmail.com"}, ] maintainers = [ - {name = "Didier VEZINET", email = "didier.vezinet@gmail.com"}, + {name = "Didier VEZINET", email = "didier.vezinet@gmail.com"}, ] -keywords = ["data", "analysis", "interactive", "2d meshing", "Collection"] -classifiers = [ - # How mature is this project? Common values are - # 3 - Alpha - # 4 - Beta - # 5 - Production/Stable - "Development Status :: 5 - Production/Stable", - - # Indicate who your project is intended for - "Intended Audience :: Science/Research", - - # Specify the Python versions you support here. - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", +keywords = [ + "data", "analysis", "interactive", "bsplines", "Collection", "mesh", ] +requires-python = ">=3.8" dependencies = [ - "numpy", - "scipy", - "matplotlib", - "astropy", - "contourpy", - "datastock>=0.0.49", + "contourpy", + 'datastock>=0.0.54', ] -[build-system] -requires = [ - "setuptools>=40.8.0, <64", - "wheel", - "numpy", -] +[project.urls] +Homepage = "https://github.com/ToFuProject/bsplines2d" +Issues = "https://github.com/ToFuProject/bsplines2d/issues" + [dependency-groups] dev = [ "pytest", ] + [project.optional-dependencies] linting = [ 'ruff' diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 768f847..0000000 --- a/requirements.txt +++ /dev/null @@ -1,7 +0,0 @@ -####### Requirements without Version Specifiers ####### -numpy -scipy -matplotlib -astropy -contourpy -datastock>=0.0.49 diff --git a/setup.py b/setup.py deleted file mode 100644 index dbf53fd..0000000 --- a/setup.py +++ /dev/null @@ -1,179 +0,0 @@ -""" A tomography library for fusion devices - -See: -https://github.com/ToFuProject/bsplines2d -""" - -# 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="bsplines2d", - 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 generic multidimensional bsplines on various meshes, using datastock", - long_description=long_description, - long_description_content_type=long_description_content_type, - - # The project's main homepage. - url="https://github.com/ToFuProject/bsplines2d", - # 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="bsplines data analysis modelling mesh plot", - - # 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", - "astropy", - "contourpy", - "datastock>=0.0.49", - ], - 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={ - 'bsplines2d.tests.test_data': ['.npz'], - }, - 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={}, - # include_dirs=[np.get_include()], - - py_modules=['_updateversion'], -)