-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsetup.py
190 lines (162 loc) · 5.88 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
# Tutorial at https://blog.jetbrains.com/pycharm/2017/05/how-to-publish-your-package-on-pypi/
# https://packaging.python.org/tutorials/packaging-projects/
# python3 setup.py sdist bdist_wheel
# python3 -m twine upload --repository-url https://test.pypi.org/legacy/ dist/*
# python.exe -m pip install --index-url https://test.pypi.org/simple/ RTOC
# virtual env for testing:
# > virtualenv <DIR>
# move to directory and use python from There
# public:
# python3 setup.py bdist_wheel
# python3 -m twine upload dist\*
# select different dependencie-levels:
# pip install 'RTOC'
# pip install 'RTOC[Telegram]'
# pip install 'RTOC[GUI]'
# pip install 'RTOC[ALL]'
from os import path
this_directory = path.abspath(path.dirname(__file__))
with open(path.join(this_directory, 'README.md'), encoding='utf-8') as f:
long_description = f.read()
setupOpts = dict(
name='RTOC',
description='RealTime OpenControl',
long_description=long_description,
long_description_content_type="text/markdown",
license='GNU',
url='https://github.com/Haschtl/RealTimeOpenControl',
author='Sebastian Keller',
author_email='sebastiankeller@online.de',
classifiers=[
# "Programming Language :: Python",
"Programming Language :: Python :: 3",
# "Development Status :: 2.3",
"Environment :: Other Environment",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)",
"Operating System :: OS Independent",
"Topic :: Scientific/Engineering :: Visualization",
"Topic :: Software Development :: User Interfaces",
],
)
import distutils.dir_util
from distutils.command import build
import os
import sys
import re
try:
import setuptools
from setuptools import setup
from setuptools.command import install
except (ImportError, SystemError):
sys.stderr.write("Warning: could not import setuptools; falling back to distutils.\n")
from distutils.core import setup
from distutils.command import install
# Work around mbcs bug in distutils.
# http://bugs.python.org/issue10945
import codecs
try:
codecs.lookup('mbcs')
except LookupError:
ascii = codecs.lookup('ascii')
func = lambda name, enc=ascii: {True: enc}.get(name == 'mbcs')
codecs.register(func)
path = os.path.split(__file__)[0]
# sys.path.insert(0, os.path.join(path, 'tools'))
version = "3.0"
forcedVersion = "3.0"
gitVersion = "3.0"
initVersion = 1.0
class Build(build.build):
"""
* Clear build path before building
"""
def run(self):
global path
# Make sure build directory is clean
buildPath = os.path.join(path, self.build_lib)
if os.path.isdir(buildPath):
distutils.dir_util.remove_tree(buildPath)
ret = build.build.run(self)
return ret
class Install(install.install):
"""
* Check for previously-installed version before installing
* Set version string in __init__ after building. This helps to ensure that we
know when an installation came from a non-release code base.
"""
def run(self):
global path, version, initVersion, forcedVersion, installVersion
name = self.config_vars['dist_name']
path = os.path.join(self.install_libbase, 'RTOC')
if os.path.exists(path):
raise Exception("It appears another version of %s is already "
"installed at %s; remove this before installing."
% (name, path))
print("Installing to %s" % path)
rval = install.install.run(self)
# If the version in __init__ is different from the automatically-generated
# version string, then we will update __init__ in the install directory
if initVersion == version:
return rval
try:
initfile = os.path.join(path, '__init__.py')
data = open(initfile, 'r').read()
open(initfile, 'w').write(re.sub(r"__version__ = .*", "__version__ = '%s'" % version, data))
installVersion = version
except Exception:
sys.stderr.write("Warning: Error occurred while setting version string in build path. "
"Installation will use the original version string "
"%s instead.\n" % (initVersion)
)
if forcedVersion:
raise
installVersion = initVersion
sys.excepthook(*sys.exc_info())
return rval
setup(
version=version,
entry_points={
'console_scripts': [
'RTOC = RTOC:main',
],
},
packages=setuptools.find_packages(),
# package_dir={'RTOC': 'RTOC', 'RTOC.plugins':'plugins', 'RTOC.example_scripts':'example_scripts'}, ## install examples along with the rest of the source
package_data={
'RTOC': ['*'],
# 'RTOC': ['*']
},
python_requires='>=3',
include_package_data=True,
install_requires=[
'numpy',
'requests',
# 'scipy',
# 'pyqt5',
# 'pyqtgraph',
# 'markdown2',
# 'xlsxwriter',
# 'QDarkStyle',
# 'qtmodern',
# 'qdarkgraystyle',
# 'python-telegram-bot',
# 'matplotlib',
'python-nmap',
'whaaaaat',
'prompt_toolkit',
# 'dash',
'pycryptodomex',
# 'pyGithub',
# 'pandas',
# 'ezodf',
# websocket-server,
'websocket_client'
],
extras_require={
'GUI': ["pyqt5", "pyqtgraph", "markdown2", "pyGithub", "pandas", "scipy", "ezodf", "xlsxwriter"],
'Telegram': ["matplotlib", "python-telegram-bot", ],
'ALL': ["pyqt5", "pyqtgraph", "markdown2", "pyGithub", "pandas", "scipy", "ezodf", "xlsxwriter", "matplotlib", "python-telegram-bot", 'dash_table', 'statsmodels', 'scikit-learn', 'scikit-metrics', 'patsy','psycopg2']
},
**setupOpts
)