Skip to content

Editable Mode install rebuilds don't update *.so in site-packages #1135

@RisinT96

Description

@RisinT96

Hi,

Unfortunately, I can't share my project, however here's the main details:

Configured cmake to install my built .so into ${SKBUILD_PLATLIB_DIR}/project/lib:

install(
    TARGETS
        bindings
    DESTINATION
        ${SKBUILD_PLATLIB_DIR}/project/lib/
)

When installing a package using pip install -v --no-build-isolation -e . I can see that cmake is installing the .so into the correct path:

  -- Installing: /tmp/tmpl60cdmsu/wheel/platlib/project/lib/bindings.cpython-312-x86_64-linux-gnu.so

Inspecting site-packages the .so is present:

> ls -lh .venv/lib/python3.12/site-packages/project/lib
-rw-r--r-- 1 user user  77K Aug 20 08:52 bindings.cpython-312-x86_64-linux-gnu.so

When importing the package, the .so is rebuilt:

> python -c "import project"
Running cmake --build & --install in /workspace/project/build
[0/2] Re-checking globbed directories...
ninja: no work to do.
-- Install configuration: "Release"
-- Installing: /tmp/tmpl60cdmsu/wheel/platlib/project/lib/bindings.cpython-312-x86_64-linux-gnu.so

(also tested where code changes were made an rebuild was actually necessary, got same behavior)

This only updates the .so in the temp dir, but doesn't update it in site-packages (see timestamp):

> ls -lh /tmp/tmpl60cdmsu/wheel/platlib/project/lib/
-rw-r--r-- 1 user user  77K Aug 20 09:02 bindings.cpython-312-x86_64-linux-gnu.so

> ls -lh .venv/lib/python3.12/site-packages/project/lib
-rw-r--r-- 1 user user  77K Aug 20 08:52 bindings.cpython-312-x86_64-linux-gnu.so

The running code is reusing the old shared object so any changes don't take effect.

I also tried installing locally (in addition to platlib):

install(
    TARGETS
        bindings
    DESTINATION
        ${CMAKE_CURRENT_SOURCE_DIR}/project/lib/
)

This will place the .so both in site-packages and in the local lib directory.

The local .so is updated on rebuild, however depending on environment and runpath, sometimes python picks up the local .so, and sometimes from site-packages.

This is unstable and so not very usable.

I also tried detecting editable installs by checking SKBUILD_STATE, and then installing only locally, but this prevents rebuilds on import.

Is this behavior expected, or am I missing something?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions