9
9
# it should be executed from tox with `{toxenvdir}/python` to ensure that the package
10
10
# can be successfully tested from within a tox environment.
11
11
12
- from subprocess import check_call
12
+ from subprocess import check_call , CalledProcessError
13
13
import argparse
14
14
import os
15
15
import logging
16
16
import sys
17
17
import glob
18
18
import shutil
19
- import pdb
20
19
from pkg_resources import parse_version
21
20
22
21
from tox_helper_tasks import find_whl , find_sdist , get_pip_list_output
23
22
from ci_tools .parsing import ParsedSetup , parse_require
24
23
from ci_tools .build import create_package
24
+ from ci_tools .functions import get_package_from_repo
25
25
26
26
logging .getLogger ().setLevel (logging .INFO )
27
27
28
28
from ci_tools .parsing import ParsedSetup
29
29
30
+
30
31
def cleanup_build_artifacts (build_folder ):
31
32
# clean up egginfo
32
33
results = glob .glob (os .path .join (build_folder , "*.egg-info" ))
@@ -170,7 +171,7 @@ def build_and_discover_package(setuppy_path, dist_dir, target_setup, package_typ
170
171
os .mkdir (tmp_dl_folder )
171
172
172
173
# preview version is enabled when installing dev build so pip will install dev build version from devpos feed
173
- if os .getenv ("SetDevVersion" , ' false' ) == ' true' :
174
+ if os .getenv ("SetDevVersion" , " false" ) == " true" :
174
175
commands_options .append ("--pre" )
175
176
176
177
if args .cache_dir :
@@ -197,7 +198,9 @@ def build_and_discover_package(setuppy_path, dist_dir, target_setup, package_typ
197
198
logging .info ("Installing {w} from fresh built package." .format (w = built_package ))
198
199
199
200
if not args .pre_download_disabled :
200
- requirements = ParsedSetup .from_path (os .path .join (os .path .abspath (args .target_setup ), "setup.py" )).requires
201
+ requirements = ParsedSetup .from_path (
202
+ os .path .join (os .path .abspath (args .target_setup ), "setup.py" )
203
+ ).requires
201
204
azure_requirements = [req .split (";" )[0 ] for req in requirements if req .startswith ("azure" )]
202
205
203
206
if azure_requirements :
@@ -238,19 +241,28 @@ def build_and_discover_package(setuppy_path, dist_dir, target_setup, package_typ
238
241
addition_necessary = False
239
242
240
243
if addition_necessary :
244
+ # we only want to add an additional rec for download if it actually exists
245
+ # in the upstream feed (either dev or pypi)
246
+ # if it doesn't, we should just install the relative dep if its an azure package
241
247
installation_additions .append (req )
242
248
243
249
if installation_additions :
244
- download_command .extend (installation_additions )
245
- download_command .extend (commands_options )
250
+ non_present_reqs = []
251
+ for addition in installation_additions :
252
+ try :
253
+ check_call (
254
+ download_command + [addition ] + commands_options ,
255
+ env = dict (os .environ , PIP_EXTRA_INDEX_URL = "" ),
256
+ )
257
+ except CalledProcessError as e :
258
+ req_name , req_specifier = parse_require (addition )
259
+ non_present_reqs .append (req_name )
246
260
247
- check_call (download_command , env = dict (os .environ , PIP_EXTRA_INDEX_URL = "" ))
248
261
additional_downloaded_reqs = [
249
262
os .path .abspath (os .path .join (tmp_dl_folder , pth )) for pth in os .listdir (tmp_dl_folder )
250
- ]
263
+ ] + [ get_package_from_repo ( relative_req ). folder for relative_req in non_present_reqs ]
251
264
252
265
commands = [sys .executable , "-m" , "pip" , "install" , built_pkg_path ]
253
-
254
266
commands .extend (additional_downloaded_reqs )
255
267
commands .extend (commands_options )
256
268
0 commit comments