Giter Site home page Giter Site logo

bazel_pybind_sample's Introduction

Bazel / pybind11 sample

Simple, working pybind11-via-bazel example on Linux/x64 (tested on Ubuntu).

Background info provided by:

If you're observing segfaults, it may be that the DSO is being built for Python2 while the bazel test interpreter is Python 3.

You can observe what Python headers were used for building by observing the file in a path similar to:

bazel-out/k8-fastbuild/bin/external/local_config_python/python_include/patchlevel.h

And you can help point at the right Python binary by providing it to the python_configure.bzl script in pybind11_bazel through an environment variable:

PYTHON_BIN_PATH=/usr/bin/python3 bazel test -c dbg :example_test --test_output=all

bazel_pybind_sample's People

Contributors

cdleary avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

bazel_pybind_sample's Issues

symbol not found in flat namespace errors on Mac OSX

I have not been able to get this example to work on my computer. I am using an Apple M1 computer, and consistently get

Traceback (most recent call last): File "/private/var/tmp/_bazel_connie/f24ab60b302356e3037695b783d4e5e0/sandbox/darwin-sandbox/74/execroot/__main__/bazel-out/darwin_arm64-dbg/bin/example_test.runfiles/__main__/example_test.py", line 9, in <module> import my_pb_mod ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/my_pb_mod-1.0.1-py3.10-macosx-10.9-universal2.egg/my_pb_mod.cpython-310-darwin.so, 0x0002): symbol not found in flat namespace '_PyInt_FromSsize_t'

I have been able to install it through g++ with the following command:
g++ -O3 -Wall -shared -std=c++17 -undefined dynamic_lookup $(python3 -m pybind11 --includes) my_pb_mod.cc -o example $(python3-config --extension-suffix), but I have not been able to install it through Bazel.

I thought it might be a seg fault issue with the dynamic library, but I ran the troubleshooting environmental variable PYTHON_BIN_PATH with Python 2.7 and 3.8, both result in the same error.

Has anyone fixed the issue with the symbol not found in flat namespace?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.