-
Notifications
You must be signed in to change notification settings - Fork 72
Editable Inplace Builds Respect build-dir
#1160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Thanks, I had a branch working on this on the side, but if someone else can work on this, it will help get this in much faster. I will give a quick review to discuss the design aspect that we would want to have for this. |
docs/reference/configs.md
Outdated
Build directory to use when ``editable.mode`` is ``"inplace"``. If empty, the project | ||
source directory is used. | ||
```` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to edit these files, use nox -t gen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made some changes
build_dir: str = "" | ||
""" | ||
Build directory to use when :confval:`editable.mode` is ``inplace``. | ||
If empty, the project source directory is used (the historical behaviour). | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I can read from your description is you want something like editable.mode = redirect
but to fully reuse the build directory right? In that case what we need to do is create a different editable mode, because:
inplace
mode is explicitly to have thesource-dir
be exactly the same asbuild-dir
redirect
mode reuses thebuild-dir
, but also rebuilds and re-installs each timenew
mode (name TBD) reuses thebuild-dir
completely and just points the redirect files to thebuild-dir
values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood, but with setuptools, build_ext --inplace still drops the artifacts inside the build directory, and I honestly can’t think of a scenario where someone would expect inplace to dump products directly into the source tree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each build backend would have their own approach. Here in scikit-build-core
the focus is on the CMake workflows and trying to make it close to a vanilla CMake workflow that you would have for debugging a non-python project.
The editable modes are a way to bridge those gaps, and unfortunately this depends more on the source code than the good designs. inplace
is very much a last-resort option that we must have in order to help some projects that do not use modern designs using importlib.resources
, otherwise the redirect
(and a future replacement) is the preferred workflow.
I can succesfully reach my goal via |
1af7eca
to
7e5e7e6
Compare
But this is not what we would want to have. |
@LecrisUT I see your point. Would the plan be to extend redirect with a switch that skips the wheel staging altogether? That sounds like a much larger patch. And, I can not understand the usage of |
Anyway, I’m happy to rework the implementation along the lines you’ve suggested—my main goal is just to land an update quickly so we can get our development workflow unblocked. |
Yes, and indeed it is not a quick drive-by patch for this, but we can assist you all-throughout the process if anyone wants to pick up the mantle for that.
What is wrong with
It will reuse the previous build directory and if all of the cmake dependencies are picked from the system, a CMake re-configure step should not be done (if it is, please try to hunt down what causes it, it's mostly a project configuration issue) |
@LecrisUT Thanks, that works for me as long as we enable |
This issue pops up regularly in the issues, most simple example of this is in usage of |
But one thing I have to complain about is that the editable build ( > pip install -e . --no-build-isolation
> ls somepath/python3.12/site-packages/tilelang
3rdparty lib As a result, sometimes when I run a program, it works fine: > python
Python 3.12.9 | packaged by Anaconda, Inc. | (main, Feb 6 2025, 18:56:27) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tilelang
>>> tilelang.__path__
['local_dir/tilelang/tilelang'] But other times, it fails to locate the right path — even when I explicitly set # test_files.py
import tilelang
print(tilelang.__path__)
from tilelang import language as T > python test_files.py
> _NamespacePath(['somepath/python3.12/site-packages/tilelang']) Then it throws:
because that directory only contains |
We do sometimes want pure |
We are well aware of the CMake good practices and we often discuss those in the issues. The from pathlib import Path
DIR = Path(__file__).parent
SOME_DATA = DIR / "resources/data.csv" The modern approach around this is to use
There is, because the If you do not use such constructs, do not set the editable mode to
Yes, this is the unfortunate limitation with the If you are interested in the detailsBasically we have the
The resolutions of We are aware that |
The new mode is super important for us. |
I will try to carve some time this weekend to publish the WIP that I have. Please check back on me, if I don't do any updates. |
Background
setuptools
toscikit-build-core
. With setuptools we could runpython setup.py build_ext --inplace
, rebuild C++ extensions in seconds, and keep artifacts out of site-packages.pip install -e .
with scikit-build-core currently produces a wheel, which slows down rebuilds, and drops editable binaries into the environment’ssite-packages
directory, which pollutes the environment.mode = "inplace"
avoids site-packages, but it ignoresbuild-dir
and writes artifacts directly into the project root, making the tree noisy.What this PR changes
[tool.scikit-build.editable].build-dir
option that is honored wheneditable.mode = "inplace"
, letting us keep a dedicated build tree (e.g.build/{wheel_tag}/editable
) without resorting to site-packages or the project root.build-dir
expansion.SKBUILD_EDITABLE_MODE
,SKBUILD_EDITABLE_BUILD_DIR
) so CMake projects can detect the setting.simplest_c
CMake project to honor the new cache entries and keep its module output inside the source tree when an external build directory is used.Remaining follow-ups
SKBUILD_EDITABLE_*
handling in the other editable fixture projects (tests/packages/navigate_editable
,tests/packages/cython_pxd_editable/pkg{1,2}
, andtests/packages/importlib_editable/**/CMakeLists.txt
) so every sample keeps extension artifacts in the source layout wheneditable.build-dir
is set.docs/configuration/index.md
) showing how projects can detectSKBUILD_EDITABLE_BUILD_DIR
and route outputs correctly.pytest -k editable
) to confirm there are no regressions.