Skip to content

Commit 2ed5a68

Browse files
Merge pull request pybind#25 from dean0x7d/update
Update example for pybind11 v2.2
2 parents 6dfbb29 + b9c5a57 commit 2ed5a68

File tree

5 files changed

+12
-26
lines changed

5 files changed

+12
-26
lines changed

.appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ environment:
1111
- PYTHON: 27
1212
- PYTHON: 36
1313
- CONDA: 27
14-
- CONDA: 35
14+
- CONDA: 36
1515
install:
1616
- cmd: '"%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" %PLATFORM%'
1717
- ps: |

.travis.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
language: cpp
2+
dist: trusty
23
matrix:
34
include:
45
- os: linux
@@ -8,24 +9,15 @@ matrix:
89
- os: linux
910
env: CONDA=2.7
1011
- os: linux
11-
env: CONDA=3.5
12+
env: CONDA=3.6
1213
- os: osx
1314
env: PYTHON=2.7
1415
- os: osx
1516
env: PYTHON=3.6
1617
- os: osx
1718
env: CONDA=2.7
1819
- os: osx
19-
env: CONDA=3.5
20-
addons:
21-
apt:
22-
sources:
23-
- ubuntu-toolchain-r-test
24-
- deadsnakes
25-
packages:
26-
- g++-4.8
27-
- python3.5
28-
- python3.5-dev
20+
env: CONDA=3.6
2921
before_install:
3022
- |
3123
if [ "$TRAVIS_OS_NAME" = "linux" ]; then export CXX=g++-4.8 CC=gcc-4.8; fi

conda.recipe/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
2+
unset MACOSX_DEPLOYMENT_TARGET
23
${PYTHON} setup.py install;
3-

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def build_extensions(self):
9898
description='A test project using pybind11',
9999
long_description='',
100100
ext_modules=ext_modules,
101-
install_requires=['pybind11>=1.7'],
101+
install_requires=['pybind11>=2.2'],
102102
cmdclass={'build_ext': BuildExt},
103103
zip_safe=False,
104104
)

src/main.cpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,10 @@ int add(int i, int j) {
44
return i + j;
55
}
66

7-
int subtract(int i, int j) {
8-
return i - j;
9-
}
10-
117
namespace py = pybind11;
128

13-
PYBIND11_PLUGIN(python_example) {
14-
py::module m("python_example", R"pbdoc(
9+
PYBIND11_MODULE(python_example, m) {
10+
m.doc() = R"pbdoc(
1511
Pybind11 example plugin
1612
-----------------------
1713
@@ -22,25 +18,23 @@ PYBIND11_PLUGIN(python_example) {
2218
2319
add
2420
subtract
25-
)pbdoc");
21+
)pbdoc";
2622

2723
m.def("add", &add, R"pbdoc(
2824
Add two numbers
2925
3026
Some other explanation about the add function.
3127
)pbdoc");
3228

33-
m.def("subtract", &subtract, R"pbdoc(
29+
m.def("subtract", [](int i, int j) { return i - j; }, R"pbdoc(
3430
Subtract two numbers
3531
3632
Some other explanation about the subtract function.
3733
)pbdoc");
3834

3935
#ifdef VERSION_INFO
40-
m.attr("__version__") = py::str(VERSION_INFO);
36+
m.attr("__version__") = VERSION_INFO;
4137
#else
42-
m.attr("__version__") = py::str("dev");
38+
m.attr("__version__") = "dev";
4339
#endif
44-
45-
return m.ptr();
4640
}

0 commit comments

Comments
 (0)