MCPcopy Create free account
hub / github.com/apache/impala / get_version

Function get_version

shell/setup.py:55–132  ·  view source on GitHub ↗

Generate package version string when calling 'setup.py'. When setup.py is being used to CREATE a distribution, e.g., via setup.py sdist or setup.py bdist, then use the output from impala_build_version.get_version(), and append modifiers as specified by the RELEASE_TYPE and OFFICIAL environmen

()

Source from the content-addressed store, hash-verified

53
54
55def get_version():
56 """Generate package version string when calling 'setup.py'.
57
58 When setup.py is being used to CREATE a distribution, e.g., via setup.py sdist
59 or setup.py bdist, then use the output from impala_build_version.get_version(),
60 and append modifiers as specified by the RELEASE_TYPE and OFFICIAL environment
61 variables. By default, the package created will be a dev release, designated
62 by timestamp. For example, if get_version() returns the string 3.0.0-SNAPSHOT,
63 the package version may be something like 3.0.0.dev20180322154653.
64
65 It's also possible set an evironment variable for BUILD_VERSION to override the
66 default build value returned from impala_build_version.get_version().
67
68 E.g., to specify an offical 3.4 beta 2 release (3.4b2), one would call:
69
70 BUILD_VERSION=3.4 RELEASE_TYPE=b2 OFFICIAL=true python setup.py sdist
71
72 The generated version string will be written to a version.txt file to be
73 referenced when the distribution is installed.
74
75 When setup.py is invoked during installation, e.g., via pip install or
76 setup.py install, read the package version from the version.txt file, which
77 is presumed to contain a single line containing a valid PEP-440 version string.
78 The file should have been generated when the distribution being installed was
79 created. (Although a version.txt file can also be created manually.)
80
81 See https://www.python.org/dev/peps/pep-0440/ for more info on python
82 version strings.
83
84 Returns:
85 A package version string compliant with PEP-440
86 """
87 version_file = os.path.join(CURRENT_DIR, 'version.txt')
88
89 if not os.path.isfile(version_file):
90 # If setup.py is being executed to create a distribution, e.g., via setup.py
91 # sdist or setup.py bdist, then derive the version and WRITE the version.txt
92 # file that will later be used for installations.
93 if os.getenv('BUILD_VERSION') is not None:
94 package_version = os.getenv('BUILD_VERSION')
95 else:
96 version_match = re.search(r'\d+\.\d+\.\d+', impala_build_version.get_version())
97 if version_match is None:
98 sys.exit('Unable to acquire Impala version.')
99 package_version = version_match.group(0)
100
101 # packages can be marked as alpha, beta, or rc RELEASE_TYPE
102 release_type = os.getenv('RELEASE_TYPE')
103 if release_type:
104 if not re.match(r'(a|b|rc)\d+?', release_type):
105 msg = """\
106 RELEASE_TYPE \'{0}\' does not conform to any PEP-440 release format:
107
108 aN (for alpha releases)
109 bN (for beta releases)
110 rcN (for release candidates)
111
112 where N is the number of the release"""

Callers 2

setup.pyFile · 0.85
impala_shell.pyFile · 0.85

Calls 5

matchMethod · 0.80
joinMethod · 0.45
searchMethod · 0.45
formatMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected