Skip to content

Commit ef43b65

Browse files
authored
fix: editable subpackage (#895)
Proposed fix for #893. - **fix: nox + uv downstream improvements** - **fix: editable subpackage issue** --------- Signed-off-by: Henry Schreiner <[email protected]>
1 parent 37daf61 commit ef43b65

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

noxfile.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -230,13 +230,7 @@ def downstream(session: nox.Session) -> None:
230230

231231
# If running in manylinux:
232232
# docker run --rm -v $PWD:/sk -w /sk -t quay.io/pypa/manylinux2014_x86_64:latest \
233-
# pipx run --system-site-packages nox -s downstream -- https://github.com/...
234-
# (requires tomli, so allowing access to system-site-packages)
235-
236-
if sys.version_info < (3, 11):
237-
import tomli as tomllib
238-
else:
239-
import tomllib
233+
# pipx run nox -s downstream -- https://github.com/...
240234

241235
parser = argparse.ArgumentParser(prog=f"{Path(sys.argv[0]).name} -s downstream")
242236
parser.add_argument("project", help="A project to build")
@@ -270,9 +264,7 @@ def downstream(session: nox.Session) -> None:
270264
session.chdir(proj_dir)
271265

272266
# Read and strip requirements
273-
pyproject_toml = Path("pyproject.toml")
274-
with pyproject_toml.open("rb") as f:
275-
pyproject = tomllib.load(f)
267+
pyproject = nox.project.load_toml("pyproject.toml")
276268
requires = [
277269
x
278270
for x in pyproject["build-system"]["requires"]
@@ -289,7 +281,7 @@ def downstream(session: nox.Session) -> None:
289281
session.chdir(args.subdir)
290282

291283
if args.editable:
292-
session.install("-e.")
284+
session.install("-e.", "--no-build-isolation")
293285
else:
294286
session.run(
295287
"python",

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ version.source = "vcs"
126126
build.hooks.vcs.version-file = "src/scikit_build_core/_version.py"
127127

128128

129+
[tool.uv.pip]
130+
reinstall-package = ["scikit-build-core"]
131+
132+
129133
[tool.pytest.ini_options]
130134
minversion = "7.0"
131135
addopts = ["-rfEsX", "--strict-markers", "--strict-config"]

src/scikit_build_core/resources/_editable_redirect.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,21 +87,26 @@ def find_spec(
8787
submodule_search_locations = list(self.submodule_search_locations[fullname])
8888
else:
8989
submodule_search_locations = None
90+
9091
if fullname in self.known_wheel_files:
9192
redir = self.known_wheel_files[fullname]
9293
if self.rebuild_flag:
9394
self.rebuild()
9495
return importlib.util.spec_from_file_location(
9596
fullname,
9697
os.path.join(self.dir, redir),
97-
submodule_search_locations=submodule_search_locations,
98+
submodule_search_locations=submodule_search_locations
99+
if redir.endswith(("__init__.py", "__init__.pyc"))
100+
else None,
98101
)
99102
if fullname in self.known_source_files:
100103
redir = self.known_source_files[fullname]
101104
return importlib.util.spec_from_file_location(
102105
fullname,
103106
redir,
104-
submodule_search_locations=submodule_search_locations,
107+
submodule_search_locations=submodule_search_locations
108+
if redir.endswith(("__init__.py", "__init__.pyc"))
109+
else None,
105110
)
106111
return None
107112

0 commit comments

Comments
 (0)