Skip to content

Commit ee19d7a

Browse files
authored
Merge pull request #894 from effigies/doc/update_config
DOC: Attempt to find versioneer version when building docs
2 parents 6967461 + 4ac9821 commit ee19d7a

File tree

13 files changed

+72
-63
lines changed

13 files changed

+72
-63
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ script:
121121
flake8 nibabel
122122
elif [ "${CHECK_TYPE}" == "doc" ]; then
123123
cd doc
124-
make html;
125-
make doctest;
124+
make html && make doctest
126125
elif [ "${CHECK_TYPE}" == "test" ]; then
127126
# Change into an innocuous directory and find tests from installation
128127
mkdir for_testing

Changelog

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Enhancements
7979

8080
Bug fixes
8181
---------
82-
* Sliced ``Tractogram``s no longer ``apply_affine`` to the original
82+
* Sliced ``Tractogram``\s no longer ``apply_affine`` to the original
8383
``Tractogram``'s streamlines. (pr/811) (MC, reviewed by Serge Koudoro,
8484
Philippe Poulin, CM, MB)
8585
* Change strings with invalid escapes to raw strings (pr/827) (EL, reviewed
@@ -98,7 +98,7 @@ Maintenance
9898
API changes and deprecations
9999
----------------------------
100100
* Fully remove deprecated ``checkwarns`` and ``minc`` modules. (pr/852) (CM)
101-
* The ``keep_file_open`` argument to file load operations and ``ArrayProxy``s
101+
* The ``keep_file_open`` argument to file load operations and ``ArrayProxy``\s
102102
no longer acccepts the value ``"auto"``, raising a ``ValueError``. (pr/852)
103103
(CM)
104104
* Deprecate ``ArraySequence.data`` in favor of ``ArraySequence.get_data()``,
@@ -420,7 +420,7 @@ New features
420420
* Support for MRtrix TCK streamlines file format (pr/486) (MC, reviewed by
421421
MB, Arnaud Bore, J-Donald Tournier, Jean-Christophe Houde)
422422
* Added ``get_fdata()`` as default method to retrieve scaled floating point
423-
data from ``DataobjImage``s (pr/551) (MB, reviewed by CM, SG)
423+
data from ``DataobjImage``\s (pr/551) (MB, reviewed by CM, SG)
424424

425425
Enhancements
426426
------------

doc/source/conf.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@
2121

2222
import sys
2323
import os
24-
try:
25-
from configparser import ConfigParser
26-
except ImportError:
27-
from ConfigParser import ConfigParser # PY2
24+
from runpy import run_path
25+
from configparser import ConfigParser
2826

2927
# Check for external Sphinx extensions we depend on
3028
try:
@@ -51,9 +49,7 @@
5149
# -- General configuration ----------------------------------------------------
5250

5351
# We load the nibabel release info into a dict by explicit execution
54-
rel = {}
55-
with open(os.path.join('..', '..', 'nibabel', 'info.py'), 'r') as fobj:
56-
exec(fobj.read(), rel)
52+
rel = run_path(os.path.join('..', '..', 'nibabel', 'info.py'))
5753

5854
# Write long description from info
5955
with open('_long_description.inc', 'wt') as fobj:
@@ -62,10 +58,7 @@
6258
# Load metadata from setup.cfg
6359
config = ConfigParser()
6460
config.read(os.path.join('..', '..', 'setup.cfg'))
65-
try:
66-
metadata = config['metadata']
67-
except AttributeError:
68-
metadata = dict(config.items('metadata')) # PY2
61+
metadata = config['metadata']
6962

7063
# Add any Sphinx extension module names here, as strings. They can be
7164
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.

doc/tools/build_modref_templates.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# stdlib imports
66
import sys
77
import re
8+
import os
89
from os.path import join as pjoin
910

1011
# local imports
@@ -48,12 +49,25 @@ def abort(error):
4849

4950
installed_version = V(module.__version__)
5051

51-
info_file = pjoin('..', package, 'info.py')
52-
info_lines = open(info_file).readlines()
53-
source_version = '.'.join([v.split('=')[1].strip(" '\n.")
54-
for v in info_lines if re.match(
55-
'^_version_(major|minor|micro|extra)', v
56-
)])
52+
version_file = pjoin('..', package, '_version.py')
53+
source_version = None
54+
if os.path.exists(version_file):
55+
# Versioneer
56+
from runpy import run_path
57+
try:
58+
source_version = run_path(version_file)['get_versions']()['version']
59+
except (FileNotFoundError, KeyError):
60+
pass
61+
if source_version == '0+unknown':
62+
source_version = None
63+
if source_version is None:
64+
# Legacy fall-back
65+
info_file = pjoin('..', package, 'info.py')
66+
info_lines = open(info_file).readlines()
67+
source_version = '.'.join([v.split('=')[1].strip(" '\n.")
68+
for v in info_lines if re.match(
69+
'^_version_(major|minor|micro|extra)', v
70+
)])
5771
print('***', source_version)
5872

5973
if source_version != installed_version:
@@ -68,6 +82,7 @@ def abort(error):
6882
r'.*test.*$',
6983
r'\.info.*$',
7084
r'\.pkg_info.*$',
85+
r'\.py3k.*$',
7186
]
7287
docwriter.write_api_docs(outdir)
7388
docwriter.write_index(outdir, 'index', relative_to=outdir)

nibabel/affines.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ def obliquity(affine):
306306
This implementation is inspired by `AFNI's implementation
307307
<https://github.com/afni/afni/blob/b6a9f7a21c1f3231ff09efbd861f8975ad48e525/src/thd_coords.c#L660-L698>`_.
308308
For further details about *obliquity*, check `AFNI's documentation
309-
<https://sscc.nimh.nih.gov/sscc/dglen/Obliquity>_.
309+
<https://sscc.nimh.nih.gov/sscc/dglen/Obliquity>`_.
310310
311311
Parameters
312312
----------

nibabel/brikhead.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def __init__(self, file_like, header, mmap=True, keep_file_open=None):
250250
a new file handle is created every time the image is accessed.
251251
If ``file_like`` refers to an open file handle, this setting has no
252252
effect. The default value (``None``) will result in the value of
253-
``nibabel.arrayproxy.KEEP_FILE_OPEN_DEFAULT` being used.
253+
``nibabel.arrayproxy.KEEP_FILE_OPEN_DEFAULT`` being used.
254254
"""
255255
super(AFNIArrayProxy, self).__init__(file_like,
256256
header,
@@ -533,7 +533,7 @@ def from_file_map(klass, file_map, mmap=True, keep_file_open=None):
533533
a new file handle is created every time the image is accessed.
534534
If ``file_like`` refers to an open file handle, this setting has no
535535
effect. The default value (``None``) will result in the value of
536-
``nibabel.arrayproxy.KEEP_FILE_OPEN_DEFAULT` being used.
536+
``nibabel.arrayproxy.KEEP_FILE_OPEN_DEFAULT`` being used.
537537
"""
538538
with file_map['header'].get_prepare_fileobj('rt') as hdr_fobj:
539539
hdr = klass.header_class.from_fileobj(hdr_fobj)
@@ -553,6 +553,7 @@ def filespec_to_file_map(klass, filespec):
553553
afni.nimh.nih.gov/pub/dist/doc/program_help/README.compression.html.
554554
Thus, if you have AFNI files my_image.HEAD and my_image.BRIK.gz and you
555555
want to load the AFNI BRIK / HEAD pair, you can specify:
556+
556557
* The HEAD filename - e.g., my_image.HEAD
557558
* The BRIK filename w/o compressed extension - e.g., my_image.BRIK
558559
* The full BRIK filename - e.g., my_image.BRIK.gz

nibabel/cifti2/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@
2626
Cifti2TransformationMatrixVoxelIndicesIJKtoXYZ,
2727
Cifti2Vertices, Cifti2Volume, CIFTI_BRAIN_STRUCTURES,
2828
Cifti2HeaderError, CIFTI_MODEL_TYPES, load, save)
29-
from .cifti2_axes import (Axis, BrainModelAxis, ParcelsAxis, SeriesAxis, LabelAxis, ScalarAxis)
29+
from .cifti2_axes import (Axis, BrainModelAxis, ParcelsAxis, SeriesAxis, LabelAxis, ScalarAxis)

nibabel/cifti2/cifti2.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def _to_xml_element(self):
172172

173173

174174
class Cifti2LabelTable(xml.XmlSerializable, MutableMapping):
175-
""" CIFTI-2 label table: a sequence of ``Cifti2Label``s
175+
""" CIFTI-2 label table: a sequence of ``Cifti2Label``\s
176176
177177
* Description - Used by NamedMap when IndicesMapToDataType is
178178
"CIFTI_INDEX_TYPE_LABELS" in order to associate names and display colors
@@ -927,8 +927,8 @@ class Cifti2MatrixIndicesMap(xml.XmlSerializable, MutableSequence):
927927
* Text Content: [NA]
928928
* Parent Element - Matrix
929929
930-
Attribute
931-
---------
930+
Attributes
931+
----------
932932
applies_to_matrix_dimension : list of ints
933933
Dimensions of this matrix that follow this mapping
934934
indices_map_to_data_type : str one of CIFTI_MAP_TYPES

nibabel/cifti2/cifti2_axes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
(except for SeriesAxis objects, which have to remain monotonically increasing or decreasing).
2424
2525
Creating new CIFTI-2 axes
26-
-----------------------
26+
-------------------------
2727
New Axis objects can be constructed by providing a description for what is contained
2828
in each row/column of the described tensor. For each Axis sub-class this descriptor is:
2929
@@ -250,7 +250,7 @@ def __init__(self, name, voxel=None, vertex=None, affine=None,
250250
factory methods:
251251
252252
- :py:meth:`~BrainModelAxis.from_mask`: creates surface or volumetric BrainModelAxis axis
253-
from respectively 1D or 3D masks
253+
from respectively 1D or 3D masks
254254
- :py:meth:`~BrainModelAxis.from_surface`: creates a surface BrainModelAxis axis
255255
256256
The resulting BrainModelAxis axes can be concatenated by adding them together.

nibabel/gifti/gifti.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,18 +207,21 @@ class GiftiCoordSystem(xml.XmlSerializable):
207207
Attributes
208208
----------
209209
dataspace : int
210-
From the spec: "Contains the stereotaxic space of a DataArray's data
210+
From the spec: Contains the stereotaxic space of a DataArray's data
211211
prior to application of the transformation matrix. The stereotaxic
212212
space should be one of:
213-
NIFTI_XFORM_UNKNOWN
214-
NIFTI_XFORM_SCANNER_ANAT
215-
NIFTI_XFORM_ALIGNED_ANAT
216-
NIFTI_XFORM_TALAIRACH
217-
NIFTI_XFORM_MNI_152"
213+
214+
- NIFTI_XFORM_UNKNOWN
215+
- NIFTI_XFORM_SCANNER_ANAT
216+
- NIFTI_XFORM_ALIGNED_ANAT
217+
- NIFTI_XFORM_TALAIRACH
218+
- NIFTI_XFORM_MNI_152
219+
218220
xformspace : int
219221
Spec: "Contains the stereotaxic space of a DataArray's data after
220222
application of the transformation matrix. See the DataSpace element for
221223
a list of stereotaxic spaces."
224+
222225
xform : array-like shape (4, 4)
223226
Affine transformation matrix
224227
"""

0 commit comments

Comments
 (0)