forked from projectcalico/felix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
85 lines (72 loc) · 2.61 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
#!/usr/bin/env python
# Copyright (c) 2014, 2015 Metaswitch Networks
# 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.
import inspect
import os
import os.path
import setuptools
import sys
PY26_DEPENDENCIES = ['argparse']
def collect_requirements():
def filter_requirements(filters, file):
for reqfilter in filters:
if reqfilter in file:
return True
return False
reqs = set()
# This monstrosity is the only way to definitely get the location of
# setup.py regardless of how you execute it. It's tempting to use __file__
# but that only works if setup.py is executed directly, otherwise it all
# goes terribly wrong.
directory = os.path.dirname(
os.path.abspath(inspect.getfile(inspect.currentframe()))
)
files = os.listdir(directory)
unfiltered_reqs = (f for f in files if f.endswith('requirements.txt'))
# If the environment variable $CALICODEPS is set, only the corresponding
# dependencies are installed.
deps = os.environ.get('CALICODEPS')
if deps:
filters = map(lambda s: s.lower().strip(), deps.split(','))
requirements_files = (
f for f in unfiltered_reqs if filter_requirements(filters, f)
)
else:
requirements_files = unfiltered_reqs
for reqfile in requirements_files:
with open(reqfile, 'r') as f:
for line in f:
line = line.split('#', 1)[0].strip()
if line:
reqs.add(line)
# If we're running on Python 2.6, add other necessary dependencies. These
# are added unconditionally.
if sys.version_info < (2, 7):
reqs.add(*PY26_DEPENDENCIES)
return reqs
setuptools.setup(
name = "calico",
version = "0.16",
packages = setuptools.find_packages(),
entry_points = {
'console_scripts': [
'calico-felix = calico.felix.felix:main',
],
'neutron.ml2.mechanism_drivers': [
'calico = calico.openstack.mech_calico:CalicoMechanismDriver',
],
},
install_requires=collect_requirements()
)