Skip to content

Commit

Permalink
fix: use universal way of passing version
Browse files Browse the repository at this point in the history
  • Loading branch information
henryiii committed Sep 18, 2020
1 parent c06d5e0 commit ee6126f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 1 addition & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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__)],
),
]

Expand Down
5 changes: 4 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include <pybind11/pybind11.h>

#define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x)

int add(int i, int j) {
return i + j;
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ee6126f

Please sign in to comment.