From 12c2db72fd88b1dd9c578d10b139ee9f291dfa5d Mon Sep 17 00:00:00 2001 From: Christian Herdtweck Date: Mon, 28 Jan 2019 09:26:13 +0100 Subject: [PATCH] Allow specify py version for make_dist make_dist.py had assumed that py3.3 and py3.6 are installed on local machine. Document that assumption and allow to deviate from it --- make_dist.py | 34 ++++++++++++++++++++++++++++------ 1 files changed, 28 insertions(+), 6 deletions(-) diff --git a/make_dist.py b/make_dist.py index d5df1a2..06b1e9b 100755 --- a/make_dist.py +++ b/make_dist.py @@ -1,13 +1,17 @@ #!/usr/bin/env python3 """ -Create rpm packages of pyi2ncommon for autotest (py3.6) and i2n system (py 3.3). +Create rpm packages of pyi2ncommon for various python versions. -Calls setup.py with different args. Add %check section to .spec file +Per default try building for autotest (py3.6) and i2n system (py 3.3). Can +deviate from this by calling `./make_dist.py 3.4` (for example). All python +versions used must be installed on local machine. -Accidentally stumbled of this: it appears that setting install-lib to -/usr/lib/pythonVERSION/site-packages is translated by setup.py to installation -requirement python(abi) = VERSION +Calls setup.py with different args. Adds %check section to .spec file + +This script relies on one feature I accidentally stumbled over: it appears that +setting install-lib to /usr/lib/pythonVERSION/site-packages is translated by +setup.py to installation requirement python(abi) = VERSION .. codeauthor:: Intra2net AG """ @@ -75,6 +79,15 @@ def create_rpm(py_version): """Create rpm that will install pyi2ncommon for given python version.""" print('Creating RPM for python version {}'.format(py_version)) + # test that python version is installed + try: + result = call(['python{}'.format(py_version), '--version']) + except Exception: + result = 1 + if result != 0: + raise RuntimeError('Python version {} not installed, ' + 'run {} VERSION'.format(py_version, sys.argv[0])) + # define options for where to install library; # It appears this is automatically translated into requirement # python(abi) = version ! @@ -149,7 +162,16 @@ def main(): see module doc for more info """ - for filename in (create_rpm('3.3'), create_rpm('3.6'), create_spec()): + if len(sys.argv) > 1: + versions = sys.argv[1:] + else: + versions = ['3.3', '3.6'] + files_created = [] + for version in versions: + files_created.append(create_rpm(version)) + files_created.append(create_spec()) + + for filename in files_created: print('Created {}'.format(filename)) return 0 -- 1.7.1