Skip to content

Commit a4a296a

Browse files
committed
Generate ev3dev/version.py automatically
1 parent 724b215 commit a4a296a

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ __pycache__
55
dist
66
*.egg-info
77
RELEASE-VERSION
8+
ev3dev/version.py
89
build

ev3dev/core.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,12 @@
6161
INPUT_AUTO = ''
6262
OUTPUT_AUTO = ''
6363

64-
# Keep the __version__ in sync with the package version in debian/changelog
65-
__version__ = '0.7.0'
66-
6764
# -----------------------------------------------------------------------------
6865
def list_device_names(class_path, name_pattern, **kwargs):
6966

7067
if not os.path.isdir(class_path):
7168
return
72-
69+
7370
"""
7471
This is a generator function that lists names of all devices matching the
7572
provided parameters.
@@ -174,7 +171,7 @@ def _attribute_file_open( self, name ):
174171
mode = stat.S_IMODE(os.stat(path)[stat.ST_MODE])
175172
r_ok = mode & stat.S_IRGRP
176173
w_ok = mode & stat.S_IWGRP
177-
174+
178175
if r_ok and w_ok:
179176
mode = 'r+'
180177
elif w_ok:
@@ -1420,7 +1417,7 @@ def __init__(self, address=None, name_pattern=SYSTEM_DEVICE_NAME_CONVENTION, nam
14201417
# ~autogen
14211418

14221419
self._value = [None,None,None,None,None,None,None,None]
1423-
1420+
14241421
self._bin_data_format = None
14251422
self._bin_data = None
14261423

git_version.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,8 @@ def read_release_version():
4040

4141

4242
def write_release_version(version):
43-
f = open("RELEASE-VERSION", "w")
44-
f.write("%s\n" % version)
45-
f.close()
43+
with open("RELEASE-VERSION", "w") as f:
44+
f.write("%s\n" % version)
4645

4746

4847
def pep386adapt(version):
@@ -78,6 +77,10 @@ def git_version(abbrev=4):
7877
if version != release_version:
7978
write_release_version(version)
8079

80+
# Update the ev3dev/__version__.py
81+
with open('ev3dev/version.py', 'w') as f:
82+
f.write("__version__ = '{}'".format(version))
83+
8184
# Finally, return the current version.
8285
return version
8386

0 commit comments

Comments
 (0)