Skip to content
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

fix: editable subpackage #895

Merged
merged 3 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
henryiii marked this conversation as resolved.
Show resolved Hide resolved
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")
henryiii marked this conversation as resolved.
Show resolved Hide resolved
else None,
)
return None

Expand Down
Loading