8000 Merge pull request #13 from SylvainCorlay/__version__string · olirice/python_example@28381e3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 28381e3

Browse files
Merge pull request pybind#13 from SylvainCorlay/__version__string
Set __version__ string
2 parents 56849f6 + ab215a4 commit 28381e3

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

setup.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import sys
44
import setuptools
55

6+
__version__ = '0.0.1'
7+
68

79
class get_pybind_include(object):
810
"""Helper class to determine the pybind11 include path
@@ -22,7 +24,7 @@ def __str__(self):
2224
ext_modules = [
2325
Extension(
2426
'python_example',
25-
['py/main.cpp'],
27+
['src/main.cpp'],
2628
include_dirs=[
2729
# Path to pybind11 headers
2830
get_pybind_include(),
@@ -76,6 +78,7 @@ class BuildExt(build_ext):
7678
def build_extensions(self):
7779
ct = self.compiler.compiler_type
7880
opts = self.c_opts.get(ct, [])
81+
opts.append('-DVERSION_INFO="%s"' % self.distribution.get_version())
7982
if ct == 'unix':
8083
opts.append(cpp_flag(self.compiler))
8184
if has_flag(self.compiler, '-fvisibility=hidden'):
@@ -86,7 +89,7 @@ def build_extensions(self):
8689

8790
setup(
8891
name='python_example',
89-
version='0.0.1',
92+
version=__version__,
9093
author='Sylvain Corlay',
9194
author_email='sylvain.corlay@gmail.com',
9295
url='https://github.com/pybind/python_example',

py/main.cpp renamed to src/main.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,11 @@ PYBIND11_PLUGIN(python_example) {
3636
Some other explanation about the subtract function.
3737
)pbdoc");
3838

39+
#ifdef VERSION_INFO
40+
m.attr("__version__") = py::str(VERSION_INFO);
41+
#else
42+
m.attr("__version__") = py::str("dev");
43+
#endif
44+
3945
return m.ptr();
4046
}

0 commit comments

Comments
 (0)
0