@@ -636,16 +636,25 @@ def _install_from_url(url, package, extra_opts=None, add_cflags="", ignore_error
636
636
build_cmd = user_build_cmd .split (" " )
637
637
638
638
bare_name = _download_with_curl_and_extract (tempdir , url , quiet = quiet )
639
+ extracted_dir = os .path .join (tempdir , bare_name , "" )
639
640
640
641
file_realpath = os .path .dirname (os .path .realpath (__file__ ))
641
642
patches_dir = os .path .join (Path (file_realpath ).parent , 'patches' , package )
642
643
# empty match group to have the same groups range as in pip_hook
643
644
# unlike with pip, the version number may not be available at all
644
645
versions = re .search ("()(\\ d+)?(.\\ d+)?(.\\ d+)?" , "" if version is None else version )
645
646
647
+ if "--no-autopatch" not in extra_opts :
648
+ # run autopatch_capi
649
+ spec = importlib .util .spec_from_file_location ("autopatch_capi" , os .path .join (file_realpath , "autopatch_capi.py" ))
650
+ autopatch_capi = importlib .util .module_from_spec (spec )
651
+ spec .loader .exec_module (autopatch_capi )
652
+ info ("auto-patching {}" , extracted_dir )
653
+ autopatch_capi .auto_patch_tree (extracted_dir )
654
+
646
655
patch_file_path = first_existing (package , versions , os .path .join (patches_dir , "sdist" ), ".patch" )
647
656
if patch_file_path :
648
- run_cmd (["patch" , "-d" , os . path . join ( tempdir , bare_name , "" ) , "-p1" , "-i" , patch_file_path ], quiet = quiet )
657
+ run_cmd (["patch" , "-d" , extracted_dir , "-p1" , "-i" , patch_file_path ], quiet = quiet )
649
658
650
659
whl_patches_dir = os .path .join (patches_dir , "whl" )
651
660
patch_file_path = first_existing (package , versions , whl_patches_dir , ".patch" )
@@ -816,6 +825,7 @@ def main(argv):
816
825
install_parser .add_argument ("--prefix" , help = "user-site path prefix" )
817
826
install_parser .add_argument ("--user" , action = 'store_true' , help = "install into user site" )
818
827
install_parser .add_argument ("--debug-build" , action = "store_true" , help = "Enable debug options when building" )
828
+ install_parser .add_argument ("--no-autopatch" , action = "store_true" , help = "Do not autopatch C extensions." )
819
829
820
830
uninstall_parser = subparsers .add_parser (
821
831
"uninstall" , help = "remove installation folder of a local package" , )
@@ -865,6 +875,8 @@ def main(argv):
865
875
extra_opts += ["--prefix" , args .prefix ]
866
876
if args .user :
867
877
extra_opts += ["--user" ]
878
+ if args .no_autopatch :
879
+ extra_opts += ["--no-autopatch" ]
868
880
869
881
for pkg in args .package .split ("," ):
870
882
if os .path .isfile (pkg ):
0 commit comments