-
Notifications
You must be signed in to change notification settings - Fork 11
/
setup.py
77 lines (63 loc) · 2.22 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
"""
Copyright (c) 2016 Riptide IO, Inc. All Rights Reserved.
"""
from setuptools import setup, find_packages
from setuptools.command.install import install
from modbus_sim import __version__
packages = find_packages()
with open('requirements') as reqs:
install_requires = [
line for line in reqs.read().split('\n')
if (line and not line.startswith('--'))
]
long_description = None
with (open('README.md')) as readme:
long_description = readme.read()
def _copy_configs():
"""
copies device config from site-packages to home directory
:return:
"""
import os
home_dir = os.path.expanduser("~")
simu_dir = os.path.join(home_dir, "modbus_sim")
try:
import modbus_sim
import shutil
install_dir = modbus_sim.__path__[0]
print("**********************************************************")
print("Home directory: %s" % home_dir)
print("modbus_simu_cli package "
"installed directory: %s" % install_dir)
print("modbus_simu config directory: %s" % simu_dir)
print("**********************************************************")
if os.path.exists(simu_dir):
shutil.rmtree(simu_dir)
copy = ["configs"]
print("copying '%s'" % simu_dir)
for d in copy:
shutil.copytree(
os.path.join(install_dir, d),
os.path.join(simu_dir, d),
ignore=shutil.ignore_patterns("*.pyc")
)
shutil.rmtree(os.path.join(install_dir, d))
except ImportError:
print("modbus_simu package not installed!!")
print("done!!")
class ModbusSimuInstaller(install):
def run(self):
install.run(self)
self.execute(_copy_configs, (), msg="Running Post Install scripts")
setup(name="modbus_simu",
url='https://github.com/dhoomakethu/modbus_sim_cli',
version=__version__,
packages=packages,
cmdclass={'install': ModbusSimuInstaller},
description="Modbus TCP/RTU device simulator",
long_description=long_description,
author="riptideio",
install_requires=install_requires,
scripts=['modbus_sim/scripts/modbus_simulator'],
include_package_data=True,
)