@@ -818,15 +818,14 @@ def _build_one_inside_env(self, req, output_dir, python_tag=None):
818
818
builder = self ._build_one_pep517
819
819
else :
820
820
builder = self ._build_one_legacy
821
- if builder (req , temp_dir .path , python_tag = python_tag ):
821
+ wheel_path = builder (req , temp_dir .path , python_tag = python_tag )
822
+ if wheel_path is not None :
823
+ wheel_name = os .path .basename (wheel_path )
824
+ dest_path = os .path .join (output_dir , wheel_name )
822
825
try :
823
- wheel_name = os .listdir (temp_dir .path )[0 ]
824
- wheel_path = os .path .join (output_dir , wheel_name )
825
- shutil .move (
826
- os .path .join (temp_dir .path , wheel_name ), wheel_path
827
- )
826
+ shutil .move (wheel_path , dest_path )
828
827
logger .info ('Stored in directory: %s' , output_dir )
829
- return wheel_path
828
+ return dest_path
830
829
except Exception :
831
830
pass
832
831
# Ignore return, we can't do anything else useful.
@@ -844,29 +843,39 @@ def _base_setup_args(self, req):
844
843
] + list (self .global_options )
845
844
846
845
def _build_one_pep517 (self , req , tempd , python_tag = None ):
846
+ """Build one InstallRequirement using the PEP 517 build process.
847
+
848
+ Returns path to wheel if successfully built. Otherwise, returns None.
849
+ """
847
850
assert req .metadata_directory is not None
848
851
try :
849
852
req .spin_message = 'Building wheel for %s (PEP 517)' % (req .name ,)
850
853
logger .debug ('Destination directory: %s' , tempd )
851
- wheelname = req .pep517_backend .build_wheel (
854
+ wheel_name = req .pep517_backend .build_wheel (
852
855
tempd ,
853
856
metadata_directory = req .metadata_directory
854
857
)
855
858
if python_tag :
856
859
# General PEP 517 backends don't necessarily support
857
860
# a "--python-tag" option, so we rename the wheel
858
861
# file directly.
859
- newname = replace_python_tag (wheelname , python_tag )
862
+ new_name = replace_python_tag (wheel_name , python_tag )
860
863
os .rename (
861
- os .path .join (tempd , wheelname ),
862
- os .path .join (tempd , newname )
864
+ os .path .join (tempd , wheel_name ),
865
+ os .path .join (tempd , new_name )
863
866
)
864
- return True
867
+ # Reassign to simplify the return at the end of function
868
+ wheel_name = new_name
865
869
except Exception :
866
870
logger .error ('Failed building wheel for %s' , req .name )
867
- return False
871
+ return None
872
+ return os .path .join (tempd , wheel_name )
868
873
869
874
def _build_one_legacy (self , req , tempd , python_tag = None ):
875
+ """Build one InstallRequirement using the "legacy" build process.
876
+
877
+ Returns path to wheel if successfully built. Otherwise, returns None.
878
+ """
870
879
base_args = self ._base_setup_args (req )
871
880
872
881
spin_message = 'Building wheel for %s (setup.py)' % (req .name ,)
@@ -881,11 +890,12 @@ def _build_one_legacy(self, req, tempd, python_tag=None):
881
890
try :
882
891
call_subprocess (wheel_args , cwd = req .setup_py_dir ,
883
892
show_stdout = False , spinner = spinner )
884
- return True
885
893
except Exception :
886
894
spinner .finish ("error" )
887
895
logger .error ('Failed building wheel for %s' , req .name )
888
- return False
896
+ return None
897
+ # listdir's return value is sorted to be deterministic
898
+ return os .path .join (tempd , sorted (os .listdir (tempd ))[0 ])
889
899
890
900
def _clean_one (self , req ):
891
901
base_args = self ._base_setup_args (req )
0 commit comments