Skip to content

Commit

Permalink
fix: editable subpackage (#895)
Browse files Browse the repository at this point in the history
Proposed fix for
#893.

- **fix: nox + uv downstream improvements**
- **fix: editable subpackage issue**

---------

Signed-off-by: Henry Schreiner <[email protected]>
  • Loading branch information
henryiii committed Sep 10, 2024
1 parent 37daf61 commit ef43b65
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
14 changes: 3 additions & 11 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,7 @@ def downstream(session: nox.Session) -> None:

# If running in manylinux:
# docker run --rm -v $PWD:/sk -w /sk -t quay.io/pypa/manylinux2014_x86_64:latest \
# pipx run --system-site-packages nox -s downstream -- https://github.com/...
# (requires tomli, so allowing access to system-site-packages)

if sys.version_info < (3, 11):
import tomli as tomllib
else:
import tomllib
# pipx run nox -s downstream -- https://github.com/...

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

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

if args.editable:
session.install("-e.")
session.install("-e.", "--no-build-isolation")
else:
session.run(
"python",
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ version.source = "vcs"
build.hooks.vcs.version-file = "src/scikit_build_core/_version.py"


[tool.uv.pip]
reinstall-package = ["scikit-build-core"]


[tool.pytest.ini_options]
minversion = "7.0"
addopts = ["-rfEsX", "--strict-markers", "--strict-config"]
Expand Down
9 changes: 7 additions & 2 deletions src/scikit_build_core/resources/_editable_redirect.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,26 @@ def find_spec(
submodule_search_locations = list(self.submodule_search_locations[fullname])
else:
submodule_search_locations = None

if fullname in self.known_wheel_files:
redir = self.known_wheel_files[fullname]
if self.rebuild_flag:
self.rebuild()
return importlib.util.spec_from_file_location(
fullname,
os.path.join(self.dir, redir),
submodule_search_locations=submodule_search_locations,
submodule_search_locations=submodule_search_locations
if redir.endswith(("__init__.py", "__init__.pyc"))
else None,
)
if fullname in self.known_source_files:
redir = self.known_source_files[fullname]
return importlib.util.spec_from_file_location(
fullname,
redir,
submodule_search_locations=submodule_search_locations,
submodule_search_locations=submodule_search_locations
if redir.endswith(("__init__.py", "__init__.pyc"))
else None,
)
return None

Expand Down

0 comments on commit ef43b65

Please sign in to comment.