-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathpydeps.py
More file actions
executable file
·55 lines (51 loc) · 1.77 KB
/
pydeps.py
File metadata and controls
executable file
·55 lines (51 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python2.7
import os, sys, json, urllib2
from hashlib import sha256
deps = [line.rstrip('\n') for line in open(str(sys.argv[1]))]
for dep in deps:
version = None
if "==" in dep:
columns = dep.split("==")
dep = columns[0]
version = columns[1]
elif "<=" in dep:
columns = dep.split("<=")
dep = columns[0]
version = columns[1]
elif ">=" in dep:
columns = dep.split(">=")
dep = columns[0]
f = urllib2.urlopen("http://pypi.python.org/pypi/{}/json".format(dep))
j = json.load(f)
f.close()
print ' resource "{}" do'.format(dep)
if version:
for i in j['releases']:
if i == version:
for k in j['releases'][i]:
if k['packagetype'] == 'sdist':
url = k['url']
print ' url "{}"'.format(url)
f = urllib2.urlopen(url)
checksum = sha256(f.read()).hexdigest()
print ' sha256 "{}"'.format(checksum)
break
break
else:
for i in j['urls']:
if i['packagetype'] == 'sdist':
url = i['url']
print ' url "{}"'.format(url)
f = urllib2.urlopen(url)
checksum = sha256(f.read()).hexdigest()
print ' sha256 "{}"'.format(checksum)
break
print ' end'
print
print "===\n"
print ' ENV.prepend_create_path "PYTHONPATH", libexec/"vendor/lib/python2.7/site-packages"'
print ' %w[' + ' '.join(deps) + '].each do |r|'
print ' resource(r).stage do'
print ' system "python", *Language::Python.setup_install_args(libexec/"vendor")'
print ' end'
print ' end'