@@ -47,14 +47,18 @@ def get_author_list():
47
47
return sorted (authors , key = lambda x : x .lower ())
48
48
49
49
50
- def protected_pip ( * arguments ):
51
- """Get arguments for session.run, that use a "protected" pip.
50
+ def run_with_protected_pip ( session , * arguments ):
51
+ """Do a session.run("pip", *arguments), using a "protected" pip.
52
52
53
53
This invokes a wrapper script, that forwards calls to original virtualenv
54
54
(stable) version, and not the code being tested. This ensures pip being
55
55
used is not the code being tested.
56
56
"""
57
- return ("python" , LOCATIONS ["protected-pip" ]) + arguments
57
+ env = {"VIRTUAL_ENV" : session .virtualenv .location }
58
+
59
+ command = ("python" , LOCATIONS ["protected-pip" ]) + arguments
60
+ kwargs = {"env" : env , "silent" : True }
61
+ session .run (* command , ** kwargs )
58
62
59
63
60
64
def should_update_common_wheels ():
@@ -84,15 +88,35 @@ def should_update_common_wheels():
84
88
def test (session ):
85
89
# Get the common wheels.
86
90
if should_update_common_wheels ():
87
- session .run (* protected_pip (
91
+ run_with_protected_pip (
92
+ session ,
88
93
"wheel" ,
89
94
"-w" , LOCATIONS ["common-wheels" ],
90
95
"-r" , REQUIREMENTS ["common-wheels" ],
91
- ))
96
+ )
97
+ else :
98
+ msg = (
99
+ "Re-using existing common-wheels at {}."
100
+ .format (LOCATIONS ["common-wheels" ])
101
+ )
102
+ session .log (msg )
103
+
104
+ # Build source distribution
105
+ sdist_dir = os .path .join (session .virtualenv .location , "sdist" )
106
+ session .run (
107
+ "python" , "setup.py" , "sdist" ,
108
+ "--formats=zip" , "--dist-dir" , sdist_dir ,
109
+ silent = True ,
110
+ )
111
+ generated_files = os .listdir (sdist_dir )
112
+ assert len (generated_files ) == 1
113
+ generated_sdist = os .path .join (sdist_dir , generated_files [0 ])
114
+
115
+ # Install source distribution
116
+ run_with_protected_pip (session , "install" , generated_sdist )
92
117
93
- # Install sources and dependencies
94
- session .run (* protected_pip ("install" , "." ))
95
- session .run (* protected_pip ("install" , "-r" , REQUIREMENTS ["tests" ]))
118
+ # Install test dependencies
119
+ run_with_protected_pip (session , "install" , "-r" , REQUIREMENTS ["tests" ])
96
120
97
121
# Parallelize tests as much as possible, by default.
98
122
arguments = session .posargs or ["-n" , "auto" ]
0 commit comments