Module Builds Without Attributes

Offen
#200 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
42/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Ruhig
Tech-Stack
cmake, python
Bereich
build-system

Rechercherichtung

Beginnen Sie mit CMakeLists.txt und den im Issue beschriebenen Installationsschritten. Reproduzieren Sie dann den Import und untersuchen Sie dir(scikit_build_example). Die gemeldete Lösung besteht darin, scikit_build_example._core zu importieren; bestätigen Sie daher, dass dies add und subtract bereitstellt, und bestimmen Sie, ob das Beispiel oder seine Anweisungen diese Verwendung klar machen sollte.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Following the instructions I am able to build and import the python module. However the module is missing all attributes (add, docs, subtract),

  1. Cloned the repo
  2. Open powershell v7.5.4 Run pip install ./scikit_build_example (pip version 26.0.1)
  3. Run python (version 3.14)
  4. import scikit_build_example
  5. scikit_build_example.add(1,2)
  6. receive error: AttributeError: module 'scikit_build_example' has no attribute 'add'

Theorized that it may have to do with how pybind11 is linked

  1. placed pybind11 in submodule scikit_build_example/extern/pybind11
  2. commented line 14 in CMakeLists.txt
  3. added line: "add_subdirectory(extern/pybind11)
  4. Open powershell run pip install ./scikit_build_example
    pip uninstalled scikit_build_example-0.0.1
    pip installed scikit_build_example-0.01
  5. Run python
    6.import scikit_build_example
  6. scikit_build_example.add(1,2)
  7. 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

nox_log.txt

Help would be appreciated in resolving this issue

*Edit: Solution

  1. 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
  2. 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']

Vorherrschende Sprache
Python
Sterne
147
Forks
39
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus pybind/scikit_build_example

Alle Issues in pybind/scikit_build_example

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.