Skip to content

Commit

Permalink
In PEP 660 mode, the pth must point to an absolute directory
Browse files Browse the repository at this point in the history
  • Loading branch information
sbidoul committed Oct 2, 2021
1 parent 9335bfb commit d68674b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion flit_core/flit_core/wheel.py
Expand Up @@ -148,7 +148,7 @@ def copy_module(self):

def add_pth(self):
with self._write_to_zip(self.module.name + ".pth") as f:
f.write(str(self.module.source_dir))
f.write(str(self.module.source_dir.resolve()))

def write_metadata(self):
log.info('Writing metadata files')
Expand Down
17 changes: 17 additions & 0 deletions tests/test_wheel.py
Expand Up @@ -36,6 +36,23 @@ def test_editable_wheel_module(copy_sample):
assert pth_path.read_text() == str(td)
assert_isdir(Path(unpacked, 'module1-0.1.dist-info'))

def test_editable_wheel_has_absolute_pth(copy_sample):
td = copy_sample('module1_toml')
oldcwd = os.getcwd()
os.chdir(str(td))
try:
make_wheel_in(Path('pyproject.toml'), Path('.'), editable=True)
whl_file = 'module1-0.1-py2.py3-none-any.whl'
assert_isfile(whl_file)
with unpack(whl_file) as unpacked:
pth_path = Path(unpacked, 'module1.pth')
assert_isfile(pth_path)
assert Path(pth_path.read_text()).is_absolute()
assert pth_path.read_text() == str(td.resolve())
assert_isdir(Path(unpacked, 'module1-0.1.dist-info'))
finally:
os.chdir(oldcwd)

def test_wheel_package(copy_sample):
td = copy_sample('package1')
make_wheel_in(td / 'pyproject.toml', td)
Expand Down

0 comments on commit d68674b

Please sign in to comment.