Browse Source

Add commit info while installing

tags/v1.2.1
liuluobin 4 years ago
parent
commit
53b1692e75
1 changed files with 25 additions and 1 deletions
  1. +25
    -1
      setup.py

+ 25
- 1
setup.py View File

@@ -13,6 +13,8 @@
# limitations under the License.
import os
import stat
import shlex
import subprocess
from setuptools import find_packages
from setuptools import setup
from setuptools.command.egg_info import egg_info
@@ -64,6 +66,28 @@ def update_permissions(path):
os.chmod(file_fullpath, stat.S_IREAD)


def get_description():
"""
Get description.

Returns:
str, wheel package description.
"""
cmd = "git log --format='[sha1]:%h, [branch]:%d' -1"
process = subprocess.Popen(
shlex.split(cmd),
shell=False,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
stdout, _ = process.communicate()
if not process.returncode:
git_version = stdout.decode().strip()
return "A smart AI security and trustworthy tool box. Git version: %s" % (git_version)
return "A smart AI security and trustworthy tool box."


class EggInfo(egg_info):
"""Egg info."""
def run(self):
@@ -91,7 +115,7 @@ setup(
'Sources': 'https://gitee.com/mindspore/mindarmour',
'Issue Tracker': 'https://gitee.com/mindspore/mindarmour/issues',
},
description="A smart AI security and trustworthy tool box.",
description=get_description(),
license='Apache 2.0',
packages=find_packages(),
include_package_data=True,


Loading…
Cancel
Save