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

RF: Cleanup Makefile to bring parity with CI, remove tox + nose references #1105

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
44 changes: 18 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ PROJECT=nibabel
# The Python executable to be used
#
PYTHON ?= python
NOSETESTS = $(PYTHON) $(shell which nosetests)
TEST_RUNNER ?= pytest

#
# Determine details on the Python/system
Expand Down Expand Up @@ -66,7 +66,6 @@ distclean: clean
-o -iname '#*#' | xargs -L10 rm -f
-rm -r dist
-rm build-stamp
-rm -r .tox
# -rm tests/data/*.hdr.* tests/data/*.img.* tests/data/something.nii \
# tests/data/noise* tests/data/None.nii

Expand All @@ -83,22 +82,23 @@ $(WWW_DIR):
# Tests
#

test: unittest testmanual
test: test-style unittest testmanual


ut-%: build
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this as I did not see it being used anywhere. I can revert this if a maintainer feels it should be brought back

@PYTHONPATH=.:$(PYTHONPATH) $(NOSETESTS) nibabel/tests/test_$*.py


unittest: build
@PYTHONPATH=.:$(PYTHONPATH) $(NOSETESTS) nibabel --with-doctest
unittest: build test-clean
export CHECK_TYPE=test; ./tools/ci/check.sh

testmanual: build
@cd doc/source && PYTHONPATH=../..:$(PYTHONPATH) $(NOSETESTS) --with-doctest --doctest-extension=.rst . dicom
export CHECK_TYPE=doc; ./tools/ci/check.sh

coverage: unittest

coverage: build
@PYTHONPATH=.:$(PYTHONPATH) $(NOSETESTS) --with-coverage --cover-package=nibabel
.PHONY: test-style
test-style:
export CHECK_TYPE=style; ./tools/ci/check.sh
Comment on lines +95 to +97
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather put make style in check.sh than call check.sh from here. And likewise with other tests.

Suggested change
.PHONY: test-style
test-style:
export CHECK_TYPE=style; ./tools/ci/check.sh
.PHONY: style
style:
flake8


.PHONY: test-clean
test-clean:
rm -rf for_testing


#
Expand Down Expand Up @@ -252,11 +252,13 @@ sdist-venv: clean
rm -rf dist venv
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure if this target is still being used anywhere -- so I kind of hacked it to install the dev dependencies to get it to pass on my local

unset PYTHONPATH && $(PYTHON) setup.py sdist --formats=zip
virtualenv --system-site-packages --python=$(PYTHON) venv
. venv/bin/activate && pip install --ignore-installed nose
. venv/bin/activate && pip install -r dev-requirements.txt
mkdir venv/tmp
cd venv/tmp && unzip ../../dist/*.zip
. venv/bin/activate && cd venv/tmp/nibabel* && python setup.py install
unset PYTHONPATH && . venv/bin/activate && cd venv && nosetests --with-doctest nibabel nisext
unset PYTHONPATH && . \
venv/bin/activate && \
cd venv && $(TEST_RUNNER) --doctest-modules --doctest-plus nibabel nisext

source-release: distclean
$(PYTHON) -m compileall .
Expand All @@ -269,17 +271,7 @@ venv-tests:
make distclean
- rm -rf $(VIRTUAL_ENV)/lib/python$(PYVER)/site-packages/nibabel
$(PYTHON) setup.py install
cd .. && nosetests $(VIRTUAL_ENV)/lib/python$(PYVER)/site-packages/nibabel

tox-fresh:
# tox tests with fresh-installed virtualenvs. Needs network. And
# pytox, obviously.
tox -c tox.ini

tox-stale:
# tox tests with MB's already-installed virtualenvs (numpy and nose
# installed)
tox -e python25,python26,python27,python32,np-1.2.1
cd .. && $(TEST_RUNNER) $(VIRTUAL_ENV)/lib/python$(PYVER)/site-packages/nibabel

refresh-readme:
$(PYTHON) tools/refresh_readme.py
Expand Down
2 changes: 2 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Requirements for running tests
-r requirements.txt
pytest
pytest-doctestplus
flake8
4 changes: 3 additions & 1 deletion doc-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Requirements for building docs
-r requirements.txt
sphinx<3
numpydoc
jinja2<3
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I needed to pin these to get version compatibility to work. In the future might be better to use a tool like poetry so that we can generate a lockfile and not have to deal with this sort of not-fun dependency pinning

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I needed this to get my local to pass but it seems like CI might not like it.... I'll try reverting to see if if this is what is breaking the pre-release CI jobs

numpydoc<1.3
MarkupSafe<2.1
texext
matplotlib >=1.3.1
2 changes: 1 addition & 1 deletion doc/source/dicom/derivations/spm_dicom_orient.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def numbered_vector(nrows, symbol_prefix):
R = zeros(4, 2)
R[:3, :] = R3

# The following is specific to the SPM algorithm.
# The following is specific to the SPM algorithm.
x1 = ones(4, 1)
y1 = ones(4, 1)
y1[:3, :] = pos_pat_0
Expand Down
3 changes: 3 additions & 0 deletions doc/source/scripts/make_coord_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
x, y = 0, 1
# Make a rectangular box with these sides


def make_ortho_box(bl, x_len, y_len):
""" Make a box with sides parallel to the axes
"""
Expand All @@ -76,6 +77,7 @@ def make_ortho_box(bl, x_len, y_len):
[bl[x], bl[y] + y_len],
[bl[x] + x_len, bl[y] + y_len]))


orth_epi_box = make_ortho_box(epi_bl, epi_x_len, epi_y_len)

# Structural bounding box
Expand Down Expand Up @@ -126,6 +128,7 @@ def plot_localizer():
def save_plot():
# Plot using global variables
plot_localizer()

def vx2mm(pts):
return pts - iso_center
plot_box(vx2mm(rot_box), label='EPI bounding box')
Expand Down
8 changes: 6 additions & 2 deletions doc/tools/build_modref_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def abort(error):

try:
__import__(package)
except ImportError as e:
except ImportError:
abort("Can not import " + package)

module = sys.modules[package]
Expand Down Expand Up @@ -71,7 +71,11 @@ def abort(error):
print('***', source_version)

if source_version != installed_version:
abort("Installed version does not match source version")
abort(
"Installed version does not match source version. "
"source_version=" + str(source_version) +
"installed_version=" + str(installed_version)
)

docwriter = ApiDocWriter(package, rst_extension='.rst',
other_defines=other_defines)
Expand Down
7 changes: 7 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,17 @@ nibabel =
max-line-length = 100
ignore = D100,D101,D102,D103,D104,D105,D200,D201,D202,D204,D205,D208,D209,D210,D300,D301,D400,D401,D403,E24,E121,E123,E126,E226,E266,E402,E704,E731,F821,I100,I101,I201,N802,N803,N804,N806,W503,W504,W605
exclude =
venv
build
*test*
*sphinx*
nibabel/externals/*
*/__init__.py
# temporary -- should be removed in another PR
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need a follow-up PR to clean up the remaining issues. I added these as ignores so that local flake8 passes. These were being covered up by the configuration of pep8speaks only looking at the diff

./doc/source/conf.py
./doc/tools/apigen.py
./nisext
./tools

[versioneer]
VCS = git
Expand Down
10 changes: 5 additions & 5 deletions tools/ci/activate.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
if [ -e virtenv/bin/activate ]; then
source virtenv/bin/activate
elif [ -e virtenv/Scripts/activate ]; then
source virtenv/Scripts/activate
if [ -e venv/bin/activate ]; then
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change was made so that we are consistent in local dev and remote dev with the virtualenv

source venv/bin/activate
elif [ -e venv/Scripts/activate ]; then
source venv/Scripts/activate
else
echo Cannot activate virtual environment
ls -R virtenv
ls -R venv
false
fi

3 changes: 1 addition & 2 deletions tools/ci/check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ set -x
export NIBABEL_DATA_DIR="$PWD/nibabel-data"

if [ "${CHECK_TYPE}" == "style" ]; then
# Run styles only on core nibabel code.
flake8 nibabel
flake8
elif [ "${CHECK_TYPE}" == "doc" ]; then
cd doc
make html && make doctest
Expand Down
2 changes: 1 addition & 1 deletion tools/ci/create_venv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ echo SETUP_REQUIRES = $SETUP_REQUIRES
set -x

python -m pip install --upgrade pip virtualenv
virtualenv --python=python virtenv
virtualenv --python=python venv
source tools/ci/activate.sh
python --version
python -m pip install -U $SETUP_REQUIRES
Expand Down
20 changes: 0 additions & 20 deletions tox.ini

This file was deleted.