Problems understanding proper build configuration

22 views
Skip to first unread message

Michael A

unread,
Aug 4, 2021, 12:10:31 PM8/4/21
to scikit-build
Hi all,

I could need some help understanding the build process with regards to the configuration of package_dir etc.

In my project (https://github.com/maichmueller/stratego) I have a mostly pure python package stratego, which I would like to augment via an internal _core CPP extension.

my structure for the package is the typical src layout:
src/
     stratego/
              __init__.py
             core
             subpackage2
             subpackage3
             ...

I am using the proposed pyproject.toml from the scikit-build docs to build the extension. Metadata is mostly held in a setup.cfg. This leads to my first question:
1) pip install seems to ignore the entries

[options]
package_dir=
=src
packages = find:
cmake_install_dir=src/stratego

in the setup.cfg. I specifically need to state them in the setup.py:

packages=find_packages(where="src"),
package_dir={"": "src"},
cmake_install_dir="src/stratego",

(not just cmake_install_dir is ignored in the setup cfg, in case this might be an unsupported entry). By `ignored`, I mean that the install fails if they are not specified in the setup.py, but in the setup cfg instead.

My other questions relate to the pip install process difference for editable and normal install. I have added the following line in my CMakeLists.txt:

install(TARGETS _core LIBRARY DESTINATION ./core)

This should install the _core library so as to be loaded by the submodule core at src/stratego/core/__init__.py: from _core import ...

2) The problem with this setup is: pip install -e .  never installs the library in the package path. It stays in the _skbuild folder and that's it. How should the install path be adjusted to ensure correct installation?

3) If I set packages=find_packages(where="src") then the normal install works and my package is installed via pip with all package files and the extension in the right folder. However, in this case the editable install fails as the egg-link points to ~/GitHubFolder/Stratego instead of ~/GitHubFolder/Stratego/src.
If I change the setup to packages=find_packages(), then the editable install points to the correct path (src) but the normal install fails. Can someone point out where I am going wrong with the package setup?

I hope my questions are somewhat understandable. I would appreciate the help, since I am hardstuck here at a proper setup for an extension within a python project. Thank you!

Michael
Reply all
Reply to author
Forward
0 new messages