Skip to content

Commit 9dcb4ba

Browse files
committed
slightly nicer installer
1 parent 489ae57 commit 9dcb4ba

File tree

2 files changed

+45
-26
lines changed

2 files changed

+45
-26
lines changed

graalpython/lib-graalpython/_sre.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ def findall(self, string, pos=0, endpos=-1):
319319
self.__check_input_type(string)
320320
if endpos > len(string):
321321
endpos = len(string)
322-
elif endpos < 0:
322+
elif endpos < 0 and len(string) > 0:
323323
endpos = endpos % len(string) + 1
324324
matchlist = []
325325
while pos < endpos:

graalpython/lib-graalpython/modules/gpip.py renamed to graalpython/lib-graalpython/modules/ginstall.py

Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,15 @@ def setuptools():
5757
install_from_pypi("setuptools")
5858

5959
def numpy():
60+
# needs setuptools
61+
setuptools()
62+
6063
url = "https://files.pythonhosted.org/packages/b0/2b/497c2bb7c660b2606d4a96e2035e92554429e139c6c71cdff67af66b58d2/numpy-1.14.3.zip"
6164
tempdir = tempfile.mkdtemp()
6265
system("curl -o %s/numpy-1.14.3.zip %s" % (tempdir, url))
6366
system("unzip -u %s/numpy-1.14.3.zip -d %s" % (tempdir, tempdir))
6467

6568
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-
7569
diff --git a/setup.py 2018-02-28 17:03:26.000000000 +0100
7670
index e450a66..ed538b4 100644
7771
--- a/setup.py
@@ -321,8 +315,13 @@ def xit(str, status=-1):
321315

322316

323317
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")
326325
try:
327326
urls = json.loads(r)["urls"]
328327
except:
@@ -366,21 +365,41 @@ def install_from_pypi(package):
366365

367366
def main(argv):
368367
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)
382401

383402

384403

385404
if __name__ == "__main__":
386-
main(sys.argv)
405+
main(sys.argv[1:])

0 commit comments

Comments
 (0)