From aa9fc8646a4bcf43bba544d37c2f6e6e59b1bebb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Mon, 6 May 2019 22:34:02 +0200 Subject: [PATCH 04/14] 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. --- rust2rpm/__init__.py | 2 ++ setup.py | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/rust2rpm/__init__.py b/rust2rpm/__init__.py index 6aba575..4a0db7b 100644 --- a/rust2rpm/__init__.py +++ b/rust2rpm/__init__.py @@ -1,2 +1,4 @@ from .metadata import * from . import licensing + +__version__ = '9' diff --git a/setup.py b/setup.py index 3eb2a77..79367da 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,17 @@ 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( name="rust2rpm", - version="9", + version=version, description="Convert Rust crates to RPM", license="MIT", keywords="rust cargo rpm", -- 2.22.0.rc3