Fix version handling
See https://packaging.python.org/guides/single-sourcing-package-version/.
This commit is contained in:
parent
8f18594833
commit
73ac351bdd
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from etherpump import VERSION
|
from etherpump import __VERSION__
|
||||||
|
|
||||||
usage = """Usage:
|
usage = """Usage:
|
||||||
etherpump CMD
|
etherpump CMD
|
||||||
@ -36,7 +36,7 @@ try:
|
|||||||
print(usage)
|
print(usage)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
elif any(arg in args for arg in ['--version', '-v']):
|
elif any(arg in args for arg in ['--version', '-v']):
|
||||||
print('etherpump {}'.format(VERSION))
|
print('etherpump {}'.format(__VERSION__))
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
except IndexError:
|
except IndexError:
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
DATAPATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), "data")
|
DATAPATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), "data")
|
||||||
VERSION = '0.0.2'
|
|
||||||
|
__VERSION__ = '0.0.2'
|
||||||
|
24
setup.py
24
setup.py
@ -1,15 +1,35 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import codecs
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
|
||||||
from setuptools import find_packages, setup
|
from setuptools import find_packages, setup
|
||||||
|
|
||||||
from etherpump import VERSION
|
|
||||||
|
def read(*parts):
|
||||||
|
current_file = os.path.abspath(os.path.dirname(__file__))
|
||||||
|
with codecs.open(os.path.join(current_file, *parts), 'r') as fp:
|
||||||
|
return fp.read()
|
||||||
|
|
||||||
|
|
||||||
|
def find_version(*file_paths):
|
||||||
|
version_file = read(*file_paths)
|
||||||
|
version_match = re.search(
|
||||||
|
r"^__VERSION__ = ['\"]([^'\"]*)['\"]", version_file, re.M
|
||||||
|
)
|
||||||
|
if version_match:
|
||||||
|
return version_match.group(1)
|
||||||
|
raise RuntimeError("Unable to find version string.")
|
||||||
|
|
||||||
|
|
||||||
with open('README.md', 'r') as handle:
|
with open('README.md', 'r') as handle:
|
||||||
long_description = handle.read()
|
long_description = handle.read()
|
||||||
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='etherpump',
|
name='etherpump',
|
||||||
version=VERSION,
|
version=find_version('etherpump', '__init__.py'),
|
||||||
author='Varia members',
|
author='Varia members',
|
||||||
author_email='info@varia.zone',
|
author_email='info@varia.zone',
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
|
Loading…
Reference in New Issue
Block a user