Skip to content

Commit 35c9050

Browse files
committed
MAINT: Drop COMMIT_INFO
1 parent 8dd3419 commit 35c9050

File tree

4 files changed

+20
-53
lines changed

4 files changed

+20
-53
lines changed

.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
nibabel/COMMIT_INFO.txt export-subst
21
nibabel/_version.py export-subst

MANIFEST.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,5 @@ recursive-include nibabel/tests/data *
99
recursive-include nibabel/externals/tests/data *
1010
recursive-include nibabel/nicom/tests/data *
1111
recursive-include nibabel/gifti/tests/data *
12-
include nibabel/COMMIT_INFO.txt
1312
include versioneer.py
1413
include nibabel/_version.py

nibabel/COMMIT_INFO.txt

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

nibabel/pkg_info.py

Lines changed: 20 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,16 @@
1-
import os
21
import sys
3-
import subprocess
4-
try:
5-
from ConfigParser import RawConfigParser as ConfigParser
6-
except ImportError:
7-
from configparser import RawConfigParser as ConfigParser # python 3
2+
from . import _version
83

9-
COMMIT_INFO_FNAME = 'COMMIT_INFO.txt'
104

5+
def pkg_commit_hash(pkg_path=None):
6+
''' Get short form of commit hash
117
12-
def pkg_commit_hash(pkg_path):
13-
''' Get short form of commit hash given directory `pkg_path`
8+
Versioneer placed a ``_version.py`` file in the package directory. This file
9+
gets updated on installation or ``git archive``.
10+
We inspect the contents of ``_version`` to detect whether we are in a
11+
repository, an archive of the repository, or an installed package.
1412
15-
There should be a file called 'COMMIT_INFO.txt' in `pkg_path`. This is a
16-
file in INI file format, with at least one section: ``commit hash``, and
17-
two variables ``archive_subst_hash`` and ``install_hash``. The first has a
18-
substitution pattern in it which may have been filled by the execution of
19-
``git archive`` if this is an archive generated that way. The second is
20-
filled in by the installation, if the installation is from a git archive.
21-
22-
We get the commit hash from (in order of preference):
23-
24-
* A substituted value in ``archive_subst_hash``
25-
* A written commit hash value in ``install_hash`
26-
* git's output, if we are in a git repository
27-
28-
If all these fail, we return a not-found placeholder tuple
13+
If detection fails, we return a not-found placeholder tuple
2914
3015
Parameters
3116
----------
@@ -39,27 +24,17 @@ def pkg_commit_hash(pkg_path):
3924
hash_str : str
4025
short form of hash
4126
'''
42-
# Try and get commit from written commit text file
43-
pth = os.path.join(pkg_path, COMMIT_INFO_FNAME)
44-
if not os.path.isfile(pth):
45-
raise IOError('Missing commit info file %s' % pth)
46-
cfg_parser = ConfigParser()
47-
cfg_parser.read(pth)
48-
archive_subst = cfg_parser.get('commit hash', 'archive_subst_hash')
49-
if not archive_subst.startswith('$Format'): # it has been substituted
50-
return 'archive substitution', archive_subst
51-
install_subst = cfg_parser.get('commit hash', 'install_hash')
52-
if install_subst != '':
53-
return 'installation', install_subst
54-
# maybe we are in a repository
55-
proc = subprocess.Popen('git rev-parse --short HEAD',
56-
stdout=subprocess.PIPE,
57-
stderr=subprocess.PIPE,
58-
cwd=pkg_path, shell=True)
59-
repo_commit, _ = proc.communicate()
60-
if repo_commit:
61-
return 'repository', repo_commit.strip()
62-
return '(none found)', '<not found>'
27+
versions = _version.get_versions()
28+
hash_str = versions['full-revisionid'][:7]
29+
if hasattr(_version, 'version_json'):
30+
hash_from = 'installation'
31+
elif not _version.get_keywords()['full'].startswith('$Format:'):
32+
hash_from = 'archive substitution'
33+
elif versions['version'] == '0+unknown':
34+
hash_from, hash_str = '(none found)', '<not found>'
35+
else:
36+
hash_from = 'repository'
37+
return hash_from, hash_str
6338

6439

6540
def get_pkg_info(pkg_path):
@@ -75,7 +50,7 @@ def get_pkg_info(pkg_path):
7550
context : dict
7651
with named parameters of interest
7752
'''
78-
src, hsh = pkg_commit_hash(pkg_path)
53+
src, hsh = pkg_commit_hash()
7954
import numpy
8055
return dict(
8156
pkg_path=pkg_path,

0 commit comments

Comments
 (0)