diff --git a/.github/workflows/buildAndUploadPyPi.yml b/.github/workflows/buildAndUploadPyPi.yml index 7df503b3f..73ee3c014 100644 --- a/.github/workflows/buildAndUploadPyPi.yml +++ b/.github/workflows/buildAndUploadPyPi.yml @@ -13,7 +13,8 @@ jobs: strategy: matrix: # macos-13 is an intel runner, macos-14 is apple silicon - os: [ ubuntu-latest, windows-latest, macos-13, macos-14 ] + os: [ ubuntu-latest, windows-latest, macos-14 ] +# os: [ubuntu-latest, ubuntu-24.04-arm, windows-latest, windows-11-arm, macos-13, macos-14] steps: - uses: actions/checkout@v4 @@ -21,7 +22,9 @@ jobs: fetch-depth: 0 - name: Build wheels - uses: pypa/cibuildwheel@v2.21.3 + uses: pypa/cibuildwheel@v3.0.0 + env: + CIBW_PLATFORM: ${{ matrix.platform || 'auto' }} - uses: actions/upload-artifact@v4 with: @@ -33,9 +36,27 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - - name: Build sdist - run: pipx run build --sdist + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.12 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install numpy cython build +# - name: Compile cython code +# run: | +# python setup.py build_ext --inplace +# - name: Install avaframe +# run: | +# pip install . + - name: create source distribution + run: python -m build +# - name: Build sdist +# run: pipx run build --sdist - uses: actions/upload-artifact@v4 with: @@ -48,7 +69,7 @@ jobs: environment: pypi permissions: id-token: write - if: github.event_name == 'release' && github.event.action == 'published' +# if: github.event_name == 'release' && github.event.action == 'published' # or, alternatively, upload to PyPI on every tag starting with 'v' (remove on: release above to use this) # if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') steps: @@ -59,6 +80,4 @@ jobs: path: dist merge-multiple: true - - uses: pypa/gh-action-pypi-publish@release/v1 - with: - # To test: repository-url: https://test.pypi.org/legacy/ \ No newline at end of file + - uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file diff --git a/.github/workflows/releaseWithManylinux.yml b/.github/workflows/releaseWithManylinux.yml deleted file mode 100644 index e54b02211..000000000 --- a/.github/workflows/releaseWithManylinux.yml +++ /dev/null @@ -1,111 +0,0 @@ -# Deploy to pypi for all plattforms - -name: releaseWithManyLinux - -on: - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -jobs: - # Build and deploy manylinux wheel - Linux-build: - runs-on: ubuntu-latest - env: - TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} - TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install numpy cython - # This compilation is necessary to have the .c file for the next step - # Alternative is to include the .c file in the repo - - name: Compile cython code - run: | - python setup.py build_ext --inplace - - name: Install avaframe - run: | - pip install . - - name: build manylinux wheels - uses: RalfG/python-wheels-manylinux-build@v0.7.1 - with: - python-versions: 'cp38-cp38 cp39-cp39 cp310-cp310 cp311-cp311 cp312-cp312 cp313-cp313' - build-requirements: 'cython numpy' - - name: Publish wheels to PyPI - run: | - pip install -U pkginfo packaging twine --break-system-packages - twine upload dist/*-manylinux*.whl - continue-on-error: true - - # deploy source distribution - Source-dist: - runs-on: ubuntu-latest - env: - TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} - TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: 3.11 - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install numpy cython - - name: Compile cython code - run: | - python setup.py build_ext --inplace - - name: Install avaframe - run: | - pip install . - - name: create source distribution - run: python setup.py sdist - - name: upload source distribution - run: | - pip install twine - pip install -U pkginfo - pip install -U packaging - twine upload dist/* - continue-on-error: true - - # Build and deploy wheels for macos and windows using setup-python action. - Matrix-build: - runs-on: ${{ matrix.os }} - env: - TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} - TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} - strategy: - matrix: - os: [windows-latest, macos-latest] - python-version: [ '3.8','3.9','3.10','3.11','3.12','3.13' ] - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - name: build wheel - run: | - pip install wheel setuptools - pip install numpy cython - - name: Compile cython code - run: | - python setup.py build_ext --inplace - - name: build wheel - run: | - python setup.py bdist_wheel - - name: upload wheel - run: | - pip install twine - pip install -U pkginfo - pip install -U packaging - twine upload dist/* - continue-on-error: true \ No newline at end of file diff --git a/.github/workflows/runTestSinglePython.yml b/.github/workflows/runTestSinglePython.yml index 9f7eeab54..d5db61fe3 100644 --- a/.github/workflows/runTestSinglePython.yml +++ b/.github/workflows/runTestSinglePython.yml @@ -8,12 +8,10 @@ on: branches: [ master ] paths-ignore: - 'docs/**' - - 'avaframe/com4FlowPy/**' pull_request: branches: [ master ] paths-ignore: - 'docs/**' - - 'avaframe/com4FlowPy/**' workflow_dispatch: jobs: @@ -36,34 +34,16 @@ jobs: pip install flake8 pytest pytest-cov pip install numpy cython pip install setuptools - pip install pytest_mock - # This compilation is necessary to have the .c file for the next step - # Alternative is to include the .c file in the repo + pip install pytest-mock - name: Compile cython code run: | python setup.py build_ext --inplace --define CYTHON_TRACE - name: Install avaframe run: | pip install . - - 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: Test with pytest run: | pytest -ra --cov --cov-report=xml --cov-report lcov:cov.info --cov-config=.coveragerc - - name: Test & publish code coverage - uses: paambaati/codeclimate-action@v9.0.0 - env: - CC_TEST_REPORTER_ID: ${{ secrets.CODECLIMATE_ID }} - # - name: Upload coverage to Codecov - # uses: codecov/codecov-action@v3 - # with: - # fail_ci_if_error: false - # name: codecov-umbrella - # verbose: true - uses: qltysh/qlty-action/coverage@main with: coverage-token: ${{secrets.QLTY_COVERAGE_TOKEN}} diff --git a/MANIFEST.in b/MANIFEST.in index 302672190..10f238b60 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,6 +1,8 @@ include avaframe/RELEASE-VERSION include avaframe/version.py include avaframe/in3Utils/logging.conf +include avaframe/com1DFA/*.pyx +include avaframe/com1DFA/*.pxd recursive-include avaframe *Cfg.ini global-exclude local_*Cfg.ini prune benchmarks diff --git a/pyproject.toml b/pyproject.toml index 982aa6196..eb1397528 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,8 @@ [build-system] # Cython dependency is optional, see setup.py for details. # For the package (run-time) dependencies, see setup.cfg. -#requires = ["setuptools", "wheel", "numpy", "Cython"] -#build-backend = "setuptools.build_meta" -requires = ["hatchling", "hatch-vcs"] -build-backend = "hatchling.build" +requires = ["setuptools", "numpy", "Cython", "setuptools-scm"] +build-backend = "setuptools.build_meta" [project] name = "avaframe" @@ -50,21 +48,36 @@ dependencies = [ "salib" ] +# Setuptools +[tool.setuptools] +include-package-data = true + +[tool.setuptools.packages.find] +exclude = ["docs"] +namespaces = false + +[tool.setuptools_scm] +version_scheme = "no-guess-dev" +local_scheme = "node-and-date" + +# Cibuildwhell +[tool.cibuildwheel] +# Only build on CPython 3.12 +#build = "cp312-*" +skip = ["*musllinux*","*-win32"] +build-verbosity = 1 +before-build = "pip install cython numpy" + +#Flake8 [tool.flake8] max-line-length = 109 select = ['B950'] extend-ignore = ['E203', 'E501'] +#Black [tool.black] line-length = 109 -[tool.hatch.version] -source = "vcs" - -[tool.hatch.version.raw-options] -version_scheme = "no-guess-dev" -local_scheme = "node-and-date" - # PIXI setup [tool.pixi.workspace] channels = ["https://prefix.dev/conda-forge"] @@ -72,7 +85,9 @@ platforms = ["linux-64", "win-64", "osx-64"] [tool.pixi.dependencies] pytest = "*" +pytest-mock ="*" setuptools = "*" +setuptools-scm = "*" # Feature dev [tool.pixi.feature.dev.pypi-dependencies] diff --git a/setup.py b/setup.py index d62057dc7..e340044d0 100644 --- a/setup.py +++ b/setup.py @@ -1,64 +1,46 @@ -# -*- coding: utf-8 -*- -"""Setup file for the avaframe package. - -important commands: -python setup.py sdist -python setup.py build_ext --inplace -python setup.py bdist_wheel -twine uploade dist/* - -To create a release (with github): -- update the version number below -- push to github -- create a release there -- run releaseWithMany.. in the actions tab - -""" - -# from setuptools import setup, find_packages # Always prefer setuptools -from setuptools import Extension, setup, find_packages -from pathlib import Path -import sys +from setuptools import setup, Extension import numpy -sys.path.append(str(Path(__file__).parent)) from Cython.Build import cythonize -# Cython part -setup_options = {} -print("Package is built with cythonization.") -setup_options = {"build_ext": {"inplace": True}} +# Define extension modules conditionally +# ext_modules = [] + +# List all potential Cython file locations +cython_files = [ + 'avaframe/com1DFA/DFAfunctionsCython.pyx', + 'avaframe/com1DFA/DFAToolsCython.pyx', + 'avaframe/com1DFA/damCom1DFA.pyx', +] extensions = [ Extension( - "avaframe.com1DFA.DFAfunctionsCython", - ["avaframe/com1DFA/DFAfunctionsCython.pyx"], - include_dirs=[numpy.get_include()], - ), - Extension( - "avaframe.com1DFA.damCom1DFA", - ["avaframe/com1DFA/damCom1DFA.pyx"], - include_dirs=[numpy.get_include()], - ), - Extension( - "avaframe.com1DFA.DFAToolsCython", - ["avaframe/com1DFA/DFAToolsCython.pyx"], - include_dirs=[numpy.get_include()], - ), + name=file.replace('/', '.').replace('.pyx', ''), + sources=[file], + include_dirs=[numpy.get_include()] + ) + for file in cython_files ] -extensions = cythonize(extensions, compiler_directives={"linetrace": True}, language_level=3) +ext_modules = cythonize( + extensions, + compiler_directives={ + 'language_level': '3', + 'linetrace': True, + } +) + +setup_options = {"build_ext": {"inplace": True}} setup( - # Find packages automatically - packages=find_packages(exclude=["docs"]), - # Include package data - include_package_data=True, - # Install dependencies - # Run build_ext options=setup_options, - # Executable scripts - entry_points={}, - zip_safe=False, - ext_modules=extensions, -) + ext_modules=ext_modules, + install_requires=[ + 'numpy', + 'scipy', + 'cython', + 'matplotlib', + 'pandas' + ], + python_requires='>=3.8', +) \ No newline at end of file