scikit-build / scikit-build-core

A next generation Python CMake adaptor and Python API for plugins
https://scikit-build-core.readthedocs.io
Apache License 2.0
242 stars 48 forks source link

Subpackages built but not installed #269

Closed gipert closed 1 year ago

gipert commented 1 year ago

Not sure if it's my fault, but with this MWE:

https://github.com/pyg4ometry/skbuild-core-mwe ,

a package consisting of two pybind11 subpackages, pip does not install anything after build, only $site_packages/pyg4ometry-0.0.1.dist-info/. The build is successful though, I can see libraries being created below /tmp.

With only one of the two subpackages, removing the intermediate subpackage directory, everything works as expected.

Anything wrong in my setup?

henryiii commented 1 year ago

There are two issues:

[tool.scikit-build]
wheel.packages = ["/src/pyg4ometry/pycgal", "/src/pyg4ometry/pyoce"]

I'm guessing that you had a __init__.py before in the "single" package, so it counted, but now as two separate packages, it doesn't. If you want the packages nested inside pyg4ometry, add a __init__.py in src/pyg4ometry. You can also manually list this in wheel.packages, but it should be auto-discovered then.

The mixed Python + C++ code might cause scikit-build-core to copy the C++ files into the Python package too; we don't have enough include/excludes yet probably for filtering that out, but should soon. It was initially designed to have C++ and Python separate.

gipert commented 1 year ago

CMake-created things need to be installed. The base install directory is $site_packages, so you'll usually need to install to your package name.

Oh, right. I somehow forgot that line. In the subpackage's CMakeLists.txt I now have

install(TARGETS ${modname} DESTINATION ${SKBUILD_PROJECT_NAME}/<subpackage>)

which should be the correct thing to do (?).

If you want Python files copied in by scikit-build-core (which is better than installing them via CMake, though you could do that too), you need to have a package with the same name as the project

Indeed this was my intention, the package and the CMake project have the same name.

I'm guessing that you had a __init__.py before in the "single" package, so it counted, but now as two separate packages, it doesn't.

Good catch -- fixed!

The mixed Python + C++ code might cause scikit-build-core to copy the C++ files into the Python package too; we don't have enough include/excludes yet probably for filtering that out, but should soon. It was initially designed to have C++ and Python separate.

Right, but this should be harmless, functionality wise?

Thanks a lot for helping!

henryiii commented 1 year ago

Right, but this should be harmless, functionality wise?

Yes, and eventually there should be a wheeel.exclude or something like that to clean up the output for this sort of pattern.