Skip to content

Commit

Permalink
Merge pull request #15 from marvinpfoertner/version-number-from-git-tag
Browse files Browse the repository at this point in the history
Improvements to the build process
  • Loading branch information
marvinpfoertner authored Aug 17, 2021
2 parents bb8c095 + 6c9774d commit 9a01ea7
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 21 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ name: Linting and Testing

on:
push:
branches: [ master ]
branches: [ main ]
pull_request:
branches: [ master ]
branches: [ main ]

jobs:
build:
Expand All @@ -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]
Expand All @@ -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: |
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 5 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand Down
28 changes: 20 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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
)
4 changes: 3 additions & 1 deletion src/cholupdates/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
*.c
**/*.c

_version.py
3 changes: 2 additions & 1 deletion src/cholupdates/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"""

from . import rank_1
from ._version import version as _version_str

__version__ = "0.0.1a2"
__version__ = _version_str
2 changes: 2 additions & 0 deletions src/cholupdates/rank_1/_seeger_impl_cython.pyx
Original file line number Diff line number Diff line change
@@ -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]_.
Expand Down

0 comments on commit 9a01ea7

Please sign in to comment.