Skip to content
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

Tests: try to add a test building a python module with pybind11 #43

Closed
GPMueller opened this issue May 6, 2018 · 3 comments · Fixed by #112
Closed

Tests: try to add a test building a python module with pybind11 #43

GPMueller opened this issue May 6, 2018 · 3 comments · Fixed by #112
Labels
tests Anything regarding tests

Comments

@GPMueller
Copy link
Contributor

This is a nontrivial problem and if our build system can manage it easily somehow it will be a good proof of concept.

@GPMueller GPMueller changed the title Try to add a test building a python module with pybind11 Tests: try to add a test building a python module with pybind11 Jun 27, 2018
@GPMueller
Copy link
Contributor Author

This is now being tried on feature-pybind-test (b3565c0).

@GPMueller
Copy link
Contributor Author

GPMueller commented Aug 21, 2019

The pybind11 test was removed again on PR #47 (same branch), because we could not figure out a missing strdup symbol.

@GPMueller GPMueller added the tests Anything regarding tests label May 5, 2020
@GPMueller
Copy link
Contributor Author

In order to get pybind11 to work properly within clang-build, we need to specify the following configuration parameters to targets:

"target_type":   "shared library",
"output_name":   "pylib",
"output_prefix": "",
"output_suffix": py_library_extension,
"include_directories": [py_include_dir],
"flags": {
    "link": [f'-L {py_library_dir}', f'-l{py_library_name}']
},

i.e. we need to add support for output_prefix and output_suffix.
Setting these parameters will then output something like pylib.cpython-37m-darwin.so, which can be imported with a simple import pylib. In this case, py_library_extension = sysconfig.get_config_var('EXT_SUFFIX') etc.

Since clang-build runs on Python, these variables are known intrinsically and we could add parameter blocks to our platform.py to make this sort of thing easier for users. E.g.:

PLATFORM_PYTHON_INCLUDE_PATH     = _Path(_get_paths()['include'])
PLATFORM_PYTHON_LIBRARY_PATH     = _Path(_get_paths()['data']) / "libs"
PLATFORM_PYTHON_LIBRARY_NAME     = f"python{_version_info.major}{_version_info.minor}"
PLATFORM_PYTHON_EXTENSION_SUFFIX = _get_config_var('EXT_SUFFIX')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Anything regarding tests
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant