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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
import json
from collections import OrderedDict
from urllib.request import urlopen
from pprint import pprint
ARCHITECTURE = [ 'linux-64', 'osx-64']
METAPACKAGES = [('stsci', '1.0.0'),
('stsci-data-analysis', '1.0.0'),
('stsci-hst', '1.0.0'),
('stsci-jwst', '1.0.0')]
REPODATA_URL='http://ssb.stsci.edu/astroconda/{arch}/repodata.json'
#REPODATA_URL='http://ssb.stsci.edu/conda-dev/{arch}/repodata.json'
MESSAGE = """
Packaging reference key:
::
[package]-[version]-[glob]_[build_number]
^Name ^Version ^ ^Conda package revision
|
npXXpyYY
^ ^
| |
| Compiled for Python version
|
Compiled for NumPY version
"""
def get_repodata(architecture):
""" Retrieves repository data but strips the info key (there's never anything there)
"""
url = REPODATA_URL.format(arch=architecture)
with urlopen(url) as response:
data = OrderedDict(json.loads(response.read().decode())['packages'])
return data
if __name__ == '__main__':
python_versions = dict(
py27='2.7',
py34='3.4',
py35='3.5'
)
with open('package_manifest.rst', 'w+') as pfile:
print('Packages', file=pfile)
print('========\n\n', file=pfile)
print('{0}\n\n'.format(MESSAGE), file=pfile)
repo_data = OrderedDict()
for arch in ARCHITECTURE:
repo_data[arch] = get_repodata(arch)
metapackages = []
for mpkg, mpkg_version in METAPACKAGES:
for key, value in repo_data[arch].items():
if mpkg == repo_data[arch][key]['name']:
if mpkg_version == repo_data[arch][key]['version']:
metapackages.append(('-'.join([value['name'], value['version']]), value['build'], value['depends']))
print('{arch} metapackages'.format(arch=arch), file=pfile)
print('------------------------\n\n', file=pfile)
metapackages = sorted(metapackages, key=lambda k: k[0])
for name, build, dependencies in metapackages:
print('- **{name} ({python})**\n'.format(name=name, python=build), file=pfile)
for pkg in dependencies:
print(' - {:<20s}\n'.format(pkg), file=pfile)
print('{arch} packages'.format(arch=arch), file=pfile)
print('------------------------\n\n', file=pfile)
_packages = sorted(repo_data[arch].values(), key=lambda k: k['name'])
packages = set(['-'.join([d['name'], d['version']]) for d in _packages])
for record in sorted(packages):
print('- {name}\n'.format(name=record, header='-' * len(record)), file=pfile)
|