Skip to content

Commit 6eb7b19

Browse files
committed
Read version from version.txt, not by executing version.py
1 parent bc869b0 commit 6eb7b19

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

pysces/version.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
MAJOR = 1
2-
MINOR = 0
3-
MICRO = 1
4-
STATUS = ''
1+
import re
2+
import os
53

4+
cwd = os.path.dirname(__file__)
5+
6+
with open(os.path.join(cwd, 'version.txt'), 'r') as f:
7+
v = f.read().strip().split('.')
8+
9+
MAJOR = int(v[0])
10+
MINOR = int(v[1])
11+
MICRO = int(re.split('(\d+)', v[2])[1])
12+
STATUS = re.split('(\d+)', v[2])[2]
613

714
def current_version():
815
return '%s.%s.%s%s' % (MAJOR, MINOR, MICRO, STATUS)
916

10-
1117
def current_version_tuple():
1218
return (MAJOR, MINOR, MICRO)
1319

14-
1520
__version__ = current_version()

pysces/version.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.0.1

setup.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,15 @@
2121

2222
__doc__ = "PySCeS: the Python Simulator for Cellular Systems setup file"
2323

24-
# get __version__ from version.py
25-
with open('pysces/version.py') as f:
26-
exec(f.read())
24+
# get __version__ from version.txt
25+
with open('pysces/version.txt') as f:
26+
__version__ = f.read().strip()
2727

2828
# avoid duplication
2929
with open('requirements.txt') as f:
3030
requirements = f.read().splitlines()
3131

3232
import os, re
33-
import sysconfig
34-
35-
import fileinput
36-
import shutil
3733

3834
try:
3935
import configparser # Py 3

0 commit comments

Comments
 (0)