|
4 | 4 | import os.path
|
5 | 5 | import subprocess
|
6 | 6 |
|
| 7 | +VERSION_PATH='jsonpath_rw/VERSION' |
7 | 8 |
|
8 | 9 | # Build README.txt from README.md if not present, and if we are actually building for distribution to pypi
|
9 | 10 | if not os.path.exists('README.txt') and 'sdist' in sys.argv:
|
|
17 | 18 | except:
|
18 | 19 | long_description = 'Could not read README.txt'
|
19 | 20 |
|
| 21 | +# Ensure that the VERSION file is shipped with the distribution |
| 22 | +if 'sdist' in sys.argv: |
| 23 | + import jsonpath_rw.version |
| 24 | + with io.open(VERSION_PATH, 'w', encoding='ascii') as fh: |
| 25 | + fh.write(jsonpath_rw.version.git_version()) |
| 26 | + |
| 27 | +# This requires either jsonpath_rw/VERSION or to be in a git clone (as does the package in general) |
| 28 | +# This is identical to code in jsonpath_rw.version. It would be nice to re-use but importing requires all deps |
| 29 | +def stored_version(): |
| 30 | + if os.path.exists(VERSION_PATH): |
| 31 | + with io.open(VERSION_PATH, encoding='ascii') as fh: |
| 32 | + return fh.read().strip() |
| 33 | + else: |
| 34 | + return None |
| 35 | + |
| 36 | +def git_version(): |
| 37 | + described_version_bytes = subprocess.Popen(['git', 'describe'], stdout=subprocess.PIPE).communicate()[0].strip() |
| 38 | + return described_version_bytes.decode('ascii') |
| 39 | + |
| 40 | +version = stored_version() or git_version() |
| 41 | + |
20 | 42 | setuptools.setup(
|
21 | 43 | name='jsonpath-rw',
|
22 |
| - version='1.2.0', |
| 44 | + version=version, |
23 | 45 | description='A robust and significantly extended implementation of JSONPath for Python, with a clear AST for metaprogramming.',
|
24 | 46 | author='Kenneth Knowles',
|
25 | 47 | author_email='kenn.knowles@gmail.com',
|
26 | 48 | url='https://github.com/kennknowles/python-jsonpath-rw',
|
27 | 49 | license='Apache 2.0',
|
28 | 50 | long_description=long_description,
|
29 | 51 | packages = ['jsonpath_rw'],
|
| 52 | + package_data = {'': ['VERSION']}, |
30 | 53 | test_suite = 'tests',
|
31 | 54 | install_requires = [ 'ply', 'decorator', 'six' ],
|
32 | 55 | classifiers = [
|
|
0 commit comments