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

14
.travis.yml

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
language: cpp
dist: trusty
matrix:
include:
- os: linux
@ -8,7 +9,7 @@ matrix: @@ -8,7 +9,7 @@ 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
@ -16,16 +17,7 @@ matrix: @@ -16,16 +17,7 @@ matrix:
- 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

2
conda.recipe/build.sh

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

2
setup.py

@ -98,7 +98,7 @@ setup( @@ -98,7 +98,7 @@ setup(
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
src/main.cpp

@ -4,14 +4,10 @@ int add(int i, int j) { @@ -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
-----------------------
@ -22,7 +18,7 @@ PYBIND11_PLUGIN(python_example) { @@ -22,7 +18,7 @@ PYBIND11_PLUGIN(python_example) {
add
subtract
)pbdoc");
)pbdoc";
m.def("add", &add, R"pbdoc(
Add two numbers
@ -30,17 +26,15 @@ PYBIND11_PLUGIN(python_example) { @@ -30,17 +26,15 @@ PYBIND11_PLUGIN(python_example) {
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();
}

Loading…
Cancel
Save