Skip to content

Commit 43edfbb

Browse files
authored
Merge pull request #88 from skoudoro/project-update
RF: large packaging update
2 parents 30dd0f4 + 79966be commit 43edfbb

45 files changed

Lines changed: 4262 additions & 2077 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.flake8

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[flake8]
2+
max-line-length = 88
3+
max-complexity = 10
4+
exclude =
5+
.git,
6+
__pycache__,
7+
.tox,
8+
.eggs,
9+
*.egg,
10+
build,
11+
dist

.github/workflows/codeformat.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Code Format
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
pre-commit:
14+
name: Pre-commit checks
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Check out repository
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: "3.12"
25+
26+
- name: Install and run pre-commit hooks
27+
uses: pre-commit/action@v3.0.1

.github/workflows/coverage.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Coverage
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
coverage:
14+
name: Code Coverage
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Check out repository
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Set up Python
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: "3.12"
27+
cache: pip
28+
cache-dependency-path: pyproject.toml
29+
30+
- name: Install dependencies
31+
run: |
32+
python -m pip install --upgrade pip
33+
python -m pip install -e .[test]
34+
35+
- name: Run tests with coverage
36+
run: |
37+
pytest trx/tests --cov=trx --cov-report=xml --cov-report=term-missing
38+
39+
- name: Upload coverage to Codecov
40+
uses: codecov/codecov-action@v4
41+
with:
42+
files: ./coverage.xml
43+
flags: unittests
44+
name: codecov-trx
45+
fail_ci_if_error: false
46+
verbose: true
47+
env:
48+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/docbuild.yml

Lines changed: 81 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@ jobs:
1717
strategy:
1818
fail-fast: false
1919
matrix:
20-
python-version: ["3.9"]
20+
python-version: ["3.13"]
2121

2222
steps:
23-
- uses: actions/checkout@v2
23+
- uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0 # Fetch all history and tags for setuptools_scm
2426
- name: Set up Python ${{ matrix.python-version }}
25-
uses: actions/setup-python@v2
27+
uses: actions/setup-python@v5
2628
with:
2729
python-version: ${{ matrix.python-version }}
2830
- name: Install
@@ -35,13 +37,86 @@ jobs:
3537
cd docs
3638
make html
3739
- name: Upload docs
38-
uses: actions/upload-artifact@v1
40+
uses: actions/upload-artifact@v4
41+
with:
42+
name: docs
43+
path: docs/_build/html
44+
45+
deploy-dev:
46+
needs: build
47+
runs-on: ubuntu-latest
48+
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository == 'tee-ar-ex/trx-python'
49+
steps:
50+
- uses: actions/checkout@v4
51+
- uses: actions/download-artifact@v4
52+
with:
53+
name: docs
54+
path: docs/_build/html
55+
- name: Publish dev docs to Github Pages
56+
uses: JamesIves/github-pages-deploy-action@v4
57+
with:
58+
branch: gh-pages
59+
folder: docs/_build/html
60+
target-folder: dev
61+
62+
deploy-release:
63+
needs: build
64+
runs-on: ubuntu-latest
65+
if: startsWith(github.ref, 'refs/tags/') && github.repository == 'tee-ar-ex/trx-python'
66+
steps:
67+
- uses: actions/checkout@v4
68+
- uses: actions/download-artifact@v4
3969
with:
4070
name: docs
4171
path: docs/_build/html
42-
- name: Publish docs to Github Pages
43-
if: startsWith(github.event.ref, 'refs/tags')
72+
- name: Get version from tag
73+
id: get_version
74+
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
75+
- name: Fetch existing switcher.json from gh-pages
76+
run: |
77+
curl -sSL https://tee-ar-ex.github.io/trx-python/switcher.json -o switcher.json || echo '[]' > switcher.json
78+
- name: Update switcher.json with new version
79+
run: python tools/update_switcher.py switcher.json --version ${{ steps.get_version.outputs.VERSION }}
80+
- name: Create root files (redirect + switcher.json)
81+
run: |
82+
mkdir -p root_files
83+
cp switcher.json root_files/
84+
cat > root_files/index.html << 'EOF'
85+
<!DOCTYPE html>
86+
<html lang="en">
87+
<head>
88+
<meta charset="utf-8">
89+
<meta name="viewport" content="width=device-width, initial-scale=1">
90+
<title>trx-python - TRX File Format for Tractography</title>
91+
<meta name="description" content="trx-python is a Python implementation of the TRX file format for tractography data, designed for efficient handling of brain fiber tract streamlines.">
92+
<meta name="robots" content="index, follow">
93+
<link rel="canonical" href="https://tee-ar-ex.github.io/trx-python/stable/">
94+
<meta http-equiv="refresh" content="0; URL=https://tee-ar-ex.github.io/trx-python/stable/">
95+
<script>window.location.replace("https://tee-ar-ex.github.io/trx-python/stable/");</script>
96+
</head>
97+
<body>
98+
<h1>trx-python Documentation</h1>
99+
<p>Python implementation of the TRX file format for tractography data.</p>
100+
<p>If you are not redirected automatically, visit the <a href="https://tee-ar-ex.github.io/trx-python/stable/">stable documentation</a>.</p>
101+
</body>
102+
</html>
103+
EOF
104+
- name: Publish root files (redirect + switcher.json)
105+
uses: JamesIves/github-pages-deploy-action@v4
106+
with:
107+
branch: gh-pages
108+
folder: root_files
109+
target-folder: .
110+
clean: false
111+
- name: Publish release docs to Github Pages
112+
uses: JamesIves/github-pages-deploy-action@v4
113+
with:
114+
branch: gh-pages
115+
folder: docs/_build/html
116+
target-folder: ${{ steps.get_version.outputs.VERSION }}
117+
- name: Publish stable docs to Github Pages
44118
uses: JamesIves/github-pages-deploy-action@v4
45119
with:
46120
branch: gh-pages
47121
folder: docs/_build/html
122+
target-folder: stable
Lines changed: 81 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,95 @@
11
name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI
22

3-
on: push
3+
on:
4+
push:
5+
branches:
6+
- master
7+
tags:
8+
- '*'
9+
410
jobs:
5-
build-n-publish:
6-
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
11+
build:
12+
name: Build distribution 📦
713
runs-on: ubuntu-latest
14+
if: github.repository == 'tee-ar-ex/trx-python'
815
steps:
9-
- uses: actions/checkout@master
10-
- name: Set up Python 3.9
11-
uses: actions/setup-python@v1
16+
- uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0 # Fetch all history and tags for setuptools_scm
19+
- name: Set up Python 3.11
20+
uses: actions/setup-python@v5
1221
with:
13-
python-version: 3.9
22+
python-version: "3.11"
1423
- name: Install pypa/build
15-
run: >-
16-
python -m
17-
pip install
18-
build
19-
--user
24+
run: python -m pip install build --user
2025
- name: Build a binary wheel and a source tarball
21-
run: >-
22-
python -m
23-
build
24-
--sdist
25-
--wheel
26-
--outdir dist/
27-
.
26+
run: python -m build --sdist --wheel --outdir dist/ .
27+
- name: Upload distribution artifacts
28+
uses: actions/upload-artifact@v4
29+
with:
30+
name: python-package-distributions
31+
path: dist/
32+
33+
publish-to-testpypi:
34+
name: Publish to TestPyPI
35+
needs: build
36+
runs-on: ubuntu-latest
37+
environment:
38+
name: testpypi
39+
url: https://test.pypi.org/p/trx-python
40+
permissions:
41+
id-token: write
42+
steps:
43+
- name: Download distribution artifacts
44+
uses: actions/download-artifact@v4
45+
with:
46+
name: python-package-distributions
47+
path: dist/
2848
- name: Publish distribution 📦 to Test PyPI
2949
uses: pypa/gh-action-pypi-publish@release/v1
3050
with:
31-
user: __token__
32-
password: ${{ secrets.test_pypi_password }}
33-
repository_url: https://test.pypi.org/legacy/
51+
repository-url: https://test.pypi.org/legacy/
52+
53+
publish-to-pypi:
54+
name: Publish to PyPI
55+
needs: build
56+
runs-on: ubuntu-latest
57+
if: startsWith(github.ref, 'refs/tags/')
58+
environment:
59+
name: pypi
60+
url: https://pypi.org/p/trx-python
61+
permissions:
62+
id-token: write
63+
steps:
64+
- name: Download distribution artifacts
65+
uses: actions/download-artifact@v4
66+
with:
67+
name: python-package-distributions
68+
path: dist/
3469
- name: Publish distribution 📦 to PyPI
35-
if: startsWith(github.event.ref, 'refs/tags')
3670
uses: pypa/gh-action-pypi-publish@release/v1
71+
72+
github-release:
73+
name: Create GitHub Release
74+
needs: publish-to-pypi
75+
runs-on: ubuntu-latest
76+
permissions:
77+
contents: write
78+
steps:
79+
- uses: actions/checkout@v4
80+
- name: Download distribution artifacts
81+
uses: actions/download-artifact@v4
3782
with:
38-
user: __token__
39-
password: ${{ secrets.pypi_password }}
83+
name: python-package-distributions
84+
path: dist/
85+
- name: Get version from tag
86+
id: get_version
87+
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
88+
- name: Create GitHub Release
89+
env:
90+
GH_TOKEN: ${{ github.token }}
91+
run: |
92+
gh release create "${{ steps.get_version.outputs.VERSION }}" \
93+
--title "Release ${{ steps.get_version.outputs.VERSION }}" \
94+
--generate-notes \
95+
dist/*

.github/workflows/python-package.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
test:
14+
name: Python ${{ matrix.python-version }} • ${{ matrix.os }}
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
python-version: ["3.11", "3.12", "3.13"]
20+
os: [ubuntu-latest, windows-latest, macos-latest]
21+
steps:
22+
- uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0 # needed for setuptools_scm version detection
25+
26+
- name: Set up Python ${{ matrix.python-version }}
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: ${{ matrix.python-version }}
30+
cache: pip
31+
cache-dependency-path: pyproject.toml
32+
33+
- name: Install dependencies
34+
run: |
35+
python -m pip install --upgrade pip
36+
python -m pip install -e .[dev,test]
37+
38+
- name: Test
39+
run: spin test

0 commit comments

Comments
 (0)