@@ -373,11 +373,6 @@ def cycler(**kwargs):
373
373
def cppy (** kwargs ):
374
374
install_from_pypi ("cppy==1.1.0" , ** kwargs )
375
375
376
- @pip_package ()
377
- def kiwisolver (** kwargs ):
378
- cppy (** kwargs )
379
- install_from_pypi ("kiwisolver==1.3.1" , ** kwargs )
380
-
381
376
@pip_package ()
382
377
def cassowary (** kwargs ):
383
378
install_from_pypi ("cassowary==0.5.2" , ** kwargs )
@@ -393,12 +388,19 @@ def matplotlib(**kwargs):
393
388
setuptools (** kwargs )
394
389
certifi (** kwargs )
395
390
cycler (** kwargs )
396
- kiwisolver (** kwargs )
391
+ cassowary (** kwargs )
397
392
pyparsing (** kwargs )
398
393
dateutil (** kwargs )
399
394
numpy (** kwargs )
400
395
Pillow (** kwargs )
401
- install_from_pypi ("matplotlib==3.3.2" , ** kwargs )
396
+
397
+ def download_freetype (extracted_dir ):
398
+ target_dir = os .path .join (extracted_dir , "build" )
399
+ os .makedirs (target_dir , exist_ok = True )
400
+ package_pattern = os .environ .get ("GINSTALL_PACKAGE_PATTERN" , "https://sourceforge.net/projects/freetype/files/freetype2/2.6.1/%s.tar.gz" )
401
+ _download_with_curl_and_extract (target_dir , package_pattern % "freetype-2.6.1" )
402
+
403
+ install_from_pypi ("matplotlib==3.3.2" , pre_install_hook = download_freetype , ** kwargs )
402
404
403
405
return locals ()
404
406
@@ -411,46 +413,55 @@ def xit(msg, status=-1):
411
413
exit (- 1 )
412
414
413
415
414
- def _install_from_url ( url , package , extra_opts = [], add_cflags = "" , ignore_errors = False , env = {}, version = None ):
416
+ def _download_with_curl_and_extract ( dest_dir , url ):
415
417
name = url [url .rfind ("/" )+ 1 :]
416
- tempdir = tempfile .mkdtemp ()
417
418
418
- # honor env var 'HTTP_PROXY' and 'HTTPS_PROXY'
419
- os_env = os .environ
420
- curl_opts = []
421
- if url .startswith ("http://" ) and "HTTP_PROXY" in os_env :
422
- curl_opts += ["--proxy" , os_env ["HTTP_PROXY" ]]
423
- elif url .startswith ("https://" ) and "HTTPS_PROXY" in os_env :
424
- curl_opts += ["--proxy" , os_env ["HTTPS_PROXY" ]]
419
+ downloaded_path = os .path .join (dest_dir , name )
425
420
426
- # honor env var 'CFLAGS' and the explicitly passed env
427
- setup_env = os_env .copy ()
428
- setup_env .update (env )
429
- cflags = os_env .get ("CFLAGS" , "" ) + ((" " + add_cflags ) if add_cflags else "" )
430
- setup_env ['CFLAGS' ] = cflags if cflags else ""
431
-
432
- if run_cmd (["curl" , "-L" , "-o" , os .path .join (tempdir , name ), url ], failOnError = False ) != 0 :
433
- # honor env var 'HTTP_PROXY' and 'HTTPS_PROXY'
421
+ # first try direct connection
422
+ if run_cmd (["curl" , "-L" , "-o" , downloaded_path , url ], failOnError = False ) != 0 :
423
+ # honor env var 'HTTP_PROXY', 'HTTPS_PROXY', and 'NO_PROXY'
434
424
env = os .environ
435
425
curl_opts = []
426
+ using_proxy = False
436
427
if url .startswith ("http://" ) and "HTTP_PROXY" in env :
437
428
curl_opts += ["--proxy" , env ["HTTP_PROXY" ]]
429
+ using_proxy = True
438
430
elif url .startswith ("https://" ) and "HTTPS_PROXY" in env :
439
431
curl_opts += ["--proxy" , env ["HTTPS_PROXY" ]]
440
- run_cmd (["curl" , "-L" ] + curl_opts + ["-o" , os .path .join (tempdir , name ), url ], msg = "Download error" )
432
+ using_proxy = True
433
+ if using_proxy and "NO_PROXY" in env :
434
+ curl_opts += ["--noproxy" , env ["NO_PROXY" ]]
435
+ run_cmd (["curl" , "-L" ] + curl_opts + ["-o" , downloaded_path , url ], msg = "Download error" )
441
436
442
437
if name .endswith (".tar.gz" ):
443
- run_cmd (["tar" , "xzf" , os . path . join ( tempdir , name ), "-C" , tempdir ], msg = "Error extracting tar.gz" )
438
+ run_cmd (["tar" , "xzf" , downloaded_path , "-C" , dest_dir ], msg = "Error extracting tar.gz" )
444
439
bare_name = name [:- len (".tar.gz" )]
445
440
elif name .endswith (".tar.bz2" ):
446
- run_cmd (["tar" , "xjf" , os . path . join ( tempdir , name ), "-C" , tempdir ], msg = "Error extracting tar.bz2" )
441
+ run_cmd (["tar" , "xjf" , downloaded_path , "-C" , dest_dir ], msg = "Error extracting tar.bz2" )
447
442
bare_name = name [:- len (".tar.bz2" )]
448
443
elif name .endswith (".zip" ):
449
- run_cmd (["unzip" , "-u" , os . path . join ( tempdir , name ), "-d" , tempdir ], msg = "Error extracting zip" )
444
+ run_cmd (["unzip" , "-u" , downloaded_path , "-d" , dest_dir ], msg = "Error extracting zip" )
450
445
bare_name = name [:- len (".zip" )]
451
446
else :
452
447
xit ("Unknown file type: %s" % name )
453
448
449
+ return bare_name
450
+
451
+
452
+ def _install_from_url (url , package , extra_opts = [], add_cflags = "" , ignore_errors = False , env = {}, version = None , pre_install_hook = None ):
453
+ tempdir = tempfile .mkdtemp ()
454
+
455
+ os_env = os .environ
456
+
457
+ # honor env var 'CFLAGS' and the explicitly passed env
458
+ setup_env = os_env .copy ()
459
+ setup_env .update (env )
460
+ cflags = os_env .get ("CFLAGS" , "" ) + ((" " + add_cflags ) if add_cflags else "" )
461
+ setup_env ['CFLAGS' ] = cflags if cflags else ""
462
+
463
+ bare_name = _download_with_curl_and_extract (tempdir , url )
464
+
454
465
file_realpath = os .path .dirname (os .path .realpath (__file__ ))
455
466
patches_dir = os .path .join (Path (file_realpath ).parent , 'patches' , package )
456
467
# empty match group to have the same groups range as in pip_hook
@@ -469,6 +480,9 @@ def _install_from_url(url, package, extra_opts=[], add_cflags="", ignore_errors=
469
480
os .path .join (tempdir , bare_name , subdir )
470
481
run_cmd (["patch" , "-d" , os .path .join (tempdir , bare_name , subdir ), "-p1" , "-i" , patch_file_path ])
471
482
483
+ if pre_install_hook :
484
+ pre_install_hook (os .path .join (tempdir , bare_name ))
485
+
472
486
if "--prefix" not in extra_opts and site .ENABLE_USER_SITE :
473
487
user_arg = ["--user" ]
474
488
else :
@@ -508,7 +522,7 @@ def read_first_existing(pkg_name, versions, dir, suffix):
508
522
509
523
# end of code duplicated in pip_hook.py
510
524
511
- def install_from_pypi (package , extra_opts = [], add_cflags = "" , ignore_errors = True , env = None ):
525
+ def install_from_pypi (package , extra_opts = [], add_cflags = "" , ignore_errors = True , env = None , pre_install_hook = None ):
512
526
package_pattern = os .environ .get ("GINSTALL_PACKAGE_PATTERN" , "https://pypi.org/pypi/%s/json" )
513
527
package_version_pattern = os .environ .get ("GINSTALL_PACKAGE_VERSION_PATTERN" , "https://pypi.org/pypi/%s/%s/json" )
514
528
@@ -547,7 +561,7 @@ def install_from_pypi(package, extra_opts=[], add_cflags="", ignore_errors=True,
547
561
548
562
if url :
549
563
_install_from_url (url , package = package , extra_opts = extra_opts , add_cflags = add_cflags ,
550
- ignore_errors = ignore_errors , env = env , version = version )
564
+ ignore_errors = ignore_errors , env = env , version = version , pre_install_hook = pre_install_hook )
551
565
else :
552
566
xit ("Package not found: '%s'" % package )
553
567
0 commit comments