Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 25838bf

Browse filesBrowse files
committed
Automatic versioning (fixes bpython#333)
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
1 parent 347c7c8 commit 25838bf
Copy full SHA for 25838bf

3 files changed

+31-4Lines changed: 31 additions & 4 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.gitignore‎

Copy file name to clipboardExpand all lines: .gitignore
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ env
99
.DS_Store
1010
.idea/
1111
doc/sphinx/build/*
12+
bpython/_version.py
Collapse file

‎bpython/__init__.py‎

Copy file name to clipboardExpand all lines: bpython/__init__.py
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@
2121
# THE SOFTWARE.
2222

2323
import os.path
24+
import bpython._version
2425

25-
__version__ = 'git'
26+
27+
__version__ = bpython._version.__version__
2628
package_dir = os.path.abspath(os.path.dirname(__file__))
2729

2830

Collapse file

‎setup.py‎

Copy file name to clipboardExpand all lines: setup.py
+27-3Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
import os
66
import platform
77
import sys
8+
import subprocess
89

910
from distutils.command.build import build
1011
from setuptools import setup
1112
from setuptools.command.install import install as _install
1213

13-
from bpython import __version__, package_dir
14+
from bpython import package_dir
1415

1516
try:
1617
from babel.messages.frontend import compile_catalog as _compile_catalog
@@ -33,14 +34,37 @@
3334
except ImportError:
3435
using_sphinx = False
3536

37+
38+
# version handling
39+
version_file = 'bpython/_version.py'
40+
41+
try:
42+
# get version from git describe
43+
version = subprocess.check_output(['git', 'describe', '--tags']).rstrip()
44+
except OSError:
45+
try:
46+
# get version from existing version file
47+
with open(version_file) as vf:
48+
version = vf.read().strip().split('=')[-1].replace('\'', '')
49+
except IOError:
50+
version = 'unknown'
51+
52+
with open(version_file, 'w') as vf:
53+
vf.write('# Auto-generated file, do not edit!\n')
54+
vf.write('__version__=\'%s\'\n' % (version, ))
55+
3656
class install(_install):
3757
"""Force install to run build target."""
3858

3959
def run(self):
4060
self.run_command('build')
4161
_install.run(self)
4262

43-
cmdclass = dict(build=build, install=install)
63+
cmdclass = {
64+
'build': build,
65+
'install': install
66+
}
67+
4468
translations_dir = os.path.join(package_dir, 'translations')
4569

4670
# localization options
@@ -172,7 +196,7 @@ def initialize_options(self):
172196

173197
setup(
174198
name="bpython",
175-
version = __version__,
199+
version = version,
176200
author = "Bob Farrell, Andreas Stuehrk et al.",
177201
author_email = "robertanthonyfarrell@gmail.com",
178202
description = "Fancy Interface to the Python Interpreter",

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.