-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Template for packaging spinalcordtoolbox datasets in pip.
- Loading branch information
Showing
7 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Test the Build | ||
|
||
on: | ||
# test on PRs and double-test on merges to master, or manually. | ||
pull_request: | ||
push: | ||
branches: | ||
- master | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python | ||
uses: actions/setup-python@v1 | ||
- name: Build tools | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install build | ||
- name: Build | ||
run: | | ||
python -m build --wheel --sdist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: Publish | ||
|
||
on: | ||
# publish from the Releases page: | ||
release: | ||
types: [published] | ||
# publish from the Actions page: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'Version (e.g. 2.0.3)' | ||
required: true | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python | ||
uses: actions/setup-python@v1 | ||
- name: Build tools | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install build | ||
- name: Build | ||
run: | | ||
python -m build --wheel --sdist | ||
### TODO: can the uploads be parallelized? | ||
- name: Publish to Github | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: 'dist/*' | ||
fail_on_unmatched_files: true | ||
tag_name: ${{ github.event.inputs.version }} # in the workflow_dispatch case, make a new tag from the given input; in the published release case, this will be empty and will fall back to updating that release. | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Publish to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
user: __token__ | ||
#password: ${{ secrets.PYPI_PASSWORD }} | ||
# DEBUG: | ||
password: ${{ secrets.TEST_PYPI_API_TOKEN }} | ||
repository_url: https://test.pypi.org/legacy/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
dist/ | ||
build/ | ||
|
||
*.whl | ||
*.egg-info | ||
__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# PAM50 | ||
|
||
PAM50 template. For more details see [De Leener et al. Neuroimage 2018](https://pubmed.ncbi.nlm.nih.gov/29061527/) | ||
|
||
Part of [`spinalcordtoolbox`](https://github.com/neuropoly/spinalcordtoolbox). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# this ensures builds are done reliably | ||
[build-system] | ||
requires = ["setuptools>=40.8.0", "setuptools_scm[toml]", "wheel"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from setuptools import setup, find_packages, find_namespace_packages | ||
import pathlib | ||
|
||
here = pathlib.Path(__file__).parent.resolve() | ||
|
||
# workaround a bug introduced by pyproject.toml | ||
# https://github.com/pypa/pip/issues/7953#issuecomment-645133255 | ||
import site, sys; site.ENABLE_USER_SITE = True | ||
|
||
setup( | ||
name='spinalcordtoolbox-data-<dataset>', | ||
description='Part of https://github.com/neuropoly/spinalcordtoolbox', | ||
long_description=(here / 'README.md').read_text(encoding='utf-8'), | ||
long_description_content_type='text/markdown', | ||
author='Neuropoly', | ||
author_email='[email protected]', | ||
url='https://spinalcordtoolbox.com/', | ||
project_urls={ | ||
'Source': 'https://github.com/sct-data/<dataset>', | ||
#'Documentation': '', | ||
}, | ||
#license='CC-BY-NC', ?? | ||
#license_files=[ ... ] # TODO? | ||
|
||
packages=find_namespace_packages('src/'), | ||
package_dir={"":"src/"}, | ||
|
||
# with setuptools_scm, means it includes non-python files if they're under git | ||
include_package_data=True, | ||
|
||
# with setuptools_scm, get the version out of the most recent git tag. | ||
# the tags must be formatted as semver. | ||
use_scm_version=True, | ||
|
||
# pyproject.toml::build-system.requires is supposed to supersede this, but it's still very new so we duplicate it. | ||
setup_requires=[ | ||
'setuptools', | ||
'setuptools_scm[toml]', | ||
'wheel', | ||
], | ||
|
||
zip_safe=False, # guarantees that importlib.resources.path() is safe | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# empty __init__.py to enable importlib.resources | ||
# see < TODO > |