mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Generate salt._version
when installing so we can have the git describe information. Fixes #2587.
This commit is contained in:
parent
5022a1d48c
commit
5730b0bf42
1 changed files with 46 additions and 1 deletions
47
setup.py
47
setup.py
|
@ -8,8 +8,11 @@ from __future__ import with_statement
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
from datetime import datetime
|
||||||
from distutils.cmd import Command
|
from distutils.cmd import Command
|
||||||
|
from distutils.command.build import build
|
||||||
from distutils.command.clean import clean
|
from distutils.command.clean import clean
|
||||||
|
from distutils.command.install import install
|
||||||
from distutils.sysconfig import get_python_lib, PREFIX
|
from distutils.sysconfig import get_python_lib, PREFIX
|
||||||
|
|
||||||
# Change to salt source's directory prior to running any command
|
# Change to salt source's directory prior to running any command
|
||||||
|
@ -109,6 +112,43 @@ class Clean(clean):
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
|
install_version_template = """\
|
||||||
|
# This file was auto-generated by salt's setup on \
|
||||||
|
{date:%A, %d %B %Y @ %H:%m:%S UTC}'.
|
||||||
|
|
||||||
|
__version__ = {version!r}
|
||||||
|
__version_info__ = {version_info!r}
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
class Build(build):
|
||||||
|
def run(self):
|
||||||
|
# Run build.run function
|
||||||
|
build.run(self)
|
||||||
|
# If our install attribute is present and set to True, we'll go ahead
|
||||||
|
# and write our install time _version.py file.
|
||||||
|
if getattr(self.distribution, 'running_salt_install', False):
|
||||||
|
version_file_path = os.path.join(
|
||||||
|
self.build_lib, 'salt', '_version.py'
|
||||||
|
)
|
||||||
|
open(version_file_path, 'w').write(
|
||||||
|
install_version_template.format(
|
||||||
|
date=datetime.utcnow(),
|
||||||
|
version=__version__,
|
||||||
|
version_info=__version_info__
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class Install(install):
|
||||||
|
def run(self):
|
||||||
|
# Let's set the running_salt_install attribute so we can add
|
||||||
|
# _version.py in the build command
|
||||||
|
self.distribution.running_salt_install = True
|
||||||
|
# Run install.run
|
||||||
|
install.run(self)
|
||||||
|
|
||||||
|
|
||||||
NAME = 'salt'
|
NAME = 'salt'
|
||||||
VER = __version__
|
VER = __version__
|
||||||
DESC = ('Portable, distributed, remote execution and '
|
DESC = ('Portable, distributed, remote execution and '
|
||||||
|
@ -134,7 +174,12 @@ setup_kwargs = {'name': NAME,
|
||||||
'author': 'Thomas S Hatch',
|
'author': 'Thomas S Hatch',
|
||||||
'author_email': 'thatch45@gmail.com',
|
'author_email': 'thatch45@gmail.com',
|
||||||
'url': 'http://saltstack.org',
|
'url': 'http://saltstack.org',
|
||||||
'cmdclass': {'test': TestCommand, 'clean': Clean},
|
'cmdclass': {
|
||||||
|
'test': TestCommand,
|
||||||
|
'clean': Clean,
|
||||||
|
'build': Build,
|
||||||
|
'install': Install
|
||||||
|
},
|
||||||
'classifiers': ['Programming Language :: Python',
|
'classifiers': ['Programming Language :: Python',
|
||||||
'Programming Language :: Cython',
|
'Programming Language :: Cython',
|
||||||
'Programming Language :: Python :: 2.6',
|
'Programming Language :: Python :: 2.6',
|
||||||
|
|
Loading…
Add table
Reference in a new issue