scikit-build-core
scikit-build-core copied to clipboard
editable mode ignores build-dir and writes CMake files directly into source tree
When using editable.mode = "inplace" in pyproject.toml, the build-dir option seems to be ignored. Even if I specify:
[tool.scikit-build]
build-dir = "src/cpp/build"
CMake generates its intermediate files (e.g., CMakeFiles/, CMakeCache.txt) directly under src/cpp/, polluting the source directory.
I also tried to add "-Bbuild", but only few files are added into build, but some of them still in src/cpp
Can you help me fix this?
When using
editable.mode = "inplace"inpyproject.toml, thebuild-diroption seems to be ignored.
Yes, inplace editable mode means cmake -S {sourcedir} -B {sourcedir} like traditional autotools. It is arguably not a good option to default to use. Maybe you are expecting another mode that would point to the build-tree, that's a WIP, I will try to open a PR for it at most next week.
Thanks a lot! I use this mode because i put wrapper of torch operator in my python directory, so I have to install lib into it.
Another related question is now I use CMakeList manually set where lib should be installed:
# Install .so file to src/molnex/op for easier management
# This works for both editable and regular installs
get_filename_component(PROJECT_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../.." ABSOLUTE)
set(MOLNEX_OP_DIR "${PROJECT_ROOT}/src/molnex/op")
# Install the library to src/molnex/op
install(TARGETS ${LIBRARY}
DESTINATION ${MOLNEX_OP_DIR}
COMPONENT python_modules
)
# Also install to the standard location for wheel packaging
install(TARGETS ${LIBRARY}
DESTINATION ${SKBUILD_PLATLIB_DIR}/molnex/op
COMPONENT python_modules
)
I believe their should be some flags in skibuild to determine it automatically(check directory of lib and install the target)?
Thanks again for your kind help!
Thanks a lot! I use this mode because i put wrapper of torch operator in my python directory, so I have to install lib into it.
You mean installing directly into the source folder in the editable mode. That I don't think we would have clean ways to support. If you could use importlib.resources to navigate where the files would be, that should be better supported. Feedback on this approach will be much appreciated.
I believe their should be some flags in skibuild to determine it automatically(check directory of lib and install the target)?
Let's try first to design without relying on that. If all else fails SKBUILD_STATE can tell you when you are in editable mode, but it doesn't tell you which editable mode you are in. If you can use importlib.resources, that would be more future stable when we add other editable modes as well.
Sorry for late reply!
It sounds more reasonable. I have refactor code and seperate python binder with cpp code. I will have a try with importlib.resources, it's seems can determine the binary path.
Thanks for your suggestion!