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
|
# Software Name: MOON
# Version: 5.4
# SPDX-FileCopyrightText: Copyright (c) 2018-2020 Orange and its contributors
# SPDX-License-Identifier: Apache-2.0
# This software is distributed under the 'Apache License 2.0',
# the text of which is available at 'http://www.apache.org/licenses/LICENSE-2.0.txt'
# or see the "LICENSE" file for more details.
import os
import shutil
from setuptools import setup, find_packages
from setuptools.command.install import install
from setuptools.command.develop import develop
import moon_manager
def initConfiguration():
if os.name == "posix":
try:
os.mkdir("/etc/moon")
except FileExistsError:
pass
if not os.path.exists(os.path.join("/etc", "moon", "moon.yaml")):
print("Installing configuration file in /etc")
shutil.copy(os.path.join("conf", "moon.yaml"),
os.path.join("/etc", "moon"))
# else:
# raise NotImplementedError('You should install configuration file somewhere '
# 'on your system')
class CustomInstallCommand(install):
"""Customized setuptools install command - install configuration file in etc."""
def run(self):
install.run(self)
initConfiguration()
class CustomDevelopCommand(develop):
"""Customized setuptools develop command - install configuration file in etc."""
def run(self):
develop.run(self)
initConfiguration()
with open('requirements.txt') as f:
requirements = filter(
lambda s: (len(s)>0 and s.strip()[0]!='#'),
f.read().split('\n'))
print('requirements', requirements)
setup(
name='moon_manager',
version=moon_manager.__version__,
packages=find_packages(),
author="Thomas Duval",
author_email="thomas.duval@orange.com",
description="",
long_description=open('README.md').read(),
install_requires=list(filter(
lambda s: (len(s) > 0 and s.strip()[0] != '#'),
open('requirements.txt').read().split('\n'))),
data_files=[
("moon", ["conf/moon.yaml"]),
("moon", ["moonrc"])
],
include_package_data=True,
cmdclass={
'develop': CustomDevelopCommand,
'install': CustomInstallCommand,
},
url='',
classifiers=[
"Programming Language :: Python",
"Development Status :: 1 - Planning",
"License :: OSI Approved",
"Natural Language :: French",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
],
entry_points={
'console_scripts': [
'moon_manager = moon_manager.__main__:run',
'moon_manager_setup = moon_manager.manager_setup:setup'
],
}
)
|