forked from qpv-research-group/solcore5
-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
executable file
·151 lines (136 loc) · 4.8 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
from setuptools import dist, find_packages
def pre_install_numpy():
try:
import numpy # noqa
except ImportError:
print('Installing numpy')
numpy_version = dist.Distribution().fetch_build_eggs(['numpy'])[0].version
print(f'Pre-installed numpy {numpy_version}')
pre_install_numpy()
from numpy.distutils.core import Extension, setup
import os
import sys
from configparser import ConfigParser
def gen_data_files(*dirs):
"""Creates the list of files (not necessarily python files) that need to be
installed together with the rest of stuff"""
results = []
exclude = [".DS_Store", "__pycache__", "egg", ".git"]
for src_dir in dirs:
for root, dirs, files in os.walk(src_dir):
if not any(sub in root for sub in exclude):
results.append(
(root, [os.path.join(root, f) for f in files if f not in exclude])
)
return results
here = os.path.abspath(os.path.dirname(__file__))
default_config = os.path.join(here, "solcore", "solcore_config.txt")
config = ConfigParser()
config.read([default_config])
# We give the option of compiling - and installing - the extension modules
if (("--with_pdd" in sys.argv) or
(('SOLCORE_WITH_PDD' in os.environ) and
(os.environ['SOLCORE_WITH_PDD'] == "1"))):
sources = os.path.join("solcore", "poisson_drift_diffusion",
"DDmodel-current.f95")
ext = [
Extension(
name="solcore.poisson_drift_diffusion.ddModel",
sources=[sources],
f2py_options=["--quiet"],
extra_link_args=["-static", "-static-libgfortran", "-static-libgcc"] if sys.platform == "win32" else None
)
]
if "--with_pdd" in sys.argv:
sys.argv.remove("--with_pdd")
else:
ext = []
# Option for updating the manifest
if "update_manifest" in sys.argv:
# Update the MANIFEST.in file with all the data from within solcore
include = "solcore"
exclude = ["__pycache__", "egg", "darwin", "cpython"]
with open("MANIFEST.in", "w", encoding="utf-8") as f:
for root, dir, files in os.walk("."):
if not any(sub in root for sub in exclude) and root[2:9] == include:
try:
files.remove(".DS_Store")
except ValueError:
pass
for file in files:
if any(sub in file for sub in exclude):
continue
include_line = "include " + os.path.join(root[2:], file) + "\n"
f.write(include_line)
sys.exit()
# Get the long description from the README file
with open(os.path.join(here, "README.md"), encoding="utf-8") as f:
long_description = f.read()
install_requires = [
"numpy",
"matplotlib",
"scipy",
"tmm",
"natsort",
"regex",
"cycler",
"pyyaml",
"yabox",
"joblib",
]
tests_require = [
"pytest",
"pytest-cov",
"pytest-mock",
"nbconvert",
"nbformat",
"pytest-rerunfailures",
"pytest-xdist",
]
docs_require = ["Sphinx", "recommonmark"]
extras_require = {
"dev": tests_require + docs_require + ["pre-commit"],
"docs": docs_require,
"test": tests_require,
}
setup(
name="solcore",
version=config.get("Configuration", "version"),
description="Python-based solar cell simulator",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/qpv-research-group/solcore5",
download_url="https://github.com/qpv-research-group/solcore5/archive/v{}.tar.gz".format(
config.get("Configuration", "version")
),
project_urls={
"Documentation": "http://solcore5.readthedocs.io",
"Solcore research paper": "https://doi.org/10.1007/s10825-018-1171-3",
},
author="The Quantum Photovoltaics Group",
author_email="[email protected]",
license="GNU LGPL",
python_requires=">=3.7",
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Science/Research",
"License :: OSI Approved",
"License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Physics",
],
ext_modules=ext,
keywords="photovoltaics modelling physics",
packages=find_packages(exclude=[]),
package_data={"": ["*.*"]},
data_files=gen_data_files("solcore"),
include_package_data=True,
setup_requires="pytest-runner",
install_requires=install_requires,
tests_require=tests_require,
extras_require=extras_require,
)