Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 53 additions & 16 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ on:
- 'v[0-9]+.[0-9]+.[0-9]+'

jobs:
deploy-job:
build_locally:
name: Build locally
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v4
with:
Expand All @@ -19,19 +20,55 @@ jobs:
run: |
python -m pip install twine build
python -m pip install -e .
- name: Build package
- name: Build package locally
run: |
python -m build --sdist --wheel
python -m build
python -m twine check dist/*
- name: Upload package to TestPyPI
run: |
python -m twine upload -r testpypi dist/* --verbose
env:
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME_TEST }}
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD_TEST }}
- name: Upload package to PyPI
run: |
python -m twine upload -r pypi dist/* --verbose
env:
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}

build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-13, macos-14]
steps:
- uses: actions/checkout@v4
- name: Build wheels
uses: pypa/cibuildwheel@v2.19.2
- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Build sdist
run: pipx run build --sdist

- uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: dist/*.tar.gz

upload_pypi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
# unpacks all CIBW artifacts into dist/
pattern: cibw-*
path: dist
merge-multiple: true

- uses: pypa/gh-action-pypi-publish@release/v1
with:
# To test:
repository-url: https://test.pypi.org/legacy/
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@ keywords = ["tda", "mapper", "topology", "topological data analysis"]
dependencies = [
"matplotlib>=3.3.4",
"networkx>=2.5",
"numpy>=1.20.1",
"numpy>=1.20.1, <2.0.0",
"plotly>=4.14.3"
]
requires-python = ">=3.6"

[project.optional-dependencies]
dev = ["coverage", "pandas", "scikit-learn"]

[tool.setuptools.package-data]
"tdamapper.utils" = ["_metrics.c", "_metrics.pyx"]

[project.urls]
Homepage = "https://github.com/lucasimi/tda-mapper-python"
Documentation = "https://tda-mapper.readthedocs.io"
Expand Down
16 changes: 10 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
from Cython.Build import cythonize


ext_modules = [
Extension(
name='tdamapper.utils._metrics',
sources=[
'src/tdamapper/utils/_metrics.pyx',
],
),
]

setup(
ext_modules=cythonize([
Extension(
name="tdamapper.utils._metrics",
sources=["src/tdamapper/utils/_metrics.pyx"],
),
])
ext_modules=cythonize(ext_modules),
)
2 changes: 1 addition & 1 deletion src/tdamapper/utils/_metrics.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ cpdef inline double euclidean(double[:] x, double[:] y) nogil:
return sqrt(norm_squared)


cdef inline double minkowski(int p, double[:] x, double[:] y) nogil:
cpdef inline double minkowski(int p, double[:] x, double[:] y) nogil:
cdef double norm_p = 0.0
cdef Py_ssize_t i, n = x.shape[0]
for i in range(n):
Expand Down