-
-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #482 from dan-blanchard/fix-relative-to
Fix support for egg packages with files outside site-packages by using `pathlib.Path.relative_to(walk_up=True)`.
- Loading branch information
Showing
5 changed files
with
61 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import os | ||
import pathlib | ||
import sys | ||
import types | ||
|
||
|
||
def wrap(path): # pragma: no cover | ||
""" | ||
Workaround for https://github.com/python/cpython/issues/84538 | ||
to add backward compatibility for walk_up=True. | ||
An example affected package is dask-labextension, which uses | ||
jupyter-packaging to install JupyterLab javascript files outside | ||
of site-packages. | ||
""" | ||
|
||
def relative_to(root, *, walk_up=False): | ||
return pathlib.Path(os.path.relpath(path, root)) | ||
|
||
return types.SimpleNamespace(relative_to=relative_to) | ||
|
||
|
||
relative_fix = wrap if sys.version_info < (3, 12) else lambda x: x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
When reading installed files from an egg, use ``relative_to(walk_up=True)`` to honor files installed outside of the installation root. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters