forked from google/grr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
79 lines (64 loc) · 2.34 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env python
"""setup.py file for a GRR Colab library."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
import os
import shutil
import sys
from setuptools import setup
from setuptools.command.sdist import sdist
# TODO: Fix this import once support for Python 2 is dropped.
# pylint: disable=g-import-not-at-top
if sys.version_info.major == 2:
import ConfigParser as configparser
else:
import configparser
# pylint: enable=g-import-not-at-top
THIS_DIRECTORY = os.path.dirname(os.path.realpath(__file__))
# If you run setup.py from the root GRR dir you get very different results since
# setuptools uses the MANIFEST.in from the root dir. Make sure we are in the
# package dir.
os.chdir(THIS_DIRECTORY)
def get_config():
"""Get INI parser with version.ini data."""
# TODO(hanuszczak): See comment in `setup.py` for `grr-response-proto`.
ini_path = os.path.join(THIS_DIRECTORY, "version.ini")
if not os.path.exists(ini_path):
ini_path = os.path.join(THIS_DIRECTORY, "../version.ini")
if not os.path.exists(ini_path):
raise RuntimeError("Couldn't find version.ini")
config = configparser.SafeConfigParser()
config.read(ini_path)
return config
class Sdist(sdist):
"""Build sdist."""
def make_release_tree(self, base_dir, files):
sdist.make_release_tree(self, base_dir, files)
sdist_version_ini = os.path.join(base_dir, "version.ini")
if os.path.exists(sdist_version_ini):
os.unlink(sdist_version_ini)
shutil.copy(
os.path.join(THIS_DIRECTORY, "../version.ini"), sdist_version_ini)
VERSION = get_config()
setup(
name="grr-colab",
version=VERSION.get("Version", "packageversion"),
description="GRR Colab library",
license="Apache License, Version 2.0",
url="https://github.com/google/grr/tree/master/colab",
maintainer="GRR Development Team",
maintainer_email="[email protected]",
cmdclass={
"sdist": Sdist,
},
install_requires=[
"future==0.17.1",
"grr_api_client==%s" % VERSION.get("Version", "packagedepends"),
"grr_response_proto==%s" % VERSION.get("Version", "packagedepends"),
"humanize==0.5.1",
"ipaddress==1.0.22",
"ipython==%s" % ("5.0.0" if sys.version_info < (3, 0) else "7.2.0"),
"numpy==1.16.4",
"pandas==0.24.1",
])