Skip to content

Commit 0d24f1f

Browse files
committed
chore: install setuptools_scm and update files
1 parent 7aa56ee commit 0d24f1f

File tree

13 files changed

+165
-155
lines changed

13 files changed

+165
-155
lines changed

.circleci/config.yml

Lines changed: 67 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ jobs:
7474
tfapi.get('MNI152NLin2009cAsym', resolution=2, desc='fMRIPrep', suffix='boldref');"
7575
7676
- save_cache:
77-
key: env-v2-{{ .Branch }}-{{ .BuildNum }}
78-
paths:
77+
key: env-v2-{{ .Branch }}-{{ .BuildNum }}
78+
paths:
7979
- /tmp/cache/git-annex-standalone.tar.gz
8080
- /usr/local/bin
8181
- /usr/local/lib/python3.7/site-packages
@@ -98,8 +98,8 @@ jobs:
9898
unzip testdata.zip -d /tmp/data/testdata
9999
fi
100100
- save_cache:
101-
key: data-v2-{{ .Branch }}-{{ .BuildNum }}
102-
paths:
101+
key: data-v2-{{ .Branch }}-{{ .BuildNum }}
102+
paths:
103103
- /tmp/data
104104
- /tmp/templateflow
105105

@@ -136,13 +136,13 @@ jobs:
136136
circleci step halt
137137
fi
138138
- save_cache:
139-
key: freesurfer-v1-{{ .BuildNum }}
140-
paths:
139+
key: freesurfer-v1-{{ .BuildNum }}
140+
paths:
141141
- /tmp/freesurfer
142142

143143
build_n_pytest:
144144
machine:
145-
image: circleci/classic:201711-01
145+
image: circleci/classic:201808-01
146146
working_directory: /tmp/tests
147147
environment:
148148
TZ: "/usr/share/zoneinfo/America/Los_Angeles"
@@ -187,11 +187,11 @@ jobs:
187187
no_output_timeout: 60m
188188
command: |
189189
cd /tmp/src/sdcflows
190-
export PY3=$(pyenv versions | grep '3\.' |
191-
sed -e 's/.* 3\./3./' -e 's/ .*//')
192-
pyenv local $PY3
190+
pyenv local 3.7.0
191+
python3 -m pip install "setuptools ~= 42.0" "setuptools_scm[toml] >= 3.4" "pip>=10.0.1"
192+
193193
# Get version, update files.
194-
THISVERSION=$( python3 get_version.py )
194+
THISVERSION=$( python3 setup.py --version )
195195
if [[ ${THISVERSION:0:1} == "0" ]] ; then
196196
echo "WARNING: latest git tag could not be found"
197197
echo "Please, make sure you fetch all tags from upstream with"
@@ -208,6 +208,7 @@ jobs:
208208
--build-arg VERSION="${CIRCLE_TAG:-$THISVERSION}" . \
209209
&& e=0 && break || sleep 15
210210
done && [ "$e" -eq "0" ]
211+
echo "${CIRCLE_TAG:-$THISVERSION}" >> /tmp/.local-version.txt
211212
- run:
212213
name: Docker push to local registry
213214
no_output_timeout: 40m
@@ -220,9 +221,19 @@ jobs:
220221
docker exec -it registry /bin/registry garbage-collect --delete-untagged \
221222
/etc/docker/registry/config.yml
222223
- save_cache:
223-
key: build-v2-{{ .Branch }}-{{ epoch }}
224-
paths:
224+
key: build-v2-{{ .Branch }}-{{ epoch }}
225+
paths:
225226
- /tmp/docker
227+
- run:
228+
name: Check version packaged in Docker image
229+
command: |
230+
docker run --rm -v /tmp:/tmp -v /tmp/src/sdcflows/.circleci/version.py:/usr/share/version.py \
231+
--entrypoint=python nipreps/sdcflows /usr/share/version.py
232+
THISVERSION=$( head -n1 /tmp/.local-version.txt )
233+
INSTALLED_VERSION=$( head -n1 /tmp/.docker-version.txt )
234+
echo "VERSION: \"${THISVERSION}\""
235+
echo "INSTALLED: \"${INSTALLED_VERSION}\""
236+
test "${INSTALLED_VERSION}" = "${THISVERSION}"
226237
227238
- restore_cache:
228239
keys:
@@ -274,11 +285,11 @@ jobs:
274285
-v /tmp/work:/work -e TEST_WORK_DIR=/work \
275286
-v /tmp/templateflow:/home/sdcflows/.cache/templateflow \
276287
-v /tmp/data:/data:ro -v /tmp/src:/src -v /tmp/tests:/out \
277-
-w /work nipreps/sdcflows:latest \
278-
pytest -v --junit-xml=/out/pytest.xml /src/sdcflows/sdcflows
288+
-w /src/sdcflows nipreps/sdcflows:latest \
289+
pytest -v --junit-xml=/out/pytest.xml sdcflows/
279290
- save_cache:
280-
key: workdir-v2-{{ .Branch }}-{{ .BuildNum }}
281-
paths:
291+
key: workdir-v2-{{ .Branch }}-{{ .BuildNum }}
292+
paths:
282293
- /tmp/work
283294
- store_artifacts:
284295
path: /tmp/tests
@@ -302,7 +313,10 @@ jobs:
302313
command: apt update && apt -y install graphviz
303314
- run:
304315
name: Install deps
305-
command: pip install --no-cache-dir -r docs/requirements.txt
316+
command: |
317+
pip install --no-cache-dir -r docs/requirements.txt
318+
pip install --no-cache-dir "setuptools ~= 42.0" "setuptools_scm[toml] >= 3.4"
319+
python setup.py --version
306320
- run:
307321
name: Build only this commit
308322
command: make -C docs SPHINXOPTS="-W" BUILDDIR="_build/no_version_html" html
@@ -380,119 +394,61 @@ jobs:
380394
steps:
381395
- checkout
382396
- run:
383-
name: Setup Python environment with virtualenvs
384-
command: |
385-
python -m pip install --user --upgrade virtualenv pip
386-
- run:
387-
name: Prepare build environment
388-
command: |
389-
virtualenv --python=python3 /tmp/build
390-
source /tmp/build/bin/activate
391-
python3 -m pip install "setuptools>=30.3.0" "pip>=10.0.1" twine docutils
392-
- run:
393-
name: Prepare install environments
397+
name: Prepare environment & build
394398
command: |
395-
virtualenv --python=python3 /tmp/install_sdist
396-
source /tmp/install_sdist/bin/activate
397-
python3 -m pip install "setuptools>=30.3.0" "pip>=10.0.1"
398-
deactivate
399-
virtualenv --python=python3 /tmp/install_wheel
400-
source /tmp/install_wheel/bin/activate
401-
python3 -m pip install "setuptools>=30.3.0" "pip>=10.0.1"
402-
- run:
403-
name: Build SDCflows in build environment
404-
command: |
405-
source /tmp/build/bin/activate
399+
python3 -m venv /tmp/buildenv
400+
source /tmp/buildenv/bin/activate
401+
python3 -m pip install "setuptools ~= 42.0" wheel "setuptools_scm[toml] >= 3.4" \
402+
"pip>=10.0.1" twine docutils
406403
python setup.py sdist bdist_wheel
404+
twine check dist/sdcflows*
407405
- store_artifacts:
408406
path: /tmp/src/sdcflows/dist
407+
- persist_to_workspace:
408+
root: /tmp/src/sdcflows
409+
paths: dist
409410
- run:
410-
name: Check sdist package in build environment
411-
command: |
412-
source /tmp/build/bin/activate
413-
twine check dist/sdcflows*
414-
- run:
415-
name: Install sdist package into install environment and check version
411+
name: Install on separate environment and check version [sdist]
416412
command: |
413+
python3 -m venv /tmp/install_sdist
417414
source /tmp/install_sdist/bin/activate
418-
THISVERSION=$( python get_version.py )
415+
python3 -m pip install "setuptools ~= 42.0" "pip>=10.0.1"
416+
THISVERSION=$( python3 setup.py --version )
419417
THISVERSION=${CIRCLE_TAG:-$THISVERSION}
420-
pip install dist/sdcflows*.tar.gz
421-
which sdcflows | grep install_sdist\\/bin
422-
INSTALLED_VERSION=$(sdcflows --version)
423-
INSTALLED_VERSION=${INSTALLED_VERSION%$'\r'}
424-
INSTALLED_VERSION=${INSTALLED_VERSION#*"sdcflows v"}
425-
echo "VERSION: \"$THISVERSION\""
426-
echo "INSTALLED: \"$INSTALLED_VERSION\""
427-
test "$INSTALLED_VERSION" = "v$THISVERSION"
418+
python3 -m pip install dist/sdcflows*.tar.gz
419+
INSTALLED_VERSION=$(python3 -c 'import sdcflows as sdc; print(sdc.__version__, end="")')
420+
echo "VERSION: \"${THISVERSION}\""
421+
echo "INSTALLED: \"${INSTALLED_VERSION}\""
422+
test "${INSTALLED_VERSION}" = "${THISVERSION}"
428423
- run:
429-
name: Install wheel into install environment and check version
424+
name: Install on separate environment and check version [wheel]
430425
command: |
426+
python3 -m venv /tmp/install_wheel
431427
source /tmp/install_wheel/bin/activate
432-
THISVERSION=$( python get_version.py )
428+
python3 -m pip install "setuptools ~= 42.0" "pip>=10.0.1"
429+
THISVERSION=$( python3 setup.py --version )
433430
THISVERSION=${CIRCLE_TAG:-$THISVERSION}
434-
pip install dist/sdcflows*.whl
435-
which sdcflows | grep install_wheel\\/bin
436-
INSTALLED_VERSION=$(sdcflows --version)
437-
INSTALLED_VERSION=${INSTALLED_VERSION%$'\r'}
438-
INSTALLED_VERSION=${INSTALLED_VERSION#*"sdcflows v"}
439-
echo "VERSION: \"$THISVERSION\""
440-
echo "INSTALLED: \"$INSTALLED_VERSION\""
441-
test "$INSTALLED_VERSION" = "v$THISVERSION"
431+
python3 -m pip install dist/sdcflows*.whl
432+
INSTALLED_VERSION=$(python3 -c 'import sdcflows as sdc; print(sdc.__version__, end="")')
433+
echo "VERSION: \"${THISVERSION}\""
434+
echo "INSTALLED: \"${INSTALLED_VERSION}\""
435+
test "${INSTALLED_VERSION}" = "${THISVERSION}"
442436
443437
deploy_pypi:
444438
docker:
445439
- image: circleci/python:3.7.4
446440
working_directory: /tmp/src/sdcflows
447441
steps:
448-
- checkout
449-
- run:
450-
name: Setup Python environment with virtualenvs
451-
command: |
452-
python -m pip install --user --upgrade virtualenv pip
453-
- run:
454-
name: Prepare build environment
455-
command: |
456-
virtualenv --python=python3 /tmp/build
457-
source /tmp/build/bin/activate
458-
python3 -m pip install "setuptools>=30.3.0" "pip>=10.0.1" twine docutils
459-
- run:
460-
name: Prepare install environments
461-
command: |
462-
virtualenv --python=python3 /tmp/install_sdist
463-
source /tmp/install_sdist/bin/activate
464-
python3 -m pip install "setuptools>=30.3.0" "pip>=10.0.1"
465-
- run:
466-
name: Build SDCflows in build environment
467-
command: |
468-
source /tmp/build/bin/activate
469-
python setup.py sdist bdist_wheel
470-
- store_artifacts:
471-
path: /tmp/src/sdcflows/dist
472-
- run:
473-
name: Check sdist and wheel in build environment
474-
command: |
475-
source /tmp/build/bin/activate
476-
twine check dist/sdcflows*
477-
- run:
478-
name: Install sdist package into install environment and check version
479-
command: |
480-
source /tmp/install_sdist/bin/activate
481-
THISVERSION=$( python get_version.py )
482-
THISVERSION=${CIRCLE_TAG:-$THISVERSION}
483-
pip install dist/sdcflows*.tar.gz
484-
which sdcflows | grep install_sdist\\/bin
485-
INSTALLED_VERSION=$(sdcflows --version)
486-
INSTALLED_VERSION=${INSTALLED_VERSION%$'\r'}
487-
INSTALLED_VERSION=${INSTALLED_VERSION#*"sdcflows v"}
488-
echo "VERSION: \"$THISVERSION\""
489-
echo "INSTALLED: \"$INSTALLED_VERSION\""
490-
test "$INSTALLED_VERSION" = "v$THISVERSION"
442+
- attach_workspace:
443+
at: /tmp/src/sdcflows
491444
- run:
492-
name: Upload packages to PyPI
445+
name: Upload to Pypi
493446
command: |
494-
source /tmp/build/bin/activate
495-
twine upload dist/sdcflows*
447+
python3 -m venv /tmp/upload
448+
source /tmp/upload/bin/activate
449+
python3 -m pip install twine
450+
python3 -m twine check dist/*
451+
python3 -m twine upload dist/* --non-interactive
496452
497453
deploy_docs_tag:
498454
<<: *docs

.circleci/version.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""Get sdcflows version."""
2+
import sdcflows
3+
print(sdcflows.__version__, end="", file=open("/tmp/.docker-version.txt", "w"))

.dockerignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ build/**/*
88
build
99
dist/**/*
1010
dist
11-
fmriprep.egg-info/**/*
12-
fmriprep.egg-info
11+
docs/**/*
12+
docs
13+
sdcflows.egg-info/**/*
14+
sdcflows.egg-info
1315
.eggs/**/*
1416
.eggs
1517

@@ -23,6 +25,7 @@ src/**/*
2325
src/
2426

2527
# git
28+
.gitattributes
2629
.gitignore
2730
.github/**/*
2831
.github

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# setuptools-scm
2+
sdcflows/_version.py
3+
14
# Byte-compiled / optimized / DLL files
25
pip-wheel-metadata
36
__pycache__/

Dockerfile

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,19 @@ ENV PATH="/usr/local/miniconda/bin:$PATH" \
8181

8282
# Installing precomputed python packages
8383
RUN conda install -y python=3.7.1 \
84-
mkl=2018.0.3 \
84+
graphviz=2.40.1 \
85+
libxml2=2.9.8 \
86+
libxslt=1.1.32 \
87+
matplotlib=2.2.2 \
8588
mkl-service \
89+
mkl=2018.0.3 \
8690
numpy=1.15.4 \
87-
scipy=1.1.0 \
88-
scikit-learn=0.19.1 \
89-
matplotlib=2.2.2 \
9091
pandas=0.23.4 \
91-
libxml2=2.9.8 \
92-
libxslt=1.1.32 \
93-
graphviz=2.40.1 \
92+
scikit-learn=0.19.1 \
93+
scipy=1.1.0 \
94+
setuptools=44.0.0 \
95+
setuptools_scm=3.4.3 \
96+
toml=0.10 \
9497
traits=4.6.0 \
9598
zlib; sync && \
9699
chmod -R a+rX /usr/local/miniconda; sync && \
@@ -116,10 +119,12 @@ COPY .docker/files/nipype.cfg $HOME/.nipype/nipype.cfg
116119
# Installing dev requirements (packages that are not in pypi)
117120
WORKDIR /src/sdcflows
118121

119-
# Installing sMRIPREP
122+
# Installing SDCFlows
120123
COPY . /src/sdcflows
121124
# Force static versioning within container
122-
RUN pip install --no-cache-dir .[all] && \
125+
ARG VERSION
126+
RUN sed -i "s/fallback_version\s=\s\"0\.0\"/fallback_version = \"${VERSION}\"/g" pyproject.toml && \
127+
pip install --no-cache-dir .[all] && \
123128
rm -rf $HOME/.cache/pip
124129

125130
RUN find $HOME -type d -exec chmod go=u {} + && \
@@ -132,7 +137,6 @@ WORKDIR /tmp/
132137

133138
ARG BUILD_DATE
134139
ARG VCS_REF
135-
ARG VERSION
136140
LABEL org.label-schema.build-date=$BUILD_DATE \
137141
org.label-schema.name="SDCflows" \
138142
org.label-schema.description="SDCflows - Susceptibility Distortion Correction (SDC) workflows for EPI MR schemes" \

MANIFEST.in

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
include CHANGES.rst
2-
include LICENSE
1+
recursive-exclude .circleci/ *
2+
recursive-exclude .docker/ *
3+
recursive-exclude .github/ *
4+
recursive-exclude docs/ *
35

4-
recursive-include sdcflows/data *
6+
exclude .*
7+
exclude Dockerfile

pyproject.toml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
11
[build-system]
2-
requires = ["setuptools >= 40.8.0", "wheel"]
2+
requires = ["setuptools >= 42.0", "wheel", "setuptools_scm[toml] >= 3.4"]
3+
4+
[tool.setuptools_scm]
5+
write_to = "sdcflows/_version.py"
6+
write_to_template = """\
7+
\"\"\"Version file, automatically generated by setuptools_scm.\"\"\"
8+
__version__ = "{version}"
9+
"""
10+
fallback_version = "0.0"

sdcflows/__about__.py

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

0 commit comments

Comments
 (0)