Skip to content

Commit 294e50c

Browse files
authored
Improvements to setup.py (#78)
* Define PY_SSIZE_T_CLEAN * Add classifiers * Add __version__ module attribute * Add src to includes to allow package-absolute includes * Fix typo LD_PREALOAD and correct description
1 parent 589e4ff commit 294e50c

5 files changed

Lines changed: 35 additions & 5 deletions

File tree

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ find_package(Python REQUIRED COMPONENTS Interpreter Development)
1313
Python_add_library(scorep_bindings src/scorep.cpp)
1414
target_link_libraries(scorep_bindings PRIVATE Scorep::Scorep)
1515
target_compile_features(scorep_bindings PRIVATE cxx_std_11)
16+
target_compile_definitions(scorep_bindings PRIVATE PY_SSIZE_T_CLEAN)
17+
target_include_directories(scorep_bindings PRIVATE src)
18+
1619
set_target_properties(scorep_bindings PROPERTIES
1720
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/site-packages/scorep
1821
)

scorep/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
__all__ = ["user", "instrumenter"]
1+
__all__ = ["user", "instrumenter", "__version__"]
2+
from scorep._version import __version__

scorep/_version.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = "3.0"

setup.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
from distutils.core import setup, Extension
23
import scorep.helper
34

@@ -20,25 +21,45 @@
2021

2122
cmodules = []
2223
(include, _, _, _, _) = scorep.helper.generate_compile_deps()
24+
src_folder = os.path.abspath('src')
25+
include += [src_folder]
2326
cmodules.append(Extension('scorep.scorep_bindings',
2427
include_dirs=include,
25-
libraries=[],
28+
define_macros=[('PY_SSIZE_T_CLEAN', '1')],
2629
extra_compile_args=["-std=c++11"],
2730
sources=['src/scorep.cpp']))
2831

2932
setup(
3033
name='scorep',
31-
version='3.0',
34+
version=scorep._version.__version__,
3235
description='This is a scorep tracing package for python',
3336
author='Andreas Gocht',
3437
author_email='andreas.gocht@tu-dresden.de',
3538
url='https://github.com/score-p/scorep_binding_python',
3639
long_description='''
3740
This package allows tracing of python code using Score-P.
3841
A working Score-P version is required.
39-
For MPI tracing it uses LD_PREALOAD.
42+
To enable tracing it uses LD_PRELOAD to load the Score-P runtime libraries.
4043
Besides this, it uses the traditional python-tracing infrastructure.
4144
''',
4245
packages=['scorep', 'scorep.instrumenters'],
43-
ext_modules=cmodules
46+
ext_modules=cmodules,
47+
classifiers=[
48+
'Development Status :: 4 - Beta',
49+
'Environment :: Console',
50+
'Intended Audience :: Developers',
51+
'Topic :: Software Development :: Testing',
52+
'Topic :: Software Development :: Quality Assurance',
53+
'Programming Language :: Python :: 2',
54+
'Programming Language :: Python :: 2.7',
55+
'Programming Language :: Python :: 3',
56+
'Programming Language :: Python :: 3.4',
57+
'Programming Language :: Python :: 3.5',
58+
'Programming Language :: Python :: 3.6',
59+
'Programming Language :: Python :: 3.7',
60+
'Programming Language :: Python :: 3.8',
61+
'Programming Language :: Python :: Implementation :: CPython',
62+
'Operating System :: POSIX',
63+
'Operating System :: Unix',
64+
],
4465
)

test/test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ def setUp(self):
6060
ignore_errors=True)
6161
os.mkdir(self.env["SCOREP_EXPERIMENT_DIRECTORY"])
6262

63+
def test_has_version(self):
64+
import scorep
65+
self.assertIsNotNone(scorep.__version__)
66+
6367
def test_user_regions(self):
6468
env = self.env
6569
env["SCOREP_EXPERIMENT_DIRECTORY"] += "/test_user_regions"

0 commit comments

Comments
 (0)