Browse Source

Merge pull request #13 from SylvainCorlay/__version__string

Set __version__ string
master
Sylvain Corlay 9 years ago committed by GitHub
parent
commit
28381e3f45
  1. 7
      setup.py
  2. 6
      src/main.cpp

7
setup.py

@ -3,6 +3,8 @@ from setuptools.command.build_ext import build_ext @@ -3,6 +3,8 @@ from setuptools.command.build_ext import build_ext
import sys
import setuptools
__version__ = '0.0.1'
class get_pybind_include(object):
"""Helper class to determine the pybind11 include path
@ -22,7 +24,7 @@ class get_pybind_include(object): @@ -22,7 +24,7 @@ class get_pybind_include(object):
ext_modules = [
Extension(
'python_example',
['py/main.cpp'],
['src/main.cpp'],
include_dirs=[
# Path to pybind11 headers
get_pybind_include(),
@ -76,6 +78,7 @@ class BuildExt(build_ext): @@ -76,6 +78,7 @@ class BuildExt(build_ext):
def build_extensions(self):
ct = self.compiler.compiler_type
opts = self.c_opts.get(ct, [])
opts.append('-DVERSION_INFO="%s"' % self.distribution.get_version())
if ct == 'unix':
opts.append(cpp_flag(self.compiler))
if has_flag(self.compiler, '-fvisibility=hidden'):
@ -86,7 +89,7 @@ class BuildExt(build_ext): @@ -86,7 +89,7 @@ class BuildExt(build_ext):
setup(
name='python_example',
version='0.0.1',
version=__version__,
author='Sylvain Corlay',
author_email='sylvain.corlay@gmail.com',
url='https://github.com/pybind/python_example',

6
py/main.cpp → src/main.cpp

@ -36,5 +36,11 @@ PYBIND11_PLUGIN(python_example) { @@ -36,5 +36,11 @@ PYBIND11_PLUGIN(python_example) {
Some other explanation about the subtract function.
)pbdoc");
#ifdef VERSION_INFO
m.attr("__version__") = py::str(VERSION_INFO);
#else
m.attr("__version__") = py::str("dev");
#endif
return m.ptr();
}
Loading…
Cancel
Save