forked from lewagon/data-setup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
confs.rb
55 lines (37 loc) · 1.42 KB
/
confs.rb
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
require 'yaml'
# read package conf
specs_path = File.join('specs', 'base', 'packages.yml')
package_confs = YAML.load_file(specs_path)
python_version = package_confs["python"]
glovebox = package_confs["glovebox"]
setup = package_confs["setup"]
platform = package_confs["platform"]
modules = package_confs["modules"]
full_mods = modules.values.flatten
confs = {
glovebox: glovebox,
apple_intel: glovebox + setup + full_mods + platform["apple_intel"],
apple_silicon: glovebox + setup + full_mods + platform["apple_silicon"],
linux: glovebox + setup + full_mods + platform["linux"],
}
# write python version
python_path = File.join('specs', 'releases', 'python_version.txt')
File.open(python_path, 'w') { |file| file.write("#{python_version}\n") }
# write generated conf files
confs.each do |conf, packages|
# build conf requirement path
conf_raw_path = File.join('specs', 'constraintless', "#{conf}.txt")
conf_path = File.join('specs', 'generated', "#{conf}.txt")
File.open(conf_raw_path, 'w') do |file_raw|
File.open(conf_path, 'w') do |file|
# write packages
packages.each do |package|
next if package.nil?
raw_package = package.gsub(/<.*/, '').gsub(/<=.*/, '')
.gsub(/>.*/, '').gsub(/>=.*/, '').gsub(/==.*/, '')
file.write("#{package}\n")
file_raw.write("#{raw_package}\n")
end
end
end
end