This repository was archived by the owner on Jan 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathsetup.py
More file actions
119 lines (106 loc) · 3.92 KB
/
setup.py
File metadata and controls
119 lines (106 loc) · 3.92 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# Copyright 2015 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS-IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Python Cloud Debugger build and packaging script."""
from configparser import ConfigParser
from glob import glob
import os
import re
from distutils import sysconfig
from setuptools import Extension
from setuptools import setup
def RemovePrefixes(optlist, bad_prefixes):
for bad_prefix in bad_prefixes:
for i, flag in enumerate(optlist):
if flag.startswith(bad_prefix):
optlist.pop(i)
break
return optlist
def ReadConfig(section, value, default):
try:
config = ConfigParser()
config.read('setup.cfg')
return config.get(section, value)
except: # pylint: disable=bare-except
return default
LONG_DESCRIPTION = (
'The Cloud Debugger lets you inspect the state of an application at any\n'
'code location without stopping or slowing it down. The debugger makes it\n'
'easier to view the application state without adding logging statements.\n'
'\n'
'For more details please see '
'https://github.com/GoogleCloudPlatform/cloud-debug-python\n')
lib_dirs = ReadConfig('build_ext', 'library_dirs',
sysconfig.get_config_var('LIBDIR')).split(':')
extra_compile_args = ReadConfig('cc_options', 'extra_compile_args', '').split()
extra_link_args = ReadConfig('cc_options', 'extra_link_args', '').split()
static_libs = []
deps = ['libgflags.a', 'libglog.a']
for dep in deps:
for lib_dir in lib_dirs:
path = os.path.join(lib_dir, dep)
if os.path.isfile(path):
static_libs.append(path)
assert len(static_libs) == len(deps), (static_libs, deps, lib_dirs)
cvars = sysconfig.get_config_vars()
cvars['OPT'] = str.join(
' ',
RemovePrefixes(
cvars.get('OPT').split(), ['-g', '-O', '-Wstrict-prototypes']))
# Determine the current version of the package. The easiest way would be to
# import "googleclouddebugger" and read its __version__ attribute.
# Unfortunately we can't do that because "googleclouddebugger" depends on
# "cdbg_native" that hasn't been built yet.
version = None
with open('googleclouddebugger/version.py', 'r') as version_file:
version_pattern = re.compile(r"^\s*__version__\s*=\s*'([0-9.]*)'")
for line in version_file:
match = version_pattern.match(line)
if match:
version = match.groups()[0]
assert version
cdbg_native_module = Extension(
'googleclouddebugger.cdbg_native',
sources=glob('googleclouddebugger/*.cc'),
extra_compile_args=[
'-std=c++0x',
'-Werror',
'-g0',
'-O3',
] + extra_compile_args,
extra_link_args=static_libs + extra_link_args,
libraries=['rt'])
setup(
name='google-python-cloud-debugger',
description='Python Cloud Debugger',
long_description=LONG_DESCRIPTION,
url='https://github.com/GoogleCloudPlatform/cloud-debug-python',
author='Google Inc.',
version=version,
install_requires=[
'firebase-admin>=5.3.0',
'pyyaml',
],
packages=['googleclouddebugger'],
ext_modules=[cdbg_native_module],
license='Apache License, Version 2.0',
keywords='google cloud debugger',
classifiers=[
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
])