forked from British-Oceanographic-Data-Centre/COAsT
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoast_metadata.py
More file actions
74 lines (60 loc) · 2.19 KB
/
Copy pathcoast_metadata.py
File metadata and controls
74 lines (60 loc) · 2.19 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
def get_package(package_path="package.json"):
from types import SimpleNamespace
import json
with open(package_path, "r") as package_file:
package = json.load(package_file)
return SimpleNamespace(**package)
def represent_ordered_dict(dumper, data):
import yaml
value = []
for item_key, item_value in data.items():
node_key = dumper.represent_data(item_key)
node_value = dumper.represent_data(item_value)
value.append((node_key, node_value))
return yaml.nodes.MappingNode(u'tag:yaml.org,2002:map', value)
def generate_conda(directory="conda"):
import yaml
from os import path
from collections import OrderedDict
yaml.add_representer(OrderedDict, represent_ordered_dict)
package = get_package()
package_metadata = OrderedDict({
"package": {
"name": package.name.lower(),
"version": package.version
},
"source": {
"url": f"https://pypi.io/packages/source/{package.name[0]}/{package.name}/{package.name}-{package.version}.tar.gz"
},
"build": {
"number": 0,
"script": "pip install https://files.pythonhosted.org/packages/83/cc/c62100906d30f95d46451c15eb407da7db201e30f42008f3643945910373/graphviz-0.14-py2.py3-none-any.whl" # TODO: I don't understand what this is for? Why are we linking to a specific file like this??? (matcaz)
},
"requirements": {
"host": package.install_requires,
"run": package.install_requires
},
# TODO --------------------
"test": {
"imports": [
"coast"
]
},
# TODO --------------------
"about": {
"home": package.url,
"license": package.license,
"license_family": package.license_family,
"summary": package.description,
},
# "extra": {
# "recipe-maintainers": [
# package.github
# ]
# }
})
yaml_path = path.join(directory, "meta.yaml")
with open(yaml_path, "w") as meta_file:
yaml.dump(package_metadata, meta_file)
if __name__ == "__main__":
generate_conda()