@@ -54,27 +54,27 @@ def system(cmd, msg=""):
54
54
55
55
56
56
def known_packages ():
57
- def PyYAML ():
58
- install_from_pypi ("PyYAML==3.13" )
57
+ def PyYAML (* args ):
58
+ install_from_pypi ("PyYAML==3.13" , args )
59
59
60
- def six ():
61
- install_from_pypi ("six==1.12.0" )
60
+ def six (* args ):
61
+ install_from_pypi ("six==1.12.0" , args )
62
62
63
- def Cython ():
64
- install_from_pypi ("Cython==0.29.2" , ['--no-cython-compile' ])
63
+ def Cython (* args ):
64
+ install_from_pypi ("Cython==0.29.2" , ['--no-cython-compile' ] + args )
65
65
66
- def setuptools ():
67
- install_from_pypi ("setuptools==40.6.3" )
66
+ def setuptools (* args ):
67
+ install_from_pypi ("setuptools==40.6.3" , args )
68
68
69
- def setuptools_scm ():
70
- install_from_url ("https://files.pythonhosted.org/packages/70/bc/f34b06274c1260c5e4842f789fb933a09b89f23549f282b36a15bdf63614/setuptools_scm-1.15.0rc1.tar.gz" )
69
+ def setuptools_scm (* args ):
70
+ install_from_url ("https://files.pythonhosted.org/packages/70/bc/f34b06274c1260c5e4842f789fb933a09b89f23549f282b36a15bdf63614/setuptools_scm-1.15.0rc1.tar.gz" , extra_opts = args )
71
71
72
- def numpy ():
72
+ def numpy (* args ):
73
73
try :
74
74
import setuptools as st
75
75
except ImportError :
76
76
print ("Installing required dependency: setuptools" )
77
- setuptools ()
77
+ setuptools (* args )
78
78
79
79
patch = """
80
80
diff --git a/setup.py 2018-02-28 17:03:26.000000000 +0100
@@ -308,51 +308,47 @@ def get_lapack_lite_sources(ext, build_dir):
308
308
2.14.1
309
309
310
310
"""
311
- install_from_url ("https://files.pythonhosted.org/packages/b0/2b/497c2bb7c660b2606d4a96e2035e92554429e139c6c71cdff67af66b58d2/numpy-1.14.3.zip" , patch = patch )
311
+ install_from_url ("https://files.pythonhosted.org/packages/b0/2b/497c2bb7c660b2606d4a96e2035e92554429e139c6c71cdff67af66b58d2/numpy-1.14.3.zip" , patch = patch , extra_opts = args )
312
312
313
313
314
- def dateutil ():
314
+ def dateutil (* args ):
315
315
try :
316
316
import setuptools_scm as st_scm
317
317
except ImportError :
318
318
print ("Installing required dependency: setuptools_scm" )
319
- setuptools_scm ()
320
- install_from_url ("https://files.pythonhosted.org/packages/0e/01/68747933e8d12263d41ce08119620d9a7e5eb72c876a3442257f74490da0/python-dateutil-2.7.5.tar.gz" )
319
+ setuptools_scm (* args )
320
+ install_from_url ("https://files.pythonhosted.org/packages/0e/01/68747933e8d12263d41ce08119620d9a7e5eb72c876a3442257f74490da0/python-dateutil-2.7.5.tar.gz" , extra_opts = args )
321
321
322
322
323
- def pytz ():
324
- install_from_url ("https://files.pythonhosted.org/packages/cd/71/ae99fc3df1b1c5267d37ef2c51b7d79c44ba8a5e37b48e3ca93b4d74d98b/pytz-2018.7.tar.gz" )
323
+ def pytz (* args ):
324
+ install_from_url ("https://files.pythonhosted.org/packages/cd/71/ae99fc3df1b1c5267d37ef2c51b7d79c44ba8a5e37b48e3ca93b4d74d98b/pytz-2018.7.tar.gz" , extra_opts = args )
325
325
326
326
327
- def six ():
328
- install_from_url ("https://files.pythonhosted.org/packages/dd/bf/4138e7bfb757de47d1f4b6994648ec67a51efe58fa907c1e11e350cddfca/six-1.12.0.tar.gz" )
329
-
330
-
331
- def pandas ():
327
+ def pandas (* args ):
332
328
try :
333
329
import numpy as np
334
330
except ImportError :
335
331
print ("Installing required dependency: numpy" )
336
- numpy ()
332
+ numpy (* args )
337
333
338
334
339
335
try :
340
336
import pytz as _dummy_pytz
341
337
except ImportError :
342
338
print ("Installing required dependency: pytz" )
343
- pytz ()
339
+ pytz (* args )
344
340
345
341
try :
346
342
import six as _dummy_six
347
343
except ImportError :
348
344
print ("Installing required dependency: six" )
349
- six ()
345
+ six (* args )
350
346
351
347
try :
352
348
import dateutil as __dummy_dateutil
353
349
except ImportError :
354
350
print ("Installing required dependency: dateutil" )
355
- dateutil ()
351
+ dateutil (* args )
356
352
357
353
# download pandas-0.20.3
358
354
patch = """diff --git a/pandas/_libs/src/period_helper.c b/pandas/_libs/src/period_helper.c
@@ -382,7 +378,7 @@ def pandas():
382
378
dinfo->abstime = (double)(hour * 3600 + minute * 60) + second;
383
379
384
380
"""
385
- install_from_url ("https://files.pythonhosted.org/packages/ee/aa/90c06f249cf4408fa75135ad0df7d64c09cf74c9870733862491ed5f3a50/pandas-0.20.3.tar.gz" , patch = patch )
381
+ install_from_url ("https://files.pythonhosted.org/packages/ee/aa/90c06f249cf4408fa75135ad0df7d64c09cf74c9870733862491ed5f3a50/pandas-0.20.3.tar.gz" , patch = patch , extra_opts = args )
386
382
387
383
return locals ()
388
384
@@ -395,7 +391,7 @@ def xit(msg, status=-1):
395
391
exit (- 1 )
396
392
397
393
398
- def install_from_url (url , patch = None ):
394
+ def install_from_url (url , patch = None , extra_opts = [] ):
399
395
name = url [url .rfind ("/" )+ 1 :]
400
396
tempdir = tempfile .mkdtemp ()
401
397
@@ -419,8 +415,11 @@ def install_from_url(url, patch=None):
419
415
with open ("%s/%s.patch" % (tempdir , bare_name ), "w" ) as f :
420
416
f .write (patch )
421
417
system ("patch -d %s/%s/ -p1 < %s/%s.patch" % ((tempdir , bare_name )* 2 ))
422
-
423
- system ("cd %s/%s; %s setup.py install --user" % (tempdir , bare_name , sys .executable ))
418
+
419
+ if "--prefix" in extra_opts :
420
+ system ("cd %s/%s; %s setup.py install %s" % (tempdir , bare_name , sys .executable , " " .join (extra_opts )))
421
+ else :
422
+ system ("cd %s/%s; %s setup.py install --user %s" % (tempdir , bare_name , sys .executable , " " .join (extra_opts )))
424
423
425
424
426
425
def install_from_pypi (package , extra_opts = []):
@@ -475,14 +474,19 @@ def main(argv):
475
474
help = "list locally installed packages"
476
475
)
477
476
478
- subparsers .add_parser (
477
+ install_parser = subparsers .add_parser (
479
478
"install" ,
480
479
help = "install a known package" ,
481
480
description = "Install a known package. Known packages are " + ", " .join (KNOWN_PACKAGES .keys ())
482
- ).add_argument (
481
+ )
482
+ install_parser .add_argument (
483
483
"package" ,
484
484
help = "comma-separated list"
485
485
)
486
+ install_parser .add_argument (
487
+ "--prefix" ,
488
+ help = "user-site path prefix"
489
+ )
486
490
487
491
subparsers .add_parser (
488
492
"uninstall" ,
@@ -534,7 +538,10 @@ def main(argv):
534
538
if pkg not in KNOWN_PACKAGES :
535
539
xit ("Unknown package: '%s'" % pkg )
536
540
else :
537
- KNOWN_PACKAGES [pkg ]()
541
+ if "prefix" in args :
542
+ KNOWN_PACKAGES [pkg ]("--prefix" , args .prefix )
543
+ else :
544
+ KNOWN_PACKAGES [pkg ]()
538
545
elif args .command == "pypi" :
539
546
for pkg in args .package .split ("," ):
540
547
install_from_pypi (pkg )
0 commit comments