diff --git a/setup.py b/setup.py index 87f6aa3..d707d22 100644 --- a/setup.py +++ b/setup.py @@ -13,9 +13,6 @@ __version__ = "0.0.1" -# Windows strips quotes -wrap = r'\"{}\"' if sys.platform.startswith("win") else '"{}"' - # The main interface is through Pybind11Extension. # * You can add cxx_std=11/14/17, and then build_ext can be removed. # * You can set include_pybind11=false to add the include directory yourself, @@ -29,7 +26,7 @@ Pybind11Extension("python_example", ["src/main.cpp"], # Example: passing in the version to the compiled code - define_macros = [('VERSION_INFO', wrap.format(__version__))], + define_macros = [('VERSION_INFO', __version__)], ), ] diff --git a/src/main.cpp b/src/main.cpp index 94d89a6..e341369 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,8 @@ #include +#define STRINGIFY(x) #x +#define MACRO_STRINGIFY(x) STRINGIFY(x) + int add(int i, int j) { return i + j; } @@ -33,7 +36,7 @@ PYBIND11_MODULE(python_example, m) { )pbdoc"); #ifdef VERSION_INFO - m.attr("__version__") = VERSION_INFO; + m.attr("__version__") = MACRO_STRINGIFY(VERSION_INFO); #else m.attr("__version__") = "dev"; #endif