-
Notifications
You must be signed in to change notification settings - Fork 4
/
setup.py
136 lines (119 loc) · 5.82 KB
/
setup.py
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import subprocess
import os
import setuptools
import atexit
def download_lfs_at_exit():
# Download large files from Zenodo. This need to be done at exti, after zenodo_get is installed.
zenodo_status = subprocess.run(['zenodo_get', '10.5281/zenodo.7495246', '-o', os.path.expanduser('~') + '/.pymoog/files/'])
# Find the latest version of pymoog_lf
version_list = [i for i in os.listdir(os.path.expanduser('~') + '/.pymoog/files/') if '.tar.gz' in i]
remove_list = [i for i in version_list if i[-7:] != '.tar.gz']
version_list = [i for i in version_list if i[-7:] == '.tar.gz']
version_split_list = [i.split('_')[2].split('.')[0:3] for i in version_list]
version_list_temp = []
for version in version_split_list:
version_list_temp.append([int(version[0][1:]), int(version[1]), int(version[2])])
version_list_temp.sort(key=lambda row: (row[0], row[1], row[2]), reverse=True)
latest_version = 'pymoog_lf_v{}.{}.{}.tar.gz'.format(*version_list_temp[0])
# Clear old lf versions
for version in remove_list:
rm_status = subprocess.run(['rm', MOOGMODELING_path + '/files/' + version], stdout=subprocess.PIPE)
# unzip latest version
tar_status = subprocess.run(['tar', '-xzvf', MOOGMODELING_path + 'files/' + latest_version, '-C', MOOGMODELING_path + 'files/'], stdout=subprocess.PIPE)
print("Large files download/renew finished.")
if os.environ.get('READTHEDOCS') != 'True':
# Define MOOGMODELING_path. This path will store the code of moog and any other temporary files in the calculation.
MOOGMODELING_path = '{}/.pymoog/'.format(os.environ['HOME'])
# Create the folder according to MOOGMODELING_path
if not(os.path.isdir(MOOGMODELING_path)):
os.mkdir(MOOGMODELING_path)
# Copy the files folder into working directory
if not(os.path.isdir(MOOGMODELING_path + 'files')):
os.mkdir(MOOGMODELING_path + 'files')
cp_status = subprocess.run(['cp', '-r', 'pymoog/files', MOOGMODELING_path], stdout=subprocess.PIPE)
# Copy the moog_nosm folder to MOOGMODELING_path; if the folder already exist it will be removed first.
if os.path.isdir(MOOGMODELING_path + '/moog_nosm'):
rm_status = subprocess.run(['rm', '-r', MOOGMODELING_path + 'moog_nosm'], stdout=subprocess.PIPE)
mv_status = subprocess.run(['mv', MOOGMODELING_path + 'files/moog_nosm', MOOGMODELING_path + 'moog_nosm'], stdout=subprocess.PIPE)
# Check the permission of ./install
chmod_subp = subprocess.run(['chmod', '775', './install.sh'], cwd=MOOGMODELING_path+'moog_nosm/moog_nosm_NOV2019/', stdout=subprocess.PIPE)
# Check if gfortran is installed in the system.
# Not done yet
# Run the MOOGMODELING_path/moog_nosm/moog_nosm_FEB2017/install.sh script
install = subprocess.run(['bash', './install.sh', 'Linux'], cwd=MOOGMODELING_path+'moog_nosm/moog_nosm_NOV2019/', encoding='UTF-8', stdout=subprocess.PIPE)
print(install.stdout)
# Check if MOOG and MOOGSILENT is in the folder
if not(os.path.isfile(MOOGMODELING_path+'moog_nosm/moog_nosm_NOV2019/MOOG')) or not(os.path.isfile(MOOGMODELING_path+'moog_nosm/moog_nosm_NOV2019/MOOGSILENT')):
raise ValueError("MOOG is not installed correctly!")
else:
print('Successfully installed MOOG!')
atexit.register(download_lfs_at_exit)
with open("README.md", "r") as fh:
long_description = fh.read()
if os.environ.get('READTHEDOCS') != 'True':
setuptools.setup(
name='pymoog',
version='1.0.0',
description='The python wrapper to run LTE spectra synthesis code MOOG.',
long_description=long_description,
long_description_content_type="text/markdown",
url='https://github.com/MingjieJian/pymoog',
author='Mingjie Jian',
author_email='ssaajianmingjie@gmail.com',
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Framework :: IPython",
"Operating System :: OS Independent",
"Development Status :: 2 - Pre-Alpha",
"Topic :: Scientific/Engineering :: Astronomy"
],
python_requires=">=3.5",
packages=setuptools.find_packages(exclude=['files']),
install_requires=[
'numpy >= 1.18.0',
'pandas >= 1.0.0',
'matplotlib >= 3.1.0',
'mendeleev >= 0.6.0',
'scipy >= 1.4.0',
'astropy >= 4.0',
'spectres',
'tqdm',
'zenodo_get'
],
include_package_data=True,
# package_data={'': ['moog_nosm/moog_nosm_FEB2017/']},
zip_safe=False)
else:
setuptools.setup(
name='pymoog',
version='1.0.0',
description='The python wrapper to run LTE spectra synthesis code MOOG.',
long_description=long_description,
long_description_content_type="text/markdown",
url='https://github.com/MingjieJian/pymoog',
author='Mingjie Jian, Pranav Satheesh and Kruthi Krishna',
author_email='ssaajianmingjie@gmail.com',
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Framework :: IPython",
"Operating System :: OS Independent",
"Development Status :: 2 - Pre-Alpha",
"Topic :: Scientific/Engineering :: Astronomy"
],
python_requires=">=3.5",
packages=setuptools.find_packages(exclude=['files']),
install_requires=[
'numpy >= 1.18.0',
'pandas >= 1.0.0',
'matplotlib >= 3.1.0',
'mendeleev >= 0.6.0',
'scipy >= 1.4.0',
'spectres',
'tqdm',
'zenodo_get'
],
include_package_data=True,
# package_data={'': ['moog_nosm/moog_nosm_FEB2017/']},
zip_safe=False)