Skip to content

Commit

Permalink
Render site dir to a string. Fixes #66.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Jan 5, 2023
1 parent 21f464b commit 6deb532
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
v10.0.3
=======

#66: Fixed regression in sitecustomize generation where pathlib
objects were being rendered.

v10.0.2
=======

Expand Down
12 changes: 9 additions & 3 deletions pip_run/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,21 @@
import pathlib


def inject_sitecustomize(target):
"""
def inject_sitecustomize(target: pathlib.Path):
r"""
Create a sitecustomize file in the target that will install
the target as a sitedir.
>>> tmp_path = getfixture('tmp_path')
>>> inject_sitecustomize(tmp_path)
>>> sc = tmp_path / 'sitecustomize.py'
>>> 'Path' not in sc.read_text()
True
"""
hook = textwrap.dedent(
f"""
import site
site.addsitedir({target!r})
site.addsitedir({os.fspath(target)!r})
"""
).lstrip()
target.joinpath('sitecustomize.py').write_text(hook)
Expand Down

0 comments on commit 6deb532

Please sign in to comment.