forked from python-quantities/python-quantities
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·158 lines (125 loc) · 4.71 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
"""
Class description.
Hack hack hack.
I said two lines. At least.
I made some beautfication in the documentation.
Let's see if this changes in the documentation will
lead to some conficts.
Yes it did. But I solved the conflict and kept the stuff
of Carlos anyway...
I did some weird stuff in the documentation. And then some more stuff.
"""
from distutils.cmd import Command
from distutils.core import setup
from distutils.command.sdist import sdist as _sdist
from distutils.command.build import build as _build
import os
import sys
print('Path to the Python executable', sys.executable())
class Data(Command):
description = "Convert the NIST database of constants"
user_options = []
boolean_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
with open('quantities/constants/NIST_codata.txt') as f:
data = f.read()
data = data.split('\n')[10:-1]
with open('quantities/constants/_codata.py', 'w') as f:
f.write('# THIS FILE IS AUTOMATICALLY GENERATED\n')
f.write('# ANY CHANGES MADE HERE WILL BE LOST\n\n')
f.write('physical_constants = {}\n\n')
for line in data:
name = line[:55].rstrip().replace('mag.','magnetic')
name = name.replace('mom.', 'moment')
val = line[55:77].replace(' ','').replace('...','')
prec = line[77:99].replace(' ','').replace('(exact)', '0')
unit = line[99:].rstrip().replace(' ', '*').replace('^', '**')
d = "{'value': %s, 'precision': %s, 'units': '%s'}" \
%(val, prec, unit)
f.write("physical_constants['%s'] = %s\n"%(name, d))
class SDist(_sdist):
def run(self):
self.run_command('data')
_sdist.run(self)
class Build(_build):
def run(self):
self.run_command('data')
_build.run(self)
class Test(Command):
"""Run the test suite."""
description = "Run the test suite"
user_options = [('verbosity=', 'V', 'set test report verbosity')]
def initialize_options(self):
self.verbosity = 0
def finalize_options(self):
try:
self.verbosity = int(self.verbosity)
except ValueError:
raise ValueError('verbosity must be an integer.')
def run(self):
import sys
if sys.version.startswith('2.6') or sys.version.startswith('3.1'):
import unittest2 as unittest
else:
import unittest
suite = unittest.TestLoader().discover('.')
unittest.TextTestRunner(verbosity=self.verbosity+1).run(suite)
packages = []
for dirpath, dirnames, filenames in os.walk('quantities'):
if '__init__.py' in filenames:
packages.append('.'.join(dirpath.split(os.sep)))
else:
del(dirnames[:])
with open('quantities/version.py') as f:
for line in f:
if line.startswith('__version__'):
exec(line)
setup(
author = 'Darren Dale',
author_email = '[email protected]',
# classifiers = """Development Status :: 4 - Beta
# Environment :: Console
# Intended Audience :: Developers
# Intended Audience :: Education
# Intended Audience :: End Users/Desktop
# Intended Audience :: Science/Research
# License :: OSI Approved :: BSD License
# Operating System :: OS Independent
# Programming Language :: Python
# Topic :: Education
# Topic :: Scientific/Engineering
# """,
cmdclass = {
'build': Build,
'data': Data,
'sdist': SDist,
'test': Test,
},
description = "Support for physical quantities with units, based on numpy",
download_url = "http://pypi.python.org/pypi/quantities",
keywords = ['quantities', 'units', 'physical', 'constants'],
license = 'BSD',
long_description = """Quantities is designed to handle arithmetic and
conversions of physical quantities, which have a magnitude, dimensionality
specified by various units, and possibly an uncertainty. See the tutorial_
for examples. Quantities builds on the popular numpy library and is
designed to work with numpy ufuncs, many of which are already
supported. Quantities is actively developed, and while the current features
and API are stable, test coverage is incomplete so the package is not
suggested for mission-critical applications.
.. _tutorial: http://packages.python.org/quantities/user/tutorial.html
""",
name = 'quantities',
packages = packages,
platforms = 'Any',
requires = [
'python (>=2.6.0)',
'numpy (>=1.4.0)',
],
url = 'http://packages.python.org/quantities',
version = __version__,
)