Browse Source

Merge pull request #25 from dean0x7d/update

Update example for pybind11 v2.2
master
Sylvain Corlay 8 years ago committed by GitHub
parent
commit
2ed5a68759
  1. 2
      .appveyor.yml
  2. 14
      .travis.yml
  3. 2
      conda.recipe/build.sh
  4. 2
      setup.py
  5. 18
      src/main.cpp

2
.appveyor.yml

@ -11,7 +11,7 @@ environment:
- PYTHON: 27 - PYTHON: 27
- PYTHON: 36 - PYTHON: 36
- CONDA: 27 - CONDA: 27
- CONDA: 35 - CONDA: 36
install: install:
- cmd: '"%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" %PLATFORM%' - cmd: '"%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" %PLATFORM%'
- ps: | - ps: |

14
.travis.yml

@ -1,4 +1,5 @@
language: cpp language: cpp
dist: trusty
matrix: matrix:
include: include:
- os: linux - os: linux
@ -8,7 +9,7 @@ matrix:
- os: linux - os: linux
env: CONDA=2.7 env: CONDA=2.7
- os: linux - os: linux
env: CONDA=3.5 env: CONDA=3.6
- os: osx - os: osx
env: PYTHON=2.7 env: PYTHON=2.7
- os: osx - os: osx
@ -16,16 +17,7 @@ matrix:
- os: osx - os: osx
env: CONDA=2.7 env: CONDA=2.7
- os: osx - os: osx
env: CONDA=3.5 env: CONDA=3.6
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- deadsnakes
packages:
- g++-4.8
- python3.5
- python3.5-dev
before_install: before_install:
- | - |
if [ "$TRAVIS_OS_NAME" = "linux" ]; then export CXX=g++-4.8 CC=gcc-4.8; fi if [ "$TRAVIS_OS_NAME" = "linux" ]; then export CXX=g++-4.8 CC=gcc-4.8; fi

2
conda.recipe/build.sh

@ -1,3 +1,3 @@
#!/bin/bash #!/bin/bash
unset MACOSX_DEPLOYMENT_TARGET
${PYTHON} setup.py install; ${PYTHON} setup.py install;

2
setup.py

@ -98,7 +98,7 @@ setup(
description='A test project using pybind11', description='A test project using pybind11',
long_description='', long_description='',
ext_modules=ext_modules, ext_modules=ext_modules,
install_requires=['pybind11>=1.7'], install_requires=['pybind11>=2.2'],
cmdclass={'build_ext': BuildExt}, cmdclass={'build_ext': BuildExt},
zip_safe=False, zip_safe=False,
) )

18
src/main.cpp

@ -4,14 +4,10 @@ int add(int i, int j) {
return i + j; return i + j;
} }
int subtract(int i, int j) {
return i - j;
}
namespace py = pybind11; namespace py = pybind11;
PYBIND11_PLUGIN(python_example) { PYBIND11_MODULE(python_example, m) {
py::module m("python_example", R"pbdoc( m.doc() = R"pbdoc(
Pybind11 example plugin Pybind11 example plugin
----------------------- -----------------------
@ -22,7 +18,7 @@ PYBIND11_PLUGIN(python_example) {
add add
subtract subtract
)pbdoc"); )pbdoc";
m.def("add", &add, R"pbdoc( m.def("add", &add, R"pbdoc(
Add two numbers Add two numbers
@ -30,17 +26,15 @@ PYBIND11_PLUGIN(python_example) {
Some other explanation about the add function. Some other explanation about the add function.
)pbdoc"); )pbdoc");
m.def("subtract", &subtract, R"pbdoc( m.def("subtract", [](int i, int j) { return i - j; }, R"pbdoc(
Subtract two numbers Subtract two numbers
Some other explanation about the subtract function. Some other explanation about the subtract function.
)pbdoc"); )pbdoc");
#ifdef VERSION_INFO #ifdef VERSION_INFO
m.attr("__version__") = py::str(VERSION_INFO); m.attr("__version__") = VERSION_INFO;
#else #else
m.attr("__version__") = py::str("dev"); m.attr("__version__") = "dev";
#endif #endif
return m.ptr();
} }

Loading…
Cancel
Save