forked from laserkelvin/PySpecTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
121 lines (111 loc) · 3.44 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
import re
import os
import shutil
import stat
import platform
import sys
from warnings import warn
from distutils.command.sdist import sdist as _sdist
from distutils.extension import Extension
from distutils.spawn import find_executable
from glob import glob
import numpy as np
from setuptools import setup, find_packages
from setuptools.command.install import install
VERSIONFILE="pyspectools/_version.py"
verstrline = open(VERSIONFILE, "rt").read()
VSRE = r"^__version__ = ['\"]([^'\"]*)['\"]"
mo = re.search(VSRE, verstrline, re.M)
if mo:
verstr = mo.group(1)
else:
raise RuntimeError("Unable to find version string in %s." % (VERSIONFILE,))
class PostInstallCommand(install):
"""
This class defines the functions to be run after running pip install.
The routines to run are:
1. Checking if SPFIT/SPCAT are installed
"""
def check_pickett(self):
for executable in ["spcat", "spfit", "calbak"]:
if find_executable(executable) is None:
warn(executable + " not found in PATH.")
def setup_folders(self):
"""
Sets up the dot folders that are utilized by the routines. If the matplotlib
user folder doesn't exist, this function will make one.
"""
folders = [
".pyspectools",
".pyspectools/templates",
".config/matplotlib/stylelib"
]
folders = [
os.path.join(os.path.expanduser("~"), folder) for folder in folders
]
for folder in folders:
os.makedirs(folder, exist_ok=True)
def setup_files(self):
try:
# Copy over matplotlib stylesheets
home_dir = os.path.expanduser("~")
if os.path.exists(
home_dir + "/.config/matplotlib/stylelib"
) is False:
os.mkdir(home_dir + "/.config/matplotlib/stylelib")
for sheet in os.listdir("./pyspectools/mpl_stylesheets"):
if ".yml" not in sheet:
path = os.path.expanduser("~") + \
"/.config/matplotlib/stylelib" + sheet
else:
path = os.path.expanduser("~") + \
"/.pyspectools/" + sheet
shutil.copy(sheet, path)
except FileExistsError:
pass
def run(self):
# Check for SPFIT/SPCAT executables in PATH
self.check_pickett()
install.run(self)
cmdclass = dict()
cmdclass.update(
**{
"develop": PostInstallCommand,
"install": PostInstallCommand
}
)
setup(
name="pyspectools",
description="A set of Python tools/routines for spectroscopy",
author="Kelvin Lee",
version=verstr,
packages=find_packages(),
include_package_data=True,
author_email="kin.long.kelvin.lee@gmail.com",
install_requires=[
"numpy>=1.16",
"pandas",
"scipy",
"matplotlib",
"astroquery==0.3.8",
"astropy==3.0.5",
"lmfit",
"peakutils>=1.3.2",
"sklearn",
"colorlover",
"monsterurl",
"plotly>=3.0.0",
"periodictable",
"uncertainties",
"joblib",
"ruamel.yaml",
"paramiko",
"jinja2",
"tqdm",
"tinydb",
"networkx",
"monsterurl",
"torch"
],
cmdclass=cmdclass,
)