Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate deepseg_gm_models to pip #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
24 changes: 24 additions & 0 deletions .github/workflows/build.yml
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
44 changes: 44 additions & 0 deletions .github/workflows/release.yml
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/
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dist/
build/

*.whl
*.egg-info
__pycache__
3 changes: 3 additions & 0 deletions pyproject.toml
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"]
44 changes: 44 additions & 0 deletions setup.py
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-deepseg_gm_models',
description='Part of https://github.com/neuropoly/spinalcordtoolbox',
long_description=(here / 'README.txt').read_text(encoding='utf-8'),
long_description_content_type='text/plain',
author='Neuropoly',
author_email='[email protected]',
url='https://spinalcordtoolbox.com/',
project_urls={
'Source': 'https://github.com/sct-data/deepseg_gm_models',
#'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
)

2 changes: 2 additions & 0 deletions src/spinalcordtoolbox/data/deepseg/gm/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# empty __init__.py to enable importlib.resources
# see < TODO >
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.