@@ -57,21 +57,15 @@ def setuptools():
57
57
install_from_pypi ("setuptools" )
58
58
59
59
def numpy ():
60
+ # needs setuptools
61
+ setuptools ()
62
+
60
63
url = "https://files.pythonhosted.org/packages/b0/2b/497c2bb7c660b2606d4a96e2035e92554429e139c6c71cdff67af66b58d2/numpy-1.14.3.zip"
61
64
tempdir = tempfile .mkdtemp ()
62
65
system ("curl -o %s/numpy-1.14.3.zip %s" % (tempdir , url ))
63
66
system ("unzip -u %s/numpy-1.14.3.zip -d %s" % (tempdir , tempdir ))
64
67
65
68
patch = """
66
- From 1842b6b02557d824692a32bb623b8e74eb7989d3 Mon Sep 17 00:00:00 2001
67
- From: Tim Felgentreff <[email protected] >
68
- Date: Wed, 20 Jun 2018 18:01:30 +0200
69
- Subject: PATCH
70
-
71
- ---
72
- numpy/core/getlimits.py | 150 ++++++++++++++++++++++++------------------------
73
- 1 file changed, 75 insertions(+), 75 deletions(-)
74
-
75
69
diff --git a/setup.py 2018-02-28 17:03:26.000000000 +0100
76
70
index e450a66..ed538b4 100644
77
71
--- a/setup.py
@@ -321,8 +315,13 @@ def xit(str, status=-1):
321
315
322
316
323
317
def install_from_pypi (package ):
324
- url = None
325
- r = subprocess .check_output ("curl https://pypi.org/pypi/%s/json" % package , shell = True ).decode ("utf8" )
318
+ if "==" in package :
319
+ package , _ , version = package .rpartition ("==" )
320
+ url = "https://pypi.org/pypi/%s/%s/json" % (package , version )
321
+ else :
322
+ url = "https://pypi.org/pypi/%s/json" % (package , version )
323
+
324
+ r = subprocess .check_output ("curl %s" % url , shell = True ).decode ("utf8" )
326
325
try :
327
326
urls = json .loads (r )["urls" ]
328
327
except :
@@ -366,21 +365,41 @@ def install_from_pypi(package):
366
365
367
366
def main (argv ):
368
367
parser = argparse .ArgumentParser ()
369
- parser .add_argument ("--list" , action = "store_true" , help = "list known packages with potential workarounds available for installation" )
370
- parser .add_argument ("--install" , help = "install a known package" )
371
- parser .add_argument ("--pypi" , help = "attempt to install a package from PyPI (untested, likely won't work, it'll only try the latest version, and it won't install dependencies for you)" )
372
- args , _ = parser .parse_known_args (argv )
373
- if args .list :
374
- print (list (KNOWN_PACKAGES .keys ()))
375
- elif args .install :
376
- if args .install not in KNOWN_PACKAGES :
377
- xit ("Unknown package: '%s'" % args .install )
378
- else :
379
- KNOWN_PACKAGES [args .install ]()
380
- elif args .pypi :
381
- install_from_pypi (args .pypi )
368
+
369
+ subparsers = parser .add_subparsers (help = "Commands" , dest = "command" )
370
+
371
+ subparsers .add_parser (
372
+ "list" , help = "list known packages with potential workarounds available for installation"
373
+ )
374
+
375
+ subparsers .add_parser (
376
+ "install" , help = "install a known package"
377
+ ).add_argument (
378
+ "package" , help = "comma-separated list"
379
+ )
380
+
381
+ subparsers .add_parser (
382
+ "pypi" , help = "attempt to install a package from PyPI (untested, likely won't work, and it won't install dependencies for you)"
383
+ ).add_argument (
384
+ "package" , help = "comma-separated list, can use `==` at the end of a package name to specify an exact version"
385
+ )
386
+
387
+ args = parser .parse_args (argv )
388
+
389
+ if args .command == "list" :
390
+ print ("Known packages:" )
391
+ print ("\n " .join (" " + x for x in KNOWN_PACKAGES .keys ()))
392
+ elif args .command == "install" :
393
+ for pkg in args .package .split ("," ):
394
+ if pkg not in KNOWN_PACKAGES :
395
+ xit ("Unknown package: '%s'" % args .install )
396
+ else :
397
+ KNOWN_PACKAGES [args .install ]()
398
+ elif args .command == "pypi" :
399
+ for pkg in args .pypi .split ("," ):
400
+ install_from_pypi (pkg )
382
401
383
402
384
403
385
404
if __name__ == "__main__" :
386
- main (sys .argv )
405
+ main (sys .argv [ 1 :] )
0 commit comments