-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsetup.py
233 lines (210 loc) · 8.99 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# This file is part of MDTools.
# Copyright (C) 2021, The MDTools Development Team and all contributors
# listed in the file AUTHORS.rst
#
# MDTools is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# MDTools is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with MDTools. If not, see <http://www.gnu.org/licenses/>.
# Setup instructions. For more details about how to create a python
# package take a look at
# https://packaging.python.org/overview/
# and specifically at
# https://packaging.python.org/guides/distributing-packages-using-setuptools/
# and
# https://packaging.python.org/tutorials/packaging-projects/
"""
Setuptools-based setup script for MDTools.
For a basic installation just type the command::
python setup.py install
For more in-depth instructions, see the :ref:`installation-label`
section in MDTools' documentation.
"""
__author__ = "Andreas Thum"
# Standard libraries
import glob
# Third-party libraries
import setuptools
def get_varstring(fname, varname):
"""
Read the string assigned to a specific variable in a given file.
Parameters
----------
fname : str
Path to the file from which to read the string assigned to a
variable.
varname : str
Name of the variable whose value should be read. The value must
be a simple string enquoted in either 'single' order "double"
quotes.
Returns
-------
varstring : str
The string assigned to `varname`.
Notes
-----
If `varname` is assigned multiple times, only the first assignment
will be considered.
"""
single_quote = "'"
double_quote = '"'
with open(fname, "r") as file:
for line in file:
if line.startswith(varname):
if double_quote in line and single_quote in line:
ix_double_quote = line.find(double_quote)
ix_single_quote = line.find(single_quote)
if ix_single_quote < ix_double_quote:
delimiter = single_quote
else:
delimiter = double_quote
elif single_quote in line:
delimiter = single_quote
elif double_quote in line:
delimiter = double_quote
else:
raise TypeError(
"The line starting with '{}' does not contain a"
" string".format(varname)
)
if line[::-1].strip()[0] != delimiter:
raise TypeError(
"The line starting with '{}' does not contain a"
" string".format(varname)
)
delimiter_count = line.count(delimiter)
varstring = line.split(delimiter)[1:delimiter_count]
return "".join(varstring)
def get_content(fname="README.rst"):
"""
Read a text file.
Parameters
----------
fname : str, optional
Path to the file to read.
Returns
-------
content : str
The whole content of the file as one long string.
"""
with open(fname, "r") as f:
return f.read()
if __name__ == "__main__":
# Directory that contains all packages.
pkg_dir = "src"
# Path to the MDTools core package, relative to this file.
mdt_dir = pkg_dir + "/mdtools"
# Directory that contains all MDTools scripts.
script_dir = "scripts"
# Description of `setuptools.setup` keywords:
# https://setuptools.pypa.io/en/latest/references/keywords.html
setuptools.setup(
name=get_varstring(mdt_dir + "/_metadata.py", "__title__"),
version=get_varstring(mdt_dir + "/version.py", "__version__"),
author=get_varstring(mdt_dir + "/_metadata.py", "__author__"),
maintainer=get_varstring(mdt_dir + "/_metadata.py", "__maintainer__"),
maintainer_email=get_varstring(mdt_dir + "/_metadata.py", "__email__"),
url="https://github.com/andthum/mdtools",
download_url="https://github.com/andthum/mdtools",
project_urls={
"Homepage": "https://github.com/andthum/mdtools",
"Source": "https://github.com/andthum/mdtools",
"Documentation": "https://mdtools.readthedocs.io/en/latest/",
"Issue Tracker": "https://github.com/andthum/mdtools/issues",
"Feature Requests": "https://github.com/andthum/mdtools/issues",
"Q&A": "https://github.com/andthum/mdtools/discussions/categories/q-a", # noqa: E501
},
description=(
"Python scripts to prepare and analyze molecular dynamics"
" simulations"
),
long_description=get_content("README.rst"),
long_description_content_type="text/x-rst",
license=get_varstring(mdt_dir + "/_metadata.py", "__license__"),
license_files=("LICENSE.txt", "AUTHORS.rst"),
# PyPI classifiers (https://pypi.org/classifiers/).
classifiers=[
"Development Status :: 4 - Beta",
"Environment :: Console",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", # noqa: E501
"Natural Language :: English",
"Operating System :: MacOS",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Chemistry",
"Topic :: Scientific/Engineering :: Physics",
"Topic :: Scientific/Engineering :: Bio-Informatics",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Utilities",
],
keywords=[
"Scripts Collection",
"Python Scripts",
"Science",
"Scientific Computing",
"Computational Science",
"Computational Biology",
"Computational Chemistry",
"Computational Physics",
"Materials Science",
"Molecular Simulation",
"Molecular Modeling",
"Molecular Mechanics",
"Molecular Dynamics",
"Molecular Dynamics Simulation",
"Trajectory Analysis",
"MDAnalysis",
"NumPy",
"Python3",
"GPLv3",
],
# Indicate that the relevant code is entirely contained inside
# the given directory (instead of being directly placed under
# the project’s root). All the directories inside the container
# directory will be copied directly into the final wheel
# distribution, but the container directory itself will not.
package_dir={"": pkg_dir},
# Let setuptools find all packages in the package directory.
# Use `setuptools.find_namespace_packages` instead of
# `setuptools.find_packages` to let setuptools find data files
# in subdirectories that don't contain an `__init__.py` file
# (https://setuptools.pypa.io/en/latest/userguide/datafiles.html#subdirectory-for-data-files).
packages=setuptools.find_namespace_packages(where=pkg_dir),
# Include all data files inside the package directories that are
# specified in the `MANIFEST.in` file.
include_package_data=True,
# A dictionary mapping package names to lists of glob patterns
# that should be excluded from your distributed package
# directories.
exclude_package_data={"": [".git*"]},
# A list of strings specifying standalone script files to be
# built and installed.
scripts=glob.glob(script_dir + "/**/*.py", recursive=True),
# The Python version(s) supported by this project.
python_requires=">=3.6, <3.10",
# Python packages required by this project to run. Dependencies
# will be installed by pip when installing this project.
install_requires=get_content("requirements.txt").splitlines(),
# Additional groups of dependencies (e.g. development or test
# dependencies). Users will be able to install these using
# pip's "extras" syntax: `pip install mdtools[dev]`
extras_require={
"dev": get_content("requirements-dev.txt").splitlines(),
},
)