forked from AstarVienna/irdb
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.py
More file actions
81 lines (65 loc) · 2.53 KB
/
Copy pathsetup.py
File metadata and controls
81 lines (65 loc) · 2.53 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
75
76
77
78
79
80
81
#!/usr/bin/env python3
"""IRDB"""
from distutils.core import setup
import os
from os import path as pth
import shutil
import zipfile
ZIPPED_DATA_FILES = (
("MaunaKea", "TER_maunakea_tapas.dat"),
)
def ensure_zipped_data_files():
"""Create large ignored data files from their checked-in zip archives."""
for folder, filename in ZIPPED_DATA_FILES:
target = pth.join(folder, filename)
archive = f"{target}.zip"
if not pth.exists(archive):
if not pth.exists(target):
raise FileNotFoundError(f"Missing required data archive: {archive}")
continue
with zipfile.ZipFile(archive) as zip_file:
try:
zip_info = zip_file.getinfo(filename)
except KeyError as err:
raise FileNotFoundError(f"{archive} does not contain {filename}") from err
if pth.exists(target) and pth.getsize(target) == zip_info.file_size:
continue
tmp_target = f"{target}.tmp"
try:
with zip_file.open(zip_info) as source, open(tmp_target, "wb") as dest:
shutil.copyfileobj(source, dest)
os.replace(tmp_target, target)
except Exception:
if pth.exists(tmp_target):
os.remove(tmp_target)
raise
print(f"Extracted {archive} -> {target}")
def create_manifest():
pkgs_list = [pkg for pkg in os.listdir("./") if \
pth.isdir(pkg) and pth.exists(pth.join(pkg, f"{pkg}.yaml"))]
with open("MANIFEST.in", "w") as f:
for pkg_name in pkgs_list:
f.write(f"include {pkg_name}/*\n")
print(f"Including {pkg_name}")
def setup_package():
ensure_zipped_data_files()
setup(name = 'IRDB',
description = "Instrument package database",
author = "Kieran Leschinski",
author_email = "kieran.leschinski@unive.ac.at",
url = "http://homepage.univie.ac.at/kieran.leschinski/",
package_dir={'scopesim': 'scopesim'},
packages = ["irdb/tests"],
install_requires=["numpy>=1.16",
"scipy>=1.0.0",
"astropy>=2.0",
"matplotlib>=1.5",
"docutils",
"pyyaml>5.1",
"paramiko",
"scopesim>=0.10.1",
],
)
if __name__ == '__main__':
create_manifest()
setup_package()