Move version string to the python code

This way the python module "knows" its own version. To avoid duplication,
read the value back from setup.py. The reader function only needs to
support the specific format used in the code, so it can be very simplistic.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2019-05-06 22:34:02 +02:00
parent 8d21ef1ee4
commit aa9fc8646a
2 changed files with 12 additions and 1 deletions

View file

@ -1,2 +1,4 @@
from .metadata import * from .metadata import *
from . import licensing from . import licensing
__version__ = '9'

View file

@ -1,8 +1,17 @@
from setuptools import setup from setuptools import setup
def read_version(path):
with open(path, 'rt') as f:
for line in f:
if line.startswith('__version__'):
return line.split("'")[1]
raise IOError
version = read_version('rust2rpm/__init__.py')
ARGS = dict( ARGS = dict(
name="rust2rpm", name="rust2rpm",
version="9", version=version,
description="Convert Rust crates to RPM", description="Convert Rust crates to RPM",
license="MIT", license="MIT",
keywords="rust cargo rpm", keywords="rust cargo rpm",