Skip to content

Commit 84b18e3

Browse files
authored
Update template (#19)
1 parent 9d0cd14 commit 84b18e3

File tree

7 files changed

+239
-89
lines changed

7 files changed

+239
-89
lines changed

.coveragerc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[run]
2+
branch = True
3+
omit =
4+
*/_version.py

.github/workflows/pythonpackage.yml

Lines changed: 79 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#This workflow will install Python dependencies, run tests and lint with a variety of Python versions
22
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
33

4+
# For deployment, it will be necessary to create a PyPI API token and store it as a secret
5+
# https://docs.github.com/en/actions/reference/encrypted-secrets
6+
47
name: Python package
58

69
# Set once
@@ -10,18 +13,21 @@ env:
1013
on:
1114
push:
1215
branches: [ master ]
16+
tags: [ '*' ]
1317
pull_request:
1418
branches: [ master ]
1519

20+
1621
jobs:
17-
build:
22+
devcheck:
1823
runs-on: ubuntu-latest
1924
strategy:
2025
matrix:
21-
python-version: [3.7, 3.8, 3.9]
26+
python-version: [3.7, 3.9] # Check oldest and newest versions
27+
pip-flags: ['', '--editable']
2228
pydra:
23-
# - 'pydra'
24-
- 'git+https://github.com/nipype/pydra.git#egg=pydra'
29+
- 'pydra'
30+
- '--editable git+https://github.com/nipype/pydra.git#egg=pydra'
2531

2632
steps:
2733
- uses: actions/checkout@v2
@@ -38,9 +44,76 @@ jobs:
3844
python -c "import pydra as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')"
3945
- name: Install task package
4046
run: |
41-
pip install ".[dev]"
47+
pip install ${{ matrix.pip-flags }} ".[dev]"
48+
python -c "import pydra.tasks.$SUBPACKAGE as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')"
49+
python -c "import pydra as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')"
50+
51+
test:
52+
runs-on: ubuntu-latest
53+
strategy:
54+
matrix:
55+
python-version: [3.7, 3.8, 3.9]
56+
57+
steps:
58+
- uses: actions/checkout@v2
59+
- name: Set up Python ${{ matrix.python-version }}
60+
uses: actions/setup-python@v2
61+
with:
62+
python-version: ${{ matrix.python-version }}
63+
- name: Install build dependencies
64+
run: |
65+
python -m pip install --upgrade pip
66+
- name: Install task package
67+
run: |
68+
pip install ".[test]"
4269
python -c "import pydra.tasks.$SUBPACKAGE as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')"
4370
python -c "import pydra as m; print(f'{m.__name__} {m.__version__} @ {m.__file__}')"
4471
- name: Test with pytest
4572
run: |
46-
pytest -sv --doctest-modules pydra/tasks/$SUBPACKAGE
73+
pytest -sv --doctest-modules pydra/tasks/$SUBPACKAGE \
74+
--cov pydra.tasks.$SUBPACKAGE --cov-report xml
75+
- uses: codecov/codecov-action@v1
76+
if: ${{ always() }}
77+
78+
79+
deploy:
80+
needs: [devcheck, test]
81+
runs-on: ubuntu-latest
82+
strategy:
83+
matrix:
84+
python-version: [3.9]
85+
steps:
86+
- uses: actions/checkout@v2
87+
with:
88+
submodules: recursive
89+
fetch-depth: 0
90+
- name: Set up Python ${{ matrix.python-version }}
91+
uses: actions/setup-python@v2
92+
with:
93+
python-version: ${{ matrix.python-version }}
94+
- name: Install build tools
95+
run: python -m pip install --upgrade pip setuptools wheel twine
96+
- name: Build source and wheel distributions
97+
run: python setup.py sdist bdist_wheel
98+
- name: Check distributions
99+
run: twine check dist/*
100+
- uses: actions/upload-artifact@v2
101+
with:
102+
name: distributions
103+
path: dist/
104+
# Deploy on tags if PYPI_API_TOKEN is defined in the repository secrets.
105+
# Secrets are not accessible in the if: condition [0], so set an output variable [1]
106+
# [0] https://github.community/t/16928
107+
# [1] https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-output-parameter
108+
- name: Check for PyPI token on tag
109+
id: deployable
110+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
111+
env:
112+
PYPI_API_TOKEN: "${{ secrets.PYPI_API_TOKEN }}"
113+
run: if [ -n "$PYPI_API_TOKEN" ]; then echo ::set-output name=DEPLOY::true; fi
114+
- name: Upload to PyPI
115+
if: steps.deployable.outputs.DEPLOY
116+
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 # v1.4.2
117+
with:
118+
user: __token__
119+
password: ${{ secrets.PYPI_API_TOKEN }}

codecov.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
coverage:
2+
range: "50...100"
3+
ignore: # files and folders that will be removed during processing
4+
- "**/tests"
5+
- "**/_version.py"
6+
- "setup.py"
7+
- "versioneer.py"
8+
status:
9+
project:
10+
default:
11+
threshold: 1
12+
patch:
13+
default:
14+
target: 80

pydra/tasks/fsl/_version.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# that just contains the computed version number.
77

88
# This file is released into the public domain. Generated by
9-
# versioneer-0.18 (https://github.com/warner/python-versioneer)
9+
# versioneer-0.19 (https://github.com/python-versioneer/python-versioneer)
1010

1111
"""Git implementation of _version.py."""
1212

@@ -57,7 +57,7 @@ class NotThisMethod(Exception):
5757

5858

5959
def register_vcs_handler(vcs, method): # decorator
60-
"""Decorator to mark a method as the handler for a particular VCS."""
60+
"""Create decorator to mark a method as the handler of a VCS."""
6161
def decorate(f):
6262
"""Store f in HANDLERS[vcs][method]."""
6363
if vcs not in HANDLERS:
@@ -93,9 +93,7 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False,
9393
if verbose:
9494
print("unable to find command, tried %s" % (commands,))
9595
return None, None
96-
stdout = p.communicate()[0].strip()
97-
if sys.version_info[0] >= 3:
98-
stdout = stdout.decode()
96+
stdout = p.communicate()[0].strip().decode()
9997
if p.returncode != 0:
10098
if verbose:
10199
print("unable to run %s (error)" % dispcmd)
@@ -165,6 +163,10 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose):
165163
raise NotThisMethod("no keywords at all, weird")
166164
date = keywords.get("date")
167165
if date is not None:
166+
# Use only the last line. Previous lines may contain GPG signature
167+
# information.
168+
date = date.splitlines()[-1]
169+
168170
# git-2.2.0 added "%cI", which expands to an ISO-8601 -compliant
169171
# datestamp. However we prefer "%ci" (which expands to an "ISO-8601
170172
# -like" string, which we must then edit to make compliant), because
@@ -300,6 +302,9 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
300302
# commit date: see ISO-8601 comment in git_versions_from_keywords()
301303
date = run_command(GITS, ["show", "-s", "--format=%ci", "HEAD"],
302304
cwd=root)[0].strip()
305+
# Use only the last line. Previous lines may contain GPG signature
306+
# information.
307+
date = date.splitlines()[-1]
303308
pieces["date"] = date.strip().replace(" ", "T", 1).replace(" ", "", 1)
304309

305310
return pieces
@@ -338,18 +343,18 @@ def render_pep440(pieces):
338343

339344

340345
def render_pep440_pre(pieces):
341-
"""TAG[.post.devDISTANCE] -- No -dirty.
346+
"""TAG[.post0.devDISTANCE] -- No -dirty.
342347
343348
Exceptions:
344-
1: no tags. 0.post.devDISTANCE
349+
1: no tags. 0.post0.devDISTANCE
345350
"""
346351
if pieces["closest-tag"]:
347352
rendered = pieces["closest-tag"]
348353
if pieces["distance"]:
349-
rendered += ".post.dev%d" % pieces["distance"]
354+
rendered += ".post0.dev%d" % pieces["distance"]
350355
else:
351356
# exception #1
352-
rendered = "0.post.dev%d" % pieces["distance"]
357+
rendered = "0.post0.dev%d" % pieces["distance"]
353358
return rendered
354359

355360

@@ -385,7 +390,7 @@ def render_pep440_old(pieces):
385390
386391
The ".dev0" means dirty.
387392
388-
Eexceptions:
393+
Exceptions:
389394
1: no tags. 0.postDISTANCE[.dev0]
390395
"""
391396
if pieces["closest-tag"]:

setup.cfg

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,30 @@ subpackage = fsl
55
author = Nipype Developers
66
author_email = [email protected]
77
description = FSL tasks for the Pydra dataflow engine
8+
long_description = file:README.md
9+
long_description_content_type = text/markdown; variant=CommonMark
10+
license = Apache License, 2.0
11+
classifiers =
12+
Development Status :: 3 - Alpha
13+
Environment :: Console
14+
Intended Audience :: Science/Research
15+
License :: OSI Approved :: Apache Software License
16+
Operating System :: POSIX :: Linux
17+
Programming Language :: Python :: 3.7
18+
Programming Language :: Python :: 3.8
19+
Programming Language :: Python :: 3.9
20+
Topic :: Scientific/Engineering
821

922
[options]
1023
python_requires = >=3.7
1124
install_requires =
1225
pydra >= 0.14.1
26+
packages = find_namespace:
27+
28+
[options.packages.find]
29+
include =
30+
pydra.tasks.%(subpackage)s
31+
pydra.tasks.%(subpackage)s.*
1332

1433
[options.extras_require]
1534
doc =
@@ -24,14 +43,18 @@ docs =
2443
test =
2544
pytest >= 4.4.0
2645
pytest-cov
46+
pytest-env
47+
pytest-xdist
48+
pytest-rerunfailures
2749
codecov
2850
tests =
2951
%(test)s
3052
dev =
3153
%(test)s
3254
nipype
33-
black
3455
pyyaml
56+
black
57+
pre-commit
3558
all =
3659
%(doc)s
3760
%(dev)s

setup.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88

99
# Give setuptools a hint to complain if it's too old a version
1010
# 30.3.0 allows us to put most metadata in setup.cfg
11+
# 40.1.0 enables the `find_namespace:` directive
1112
# Should match pyproject.toml
12-
SETUP_REQUIRES = ["setuptools >= 30.3.0"]
13+
SETUP_REQUIRES = ["setuptools >= 40.1.0"]
1314
# This enables setuptools to install wheel on-the-fly
1415
SETUP_REQUIRES += ["wheel"] if "bdist_wheel" in sys.argv else []
1516

@@ -19,7 +20,4 @@
1920
setup_requires=SETUP_REQUIRES,
2021
version=versioneer.get_version(),
2122
cmdclass=versioneer.get_cmdclass(),
22-
packages=find_namespace_packages(
23-
include=(f"pydra.tasks.{SUBPACKAGE}", f"pydra.tasks.{SUBPACKAGE}.*")
24-
),
2523
)

0 commit comments

Comments
 (0)