diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 6c68902..0ca7025 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -5,9 +5,9 @@ name: Linting and Testing on: push: - branches: [ master ] + branches: [ main ] pull_request: - branches: [ master ] + branches: [ main ] jobs: build: @@ -26,7 +26,6 @@ jobs: - name: Install build dependencies run: | python -m pip install --upgrade pip - python -m pip install --upgrade setuptools>=46.4.0 - name: Build package run: | python -m pip install -e .[testing,linting,formatting] @@ -41,7 +40,7 @@ jobs: if: startsWith(matrix.platform,'ubuntu') && matrix.python-version == '3.8' - name: Lint source with pylint run: | - pylint src/cholupdates + pylint src/cholupdates --ignore-paths=src/cholupdates/_version.py if: always() - name: Lint tests with pylint run: | diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index db2bbbf..f57b1ba 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -20,11 +20,15 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install setuptools wheel twine - - name: Build and publish + pip install --upgrade build twine + - name: Build package using `build` + env: + CHOLUPDATES_DISABLE_CYTHON_BUILD: 1 + run: | + python -m build + - name: Publish to PyPI env: TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: | - python setup.py sdist bdist_wheel twine upload dist/* diff --git a/pyproject.toml b/pyproject.toml index d53488f..74e1bc7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,11 +2,15 @@ requires = [ "setuptools>=46.4.0", "wheel", + "setuptools_scm[toml]>=6.0", "Cython", "scipy", ] build-backend = "setuptools.build_meta" +[tool.setuptools_scm] +write_to = "src/cholupdates/_version.py" + [tool.pytest.ini_options] addopts = [ "--verbose", diff --git a/setup.cfg b/setup.cfg index 3d3a7f2..f844df9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,13 +1,12 @@ [metadata] name = cholupdates -version = attr: cholupdates.__version__ description = Efficient Updates to Cholesky Factors after Matrix Modifications url = https://cholupdates.readthedocs.io/ author = Marvin Pförtner -author-email = marvin.pfoertner@icloud.com +author_email = marvin.pfoertner@icloud.com license = MIT -long-description = file: README.md -long-description-content-type = text/markdown +long_description = file: README.md +long_description_content_type = text/markdown keywords = low-rank, rank-1, rank, one, update, downdate, cholesky platforms = any @@ -17,6 +16,8 @@ include_package_data = True package_dir = =src zip_safe = False # Needed for Cython to work +setup_requires = + setuptools_scm[toml]>=6.0 # This is only here for compatibility reasons install_requires = numpy scipy diff --git a/setup.py b/setup.py index 15d8a47..1990066 100644 --- a/setup.py +++ b/setup.py @@ -1,24 +1,36 @@ from setuptools import setup +# Cython Extensions +ext_modules = [] + try: + # isort: off + # This import must come after the setuptools import - from Cython.Build import cythonize # isort: skip - import scipy # isort: skip, pylint: disable=unused-import + from Cython.Build import cythonize + import scipy # pylint: disable=unused-import - build_cython = True -except ImportError: - build_cython = False + import os - print("Not building Cython extensions") + # isort: on -# Extensions -ext_modules = [] + cython_available = True +except ImportError: + cython_available = False + +build_cython = cython_available and not ( + "CHOLUPDATES_DISABLE_CYTHON_BUILD" in os.environ + and os.environ["CHOLUPDATES_DISABLE_CYTHON_BUILD"] == "1" +) if build_cython: ext_modules.extend( cythonize("src/cholupdates/rank_1/_seeger_impl_cython.pyx"), ) +else: + print("Not building Cython extensions") setup( ext_modules=ext_modules, + use_scm_version=True, # This is only here for compatibility reasons ) diff --git a/src/cholupdates/.gitignore b/src/cholupdates/.gitignore index 09b2ac1..ed7e365 100644 --- a/src/cholupdates/.gitignore +++ b/src/cholupdates/.gitignore @@ -1 +1,3 @@ -*.c \ No newline at end of file +**/*.c + +_version.py diff --git a/src/cholupdates/__init__.py b/src/cholupdates/__init__.py index f43cdd8..11a973e 100644 --- a/src/cholupdates/__init__.py +++ b/src/cholupdates/__init__.py @@ -3,5 +3,6 @@ """ from . import rank_1 +from ._version import version as _version_str -__version__ = "0.0.1a2" +__version__ = _version_str diff --git a/src/cholupdates/rank_1/_seeger_impl_cython.pyx b/src/cholupdates/rank_1/_seeger_impl_cython.pyx index 72bcfed..bf7a9dd 100644 --- a/src/cholupdates/rank_1/_seeger_impl_cython.pyx +++ b/src/cholupdates/rank_1/_seeger_impl_cython.pyx @@ -1,3 +1,5 @@ +# cython: language_level = 3 + """Cython implementation of the symmetric rank-1 up- and downdate algorithms from sections 2 and 3 in [1]_.