-
Notifications
You must be signed in to change notification settings - Fork 7
/
setup.py
100 lines (84 loc) · 3.17 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
#!/usr/bin/env python
# Copyright 2016 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from octario.lib.release import __AUTHOR__
from octario.lib.release import __VERSION__
import pkg_resources
from setuptools import find_packages
from setuptools import setup
import distro
import os
with open('requirements.txt', 'r') as fh:
reqs = [str(requirement)
for requirement in pkg_resources.parse_requirements(fh)]
with open("LICENSE") as file:
license = file.read()
with open("README.md") as file:
long_description = file.read()
setup(
name='octario',
version=__VERSION__,
author=__AUTHOR__,
author_email='rhos-ci@redhat.com',
long_description=long_description,
license=license,
install_requires=reqs,
packages=find_packages(),
include_package_data=True,
entry_points={
'console_scripts': ['octario = octario.lib.cli:main']
}
)
SELINUX_DISTROS = ["fedora", "rhel", "centos"]
if distro.linux_distribution(full_distribution_name=False)[0] in SELINUX_DISTROS:
# For RedHat based systems, get selinux binding
try:
import selinux
except ImportError as e:
new_error = type(e)(e.message + ". check that 'libselinux-python is "
"installed'")
from distutils import sysconfig
import shutil
import sys
if hasattr(sys, 'real_prefix'):
# check for venv
VENV_SITE = sysconfig.get_python_lib()
SELINUX_PATH = os.path.join(
sysconfig.get_python_lib(plat_specific=True,
prefix=sys.real_prefix),
"selinux")
if not os.path.exists(SELINUX_PATH):
raise new_error
dest = os.path.join(VENV_SITE, "selinux")
if os.path.exists(dest):
raise new_error
# filter precompiled files
files = [os.path.join(SELINUX_PATH, f)
for f in os.listdir(SELINUX_PATH)
if not os.path.splitext(f)[1] in (".pyc", ".pyo")]
# add extra file for (libselinux-python)
_selinux_file = os.path.join(
sysconfig.get_python_lib(plat_specific=True,
prefix=sys.real_prefix),
"_selinux.so")
if os.path.exists(_selinux_file):
shutil.copy(_selinux_file, os.path.dirname(dest))
files.append(_selinux_file)
os.makedirs(dest)
for f in files:
shutil.copy(f, dest)
else:
raise new_error
import selinux # noqa