From 1949261a504fd01e057b41126d78f142f4977204 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?= Date: Fri, 6 Oct 2017 17:12:15 +0100 Subject: [PATCH 6/6] Enable '--with-salt-version' parameter for setup.py script --- setup.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index effdc2f230..519f753401 100755 --- a/setup.py +++ b/setup.py @@ -183,17 +183,22 @@ class WriteSaltVersion(Command): ''' def run(self): - if not os.path.exists(SALT_VERSION_HARDCODED): + if not os.path.exists(SALT_VERSION_HARDCODED) or self.distribution.with_salt_version: # Write the version file if getattr(self.distribution, 'salt_version_hardcoded_path', None) is None: print('This command is not meant to be called on it\'s own') exit(1) + if not self.distribution.with_salt_version: + salt_version = __saltstack_version__ + else: + salt_version = SaltStackVersion.parse(self.distribution.with_salt_version) + # pylint: disable=E0602 open(self.distribution.salt_version_hardcoded_path, 'w').write( INSTALL_VERSION_TEMPLATE.format( date=DATE, - full_version_info=__saltstack_version__.full_info + full_version_info=salt_version.full_info ) ) # pylint: enable=E0602 @@ -731,6 +736,13 @@ class Build(build): def run(self): # Run build.run function build.run(self) + if getattr(self.distribution, 'with_salt_version', False): + # Write the hardcoded salt version module salt/_version.py + self.distribution.salt_version_hardcoded_path = os.path.join( + self.build_lib, 'salt', '_version.py' + ) + self.run_command('write_salt_version') + if getattr(self.distribution, 'running_salt_install', False): # If our install attribute is present and set to True, we'll go # ahead and write our install time python modules. @@ -839,6 +851,7 @@ class SaltDistribution(distutils.dist.Distribution): ('ssh-packaging', None, 'Run in SSH packaging mode'), ('salt-transport=', None, 'The transport to prepare salt for. Choices are \'zeromq\' ' '\'raet\' or \'both\'. Defaults to \'zeromq\'', 'zeromq')] + [ + ('with-salt-version=', None, 'Set a fixed version for Salt instead calculating it'), # Salt's Paths Configuration Settings ('salt-root-dir=', None, 'Salt\'s pre-configured root directory'), @@ -893,6 +906,9 @@ class SaltDistribution(distutils.dist.Distribution): self.salt_spm_pillar_dir = None self.salt_spm_reactor_dir = None + # Salt version + self.with_salt_version = None + self.name = 'salt-ssh' if PACKAGED_FOR_SALT_SSH else 'salt' self.salt_version = __version__ # pylint: disable=undefined-variable self.description = 'Portable, distributed, remote execution and configuration management system' -- 2.14.2