Skip to content

Update example for pybind11 v2.2 #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ environment:
- PYTHON: 27
- PYTHON: 36
- CONDA: 27
- CONDA: 35
- CONDA: 36
install:
- cmd: '"%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" %PLATFORM%'
- ps: |
Expand Down
14 changes: 3 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
language: cpp
dist: trusty
matrix:
include:
- os: linux
Expand All @@ -8,24 +9,15 @@ matrix:
- os: linux
env: CONDA=2.7
- os: linux
env: CONDA=3.5
env: CONDA=3.6
- os: osx
env: PYTHON=2.7
- os: osx
env: PYTHON=3.6
- os: osx
env: CONDA=2.7
- os: osx
env: CONDA=3.5
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- deadsnakes
packages:
- g++-4.8
- python3.5
- python3.5-dev
env: CONDA=3.6
before_install:
- |
if [ "$TRAVIS_OS_NAME" = "linux" ]; then export CXX=g++-4.8 CC=gcc-4.8; fi
Expand Down
2 changes: 1 addition & 1 deletion conda.recipe/build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
unset MACOSX_DEPLOYMENT_TARGET
${PYTHON} setup.py install;

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def build_extensions(self):
description='A test project using pybind11',
long_description='',
ext_modules=ext_modules,
install_requires=['pybind11>=1.7'],
install_requires=['pybind11>=2.2'],
cmdclass={'build_ext': BuildExt},
zip_safe=False,
)
18 changes: 6 additions & 12 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@ int add(int i, int j) {
return i + j;
}

int subtract(int i, int j) {
return i - j;
}

namespace py = pybind11;

PYBIND11_PLUGIN(python_example) {
py::module m("python_example", R"pbdoc(
PYBIND11_MODULE(python_example, m) {
m.doc() = R"pbdoc(
Pybind11 example plugin
-----------------------

Expand All @@ -22,25 +18,23 @@ PYBIND11_PLUGIN(python_example) {

add
subtract
)pbdoc");
)pbdoc";

m.def("add", &add, R"pbdoc(
Add two numbers

Some other explanation about the add function.
)pbdoc");

m.def("subtract", &subtract, R"pbdoc(
m.def("subtract", [](int i, int j) { return i - j; }, R"pbdoc(
Subtract two numbers

Some other explanation about the subtract function.
)pbdoc");

#ifdef VERSION_INFO
m.attr("__version__") = py::str(VERSION_INFO);
m.attr("__version__") = VERSION_INFO;
#else
m.attr("__version__") = py::str("dev");
m.attr("__version__") = "dev";
#endif

return m.ptr();
}