Skip to content

Commit db10401

Browse files
authored
Merge pull request #59 from cortex-lab/agent/development-version
Mark master as 2.7.1.dev0
2 parents 734c223 + 97a40f7 commit db10401

6 files changed

Lines changed: 45 additions & 14 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Added
1111
- Code of Conduct for project participation and incident reporting.
1212

13+
### Fixed
14+
- Development checkouts now report a development version with a Git commit suffix.
15+
1316
## [2.7.0] 2025-12-10
1417

1518
### Added

‎README.md‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,14 @@ Electrophysiological data analysis library used by [phy](https://github.com/kwik
99

1010
- participation in phylib is governed by the project [Code of Conduct](CODE_OF_CONDUCT.md)
1111
- run all tests using pytest `pytest phylib`
12-
- PR to main
13-
- update `CHANGELOG.md` and version in `phylib\__init__.py`
14-
- publish to pypi:
12+
- PR to master
13+
- keep `phylib/__init__.py` on the next development version (for example,
14+
`2.7.1.dev0`)
15+
- for a release, update `CHANGELOG.md`, remove the `.dev0` suffix, run the
16+
tests, and tag the exact release commit
17+
- after publishing, immediately bump `phylib/__init__.py` to the next
18+
`.dev0` version
19+
- publish to pypi:
1520
```shell
1621
rm -R dist
1722
rm -R build

‎phylib/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
__author__ = 'Cyrille Rossant'
2424
__email__ = 'cyrille.rossant at gmail.com'
25-
__version__ = '2.7.0'
25+
__version__ = '2.7.1.dev0'
2626
__version_git__ = __version__ + _git_version()
2727

2828

‎phylib/utils/_misc.py‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -354,19 +354,19 @@ def _load_from_fullname(name):
354354

355355

356356
def _git_version():
357-
"""Return the git version."""
358-
curdir = os.getcwd()
359-
os.chdir(str(Path(__file__).parent))
357+
"""Return a PEP 440-compatible local version derived from Git."""
358+
cwd = str(Path(__file__).parent)
360359
try:
361360
with open(os.devnull, 'w') as fnull:
362-
version = ('-git-' + subprocess.check_output(
363-
['git', 'describe', '--abbrev=8', '--dirty', '--always', '--tags'],
364-
stderr=fnull).strip().decode('ascii'))
365-
return version
361+
revision = subprocess.check_output(
362+
['git', 'rev-parse', '--short=8', 'HEAD'],
363+
cwd=cwd, stderr=fnull).strip().decode('ascii')
364+
dirty = subprocess.call(
365+
['git', 'diff', '--quiet', 'HEAD', '--'],
366+
cwd=cwd, stdout=fnull, stderr=fnull)
367+
return '+git.' + revision + ('.dirty' if dirty else '')
366368
except (OSError, subprocess.CalledProcessError): # pragma: no cover
367369
return ""
368-
finally:
369-
os.chdir(curdir)
370370

371371

372372
def phy_config_dir():

‎phylib/utils/tests/test_misc.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
# Imports
77
#------------------------------------------------------------------------------
88

9+
import re
10+
911
import numpy as np
1012
from numpy.testing import assert_array_equal as ae
1113
from pytest import raises, mark
@@ -137,7 +139,7 @@ def test_write_tsv(tempdir):
137139

138140
def test_git_version():
139141
v = _git_version()
140-
assert v
142+
assert re.match(r'^\+git\.[0-9a-f]{8}(?:\.dirty)?$', v)
141143

142144

143145
def _myfunction(x):

‎phylib/utils/tests/test_version.py‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""Tests of package versioning."""
4+
5+
import re
6+
import subprocess
7+
import sys
8+
from pathlib import Path
9+
10+
import phylib
11+
12+
13+
def test_version_format():
14+
assert re.match(r'^\d+\.\d+\.\d+(?:\.dev\d+)?$', phylib.__version__)
15+
16+
17+
def test_setup_version_matches_package_version():
18+
root = Path(__file__).parents[3]
19+
version = subprocess.check_output(
20+
[sys.executable, 'setup.py', '--version'], cwd=str(root)).decode().strip()
21+
assert version == phylib.__version__

0 commit comments

Comments
 (0)