File tree 2 files changed +44
-0
lines changed 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change 1
1
import contextlib
2
2
import sys
3
3
import shutil
4
+ import subprocess
4
5
5
6
import pytest
6
7
@@ -58,3 +59,16 @@ def workaround_xdist_376(request):
58
59
59
60
with contextlib .suppress (ValueError ):
60
61
sys .path .remove ('' )
62
+
63
+
64
+ @pytest .fixture
65
+ def sample_project (tmp_path ):
66
+ """
67
+ Clone the 'sampleproject' and return a path to it.
68
+ """
69
+ cmd = ['git' , 'clone' , 'https://github.com/pypa/sampleproject' ]
70
+ try :
71
+ subprocess .check_call (cmd , cwd = str (tmp_path ))
72
+ except Exception :
73
+ pytest .skip ("Unable to clone sampleproject" )
74
+ return tmp_path / 'sampleproject'
Original file line number Diff line number Diff line change 7
7
import io
8
8
import subprocess
9
9
import platform
10
+ import pathlib
10
11
11
12
from setuptools .command import test
12
13
@@ -199,3 +200,32 @@ def test_namespace_package_importable(self, tmpdir):
199
200
]
200
201
with test .test .paths_on_pythonpath ([str (target )]):
201
202
subprocess .check_call (pkg_resources_imp )
203
+
204
+ @pytest .mark .xfail (reason = "#2612" )
205
+ def test_editable_prefix (self , tmp_path , sample_project ):
206
+ """
207
+ Editable install to a prefix should be discoverable.
208
+ """
209
+ prefix = tmp_path / 'prefix'
210
+ prefix .mkdir ()
211
+
212
+ cmd = [
213
+ sys .executable ,
214
+ '-m' , 'pip' ,
215
+ 'install' ,
216
+ '-e' , str (sample_project ),
217
+ '--prefix' , str (prefix ),
218
+ ]
219
+ subprocess .check_call (cmd )
220
+
221
+ # now run 'sample' with the prefix on the PYTHONPATH
222
+ site_packages = prefix / next (
223
+ pathlib .Path (path ).relative_to (sys .prefix )
224
+ for path in sys .path
225
+ if 'site-packages' in path
226
+ and path .startswith (sys .prefix )
227
+ )
228
+ env = dict (PYTHONPATH = site_packages )
229
+ bin = 'Scripts' if platform .system () == 'Windows' else 'bin'
230
+ sample = prefix / bin / 'sample'
231
+ subprocess .check_call ([sample ], env = env )
You can’t perform that action at this time.
0 commit comments