|
1 | 1 | #! /usr/bin/env python3 |
2 | 2 |
|
| 3 | +# Beware when cross-building 64/32 bit: |
| 4 | +# When using --plat-name to override this, make sure to `rm -r build` othewise |
| 5 | +# files from the wrong platform might be reused. |
| 6 | +# Also, on Linux because of https://bugs.python.org/issue18987, using a 32 bit |
| 7 | +# Python on a 64 bit OS is not enough to change the platform tag. |
| 8 | + |
3 | 9 | from __future__ import print_function |
4 | 10 |
|
5 | 11 | import io |
6 | 12 | import os |
7 | 13 | from os import path |
| 14 | +import re |
8 | 15 |
|
9 | 16 | # https://github.com/PyCQA/pylint/issues/73 |
10 | 17 | #pylint:disable=no-name-in-module,import-error |
|
24 | 31 |
|
25 | 32 | CSDK_ENV_NAME = 'DT_PYSDK_CSDK_PATH' |
26 | 33 |
|
27 | | -with io.open('README.md', encoding='utf-8') as readmefile: |
| 34 | +_THIS_DIR = path.dirname(path.abspath(__file__)) |
| 35 | + |
| 36 | +with io.open(path.join(_THIS_DIR, 'README.md'), encoding='utf-8') as readmefile: |
28 | 37 | long_description = readmefile.read() |
29 | 38 | del readmefile |
30 | 39 |
|
| 40 | +VER_RE = re.compile(r"^__version__ = '([^']+)'$") |
| 41 | + |
| 42 | +verfilepath = path.join(_THIS_DIR, 'src/oneagent/__init__.py') |
| 43 | +with io.open(verfilepath, encoding='utf-8') as verfile: |
| 44 | + for line in verfile: |
| 45 | + match = VER_RE.match(line) |
| 46 | + if match: |
| 47 | + __version__ = match.group(1) |
| 48 | + break |
| 49 | + else: |
| 50 | + raise AssertionError('Version not found in src/oneagent/__init__.py') |
| 51 | +del match, verfile, verfilepath, VER_RE |
| 52 | + |
| 53 | + |
31 | 54 | def compilefile(fname, mode='exec'): |
32 | 55 | with open(fname) as srcfile: |
33 | 56 | codestr = srcfile.read() |
@@ -63,7 +86,8 @@ def get_tag(self): |
63 | 86 | def get_dll_info(plat_name): |
64 | 87 | dll_info = {} |
65 | 88 | #pylint:disable=exec-used |
66 | | - exec(compilefile('src/oneagent/_impl/native/sdkdllinfo.py'), dll_info) |
| 89 | + infopath = path.join(_THIS_DIR, 'src/oneagent/_impl/native/sdkdllinfo.py') |
| 90 | + exec(compilefile(infopath), dll_info) |
67 | 91 | if plat_name: |
68 | 92 | is_win32 = plat_name.startswith('win') |
69 | 93 | is_64bit = plat_name.endswith('64') |
@@ -158,39 +182,44 @@ def has_ext_modules(self): #pylint:disable=no-self-use |
158 | 182 | if bdist_wheel is not None: |
159 | 183 | cmdclss['bdist_wheel'] = BdistWheel |
160 | 184 |
|
161 | | -setup( |
162 | | - packages=find_packages('src'), |
163 | | - package_dir={'': 'src'}, |
164 | | - include_package_data=True, |
165 | | - zip_safe=True, |
166 | | - python_requires='>=2.7,!=3.0,!=3.1,!=3.2,!=3.3', |
167 | | - cmdclass=cmdclss, |
168 | | - name='oneagent-sdk', |
169 | | - version='0.1', |
170 | | - distclass=BinaryDistribution, |
171 | | - |
172 | | - description='Dynatrace OneAgent SDK for Python', |
173 | | - long_description=long_description, |
174 | | - url='https://www.dynatrace.com/', |
175 | | - maintainer='Dynatrace LLC', |
176 | | - maintainer_email='dynatrace.oneagent.sdk@dynatrace.com', |
177 | | - license='Apache License 2.0', |
178 | | - classifiers=[ |
179 | | - 'Development Status :: 2 - Pre-Alpha', |
180 | | - 'Intended Audience :: Developers', |
181 | | - 'License :: OSI Approved :: Apache Software License', # 2.0 |
182 | | - 'Programming Language :: Python', |
183 | | - 'Programming Language :: Python :: 2', |
184 | | - 'Programming Language :: Python :: 2.7', |
185 | | - 'Programming Language :: Python :: 3', |
186 | | - 'Programming Language :: Python :: 3.3', |
187 | | - 'Programming Language :: Python :: 3.4', |
188 | | - 'Programming Language :: Python :: 3.5', |
189 | | - 'Programming Language :: Python :: 3.6', |
190 | | - 'Programming Language :: Python :: Implementation :: CPython', |
191 | | - #'Programming Language :: Python :: Implementation :: PyPy', |
192 | | - 'Operating System :: POSIX :: Linux', |
193 | | - 'Operating System :: Microsoft :: Windows', |
194 | | - 'Topic :: Software Development :: Libraries', |
195 | | - 'Topic :: System :: Monitoring' |
196 | | - ]) |
| 185 | +def main(): |
| 186 | + setup( |
| 187 | + packages=find_packages('src'), |
| 188 | + package_dir={'': 'src'}, |
| 189 | + include_package_data=True, |
| 190 | + zip_safe=True, |
| 191 | + python_requires='>=2.7,!=3.0,!=3.1,!=3.2,!=3.3', |
| 192 | + cmdclass=cmdclss, |
| 193 | + name='oneagent-sdk', |
| 194 | + version=__version__, |
| 195 | + distclass=BinaryDistribution, |
| 196 | + |
| 197 | + description='Dynatrace OneAgent SDK for Python', |
| 198 | + long_description=long_description, |
| 199 | + long_description_content_type='text/markdown', |
| 200 | + url='https://www.dynatrace.com/', |
| 201 | + maintainer='Dynatrace LLC', |
| 202 | + maintainer_email='dynatrace.oneagent.sdk@dynatrace.com', |
| 203 | + license='Apache License 2.0', |
| 204 | + classifiers=[ |
| 205 | + 'Development Status :: 2 - Pre-Alpha', |
| 206 | + 'Intended Audience :: Developers', |
| 207 | + 'License :: OSI Approved :: Apache Software License', # 2.0 |
| 208 | + 'Programming Language :: Python', |
| 209 | + 'Programming Language :: Python :: 2', |
| 210 | + 'Programming Language :: Python :: 2.7', |
| 211 | + 'Programming Language :: Python :: 3', |
| 212 | + 'Programming Language :: Python :: 3.3', |
| 213 | + 'Programming Language :: Python :: 3.4', |
| 214 | + 'Programming Language :: Python :: 3.5', |
| 215 | + 'Programming Language :: Python :: 3.6', |
| 216 | + 'Programming Language :: Python :: Implementation :: CPython', |
| 217 | + #'Programming Language :: Python :: Implementation :: PyPy', |
| 218 | + 'Operating System :: POSIX :: Linux', |
| 219 | + 'Operating System :: Microsoft :: Windows', |
| 220 | + 'Topic :: Software Development :: Libraries', |
| 221 | + 'Topic :: System :: Monitoring' |
| 222 | + ]) |
| 223 | + |
| 224 | +if __name__ == '__main__': |
| 225 | + main() |
0 commit comments