Skip to content

Editable Install with cython extension and shared library for ctypes #1141

Description

@AndrewAnnex

I have a python project that includes a cython extension linked against a shared library I also interface to using ctypes in the same project, and I am trying to enable editable installs to allow for the conventional build_ext --inplace workflow that I've used to develop the package in the past, but I am running into odd behavior with the replace and inplace editable installation modes and likely my inexperience with cmake is making this difficult to reason about. I am aware of the number of related issues with editable installs, however after reading through a number of them I am still stuck on this.

It could be I am doing something nonstandard in my cmakelists.txt file, but so far what I have works for building installable wheels where all tests pass in my CI/CD with cibuildwheel and pipx.

link to my CMakeLists.txt
link to my pyproject.toml

In the end, I need both the cython extension (for my mac cyice.cpython-313-darwin.so) and the shared library (libcspice.dylib) to be installed in my project root folder rather than just site-packages. The expected paths for each would then be src/spiceypy/cyice/cyice.cpython-313-darwin.so and src/spiceypy/utils/libcspice.dylib

with redirect and pip install --no-build-isolation -ve .

Logs:

  *** Installing project into wheel...
  2025-09-04 09:37:08,639 - scikit_build_core - INFO - RUN: /opt/homebrew/bin/cmake --install build --prefix /var/folders/6r/0_ck04691rx1vj2x5knvq8s00000gn/T/tmpb0blklrg/wheel/platlib --strip
  -- Install configuration: "Release"
....
  -- Installing: /var/folders/6r/0_ck04691rx1vj2x5knvq8s00000gn/T/tmpb0blklrg/wheel/platlib/spiceypy/utils/cmake/cspice/cspiceTargets.cmake
  -- Installing: /var/folders/6r/0_ck04691rx1vj2x5knvq8s00000gn/T/tmpb0blklrg/wheel/platlib/spiceypy/utils/cmake/cspice/cspiceTargets-release.cmake
  -- Installing: /var/folders/6r/0_ck04691rx1vj2x5knvq8s00000gn/T/tmpb0blklrg/wheel/platlib/spiceypy/utils/cmake/cspice/cspiceConfig.cmake
  -- Installing: /var/folders/6r/0_ck04691rx1vj2x5knvq8s00000gn/T/tmpb0blklrg/wheel/platlib/spiceypy/utils/cmake/cspice/cspiceConfigVersion.cmake
  -- Installing: /var/folders/6r/0_ck04691rx1vj2x5knvq8s00000gn/T/tmpb0blklrg/wheel/platlib/spiceypy/utils/libcspice.dylib
  -- Installing: /var/folders/6r/0_ck04691rx1vj2x5knvq8s00000gn/T/tmpb0blklrg/wheel/platlib/spiceypy/cyice/cyice.cpython-313-darwin.so

but both the shared library and the cython extension are only found in my site-packages folder:

ls /Users/andrew/mambaforge/envs/spiceypydev_313/lib/python3.13/site-packages/spiceypy/utils                                        
libcspice.dylib
ls /Users/andrew/mambaforge/envs/spiceypydev_313/lib/python3.13/site-packages/spiceypy/cyice/                                      
cyice.cpython-313-darwin.so

with inplace and pip install --no-build-isolation -ve .

as build-dir is now ignored, a lot of build folder stuff is made in my project root folder, including the cython extension which is sitting at the root path instead of inside my src directory in src/spiceypy/cyice/ where i'd expect it to be. The shared library remains in _deps and doesn't get copied anywhere else.

  [2231/2235] Linking C shared library _deps/cspice-build/libcspice.dylib
  [2232/2235] Linking C executable _deps/cspice-build/test_cspice
  [2233/2235] Cythonizing /Users/andrew/PycharmProjects/SpiceyPy/src/spiceypy/cyice/cyice.pyx to /Users/andrew/PycharmProjects/SpiceyPy/spiceypy/cyice/cyice.c
  [2234/2235] Building C object CMakeFiles/cyice.dir/spiceypy/cyice/cyice.c.o
  [2235/2235] Linking C shared module cyice.cpython-313-darwin.so
  *** Making editable...

I am wondering if the cyice.dir is a clue here, as this causes a copy of cyice.c to be made outside of the src directory making a new folder at spiceypy/cyice relative to the project root.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions