Skip to content

Commit

Permalink
use setuptools instead of pdm for package build (#26)
Browse files Browse the repository at this point in the history
* remove pdm and tox and adapt pyproject.toml

* clean up build process

* work on package build

* renew build workflow

* add package install

* run tests only on python 3.9 and 3.11

* test with two tf versions

* add new publish to pypi workflow

---------

Co-authored-by: Georg Schramm <georg@Georgs-MacBook-Pro-9.local>
  • Loading branch information
gschramm and Georg Schramm authored Jan 21, 2025
1 parent 912a338 commit eddc106
Show file tree
Hide file tree
Showing 11 changed files with 129 additions and 1,716 deletions.
71 changes: 45 additions & 26 deletions .github/workflows/build_python.yaml
Original file line number Diff line number Diff line change
@@ -1,43 +1,62 @@
# Workflow to build the parallelproj C/CUDA libs (incl. installation of CUDA)
name: python build
name: Build and Test

on:
push:
branches: [ "master" ]
branches:
- master
pull_request:
branches: [ "master" ]

jobs:
Testing:
runs-on: ${{ matrix.os }}
build-and-test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9','3.10']
os: [ubuntu-latest]
python-version: [3.9, 3.11]
tensorflow-version: [2.13, 2.15]

steps:
- uses: actions/checkout@v4
# Checkout the repository
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0 # default 1 is, which doesnt allow to get all tags which we need for version from scm
fetch-tags: true
- name: Set up PDM
uses: pdm-project/setup-pdm@v4
fetch-depth: 0 # Fetch all history to ensure tags are available

# Set up Python
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Show package version
# Install dependencies
- name: Install dependencies
run: |
git describe --tags
pdm show --version
- name: Install dependencies and package
python -m pip install --upgrade pip
pip install build
# Build the package
- name: Build the package
run: |
pdm update -d -G test
pdm list
- name: Test CLI
python -m build
# Install tensorflow
- name: Install tensorflow
run: |
pdm run pyapetnet_list_models
pdm run pyapetnet_predict_from_nifti -h
pdm run pyapetnet_predict_from_dicom -h
- name: Run Tests
pip install tensorflow==${{ matrix.tensorflow-version }}
# Install the package
- name: Install the package
run: |
pip install dist/*.whl
# Run tests
- name: Run tests
run: |
pip install pytest
pytest -vv tests
# Test entry points
- name: Test entry points
run: |
pdm run tox
pyapetnet_list_models
pyapetnet_predict_from_nifti -h
pyapetnet_predict_from_dicom -h
41 changes: 41 additions & 0 deletions .github/workflows/publish-to-pypi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Publish Python distributions to PyPI

on:
push:
tags:
- "v[0-9]+"
- "v[0-9]+.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+"
- "v[0-9]+[a-z][0-9]+"
- "v[0-9]+.[0-9]+[a-z][0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+[a-z][0-9]+"

jobs:
build-n-publish:
name: Build and publish Python distributions package to PyPI
runs-on: ubuntu-latest

permissions:
id-token: write
contents: read

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history to ensure tags are available
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Install pypa/build
run: |
python -m pip install build --user
- name: Build a binary wheel and a source tarball
run: |
python -m build --sdist --wheel --outdir dist/ .
- name: Publish distribution package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
34 changes: 0 additions & 34 deletions .github/workflows/publish_pypi.yaml

This file was deleted.

34 changes: 0 additions & 34 deletions .github/workflows/publish_test_pypi.yaml

This file was deleted.

24 changes: 24 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Include necessary metadata files
include LICENSE
include README.md
include pyproject.toml

# Include only the package files
graft src/pyapetnet

# Include trained models
recursive-include src/pyapetnet/trained_models

# Exclude unwanted directories
prune .git
prune .github
prune binder
prune demo_data
prune demos
prune figures
prune notebooks
prune scripts
prune tests

# Exclude unwanted files
global-exclude *.pyc *.pyo __pycache__
Loading

0 comments on commit eddc106

Please sign in to comment.