pybind / pybind/scikit_build_example
Module Builds Without Attributes
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 148
- Forks
- 39
- Avg merge
- 8d 2h
- Merged PRs (30d)
- 1
Description
Following the instructions I am able to build and import the python module. However the module is missing all attributes (add, docs, subtract),
- Cloned the repo
- Open powershell v7.5.4 Run pip install ./scikit_build_example (pip version 26.0.1)
- Run python (version 3.14)
import scikit_build_examplescikit_build_example.add(1,2)- receive error: AttributeError: module 'scikit_build_example' has no attribute 'add'
Theorized that it may have to do with how pybind11 is linked
- placed pybind11 in submodule scikit_build_example/extern/pybind11
- commented line 14 in CMakeLists.txt
- added line: "add_subdirectory(extern/pybind11)
- Open powershell run
pip install ./scikit_build_example
pip uninstalled scikit_build_example-0.0.1
pip installed scikit_build_example-0.01 - Run python
6.import scikit_build_example scikit_build_example.add(1,2)- receive error: AttributeError: module 'scikit_build_example' has no attribute 'add'
For both cases the python dir(module) command output line
dir(scikit_build_example)
['doc', 'file', 'loader', 'name', 'package', 'path', 'spec']
Nox log has been attached
Help would be appreciated in resolving this issue
*Edit: Solution
- I have a python version with path name "python" and a different version with "py"
used the command python -m pip install, with python -m pip list to ensure the package existed in the correct version - Using the pip uninstall command the output:
*\python314\lib\site-packages\hello-0.0.1.dist-info*
*\python314\lib\site-packages\hello_core.cp314-win_amd64.pyd
gave me a clue that the attributes were being stored in a second location. Issue #63 contained the final clue to the naming convention to get access to the attributes
The automatically generated signatures of the class functions contain then something like packagename.modulename.classname
Therefore in order to get access to the defined attributes and follow the tutorial the import statement must be
import scikit_build_example._core
scikit_build_example._core.add(1,2)
'dir(scikit_build_example._core)'
['doc', 'file', 'loader', 'name', 'package', 'spec', 'version', 'add', 'subtract']
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with CMakeLists.txt and the installation steps in the issue, then reproduce the import and inspect dir(scikit_build_example). The reported resolution is to import scikit_build_example._core, so confirm that this exposes add and subtract and determine whether the example or its instructions should make that usage clear.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, python
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100