188
by Scott Moser
add vi modelines to python files |
1 |
# vi: ts=4 expandtab
|
26
by Soren Hansen
Update license to GPLv3 (dropping the "or later" bit). |
2 |
#
|
3 |
# Distutils magic for ec2-init
|
|
559.2.83
by Joshua Harlow
Update with parsing of a requirments file, changelog for this new refactoring stuff and setup.py for both of those. |
4 |
#
|
26
by Soren Hansen
Update license to GPLv3 (dropping the "or later" bit). |
5 |
# Copyright (C) 2009 Canonical Ltd.
|
559.2.83
by Joshua Harlow
Update with parsing of a requirments file, changelog for this new refactoring stuff and setup.py for both of those. |
6 |
# Copyright (C) 2012 Yahoo! Inc.
|
26
by Soren Hansen
Update license to GPLv3 (dropping the "or later" bit). |
7 |
#
|
8 |
# Author: Soren Hansen <soren@canonical.com>
|
|
559.2.83
by Joshua Harlow
Update with parsing of a requirments file, changelog for this new refactoring stuff and setup.py for both of those. |
9 |
# Author: Joshua Harlow <harlowja@yahoo-inc.com>
|
26
by Soren Hansen
Update license to GPLv3 (dropping the "or later" bit). |
10 |
#
|
11 |
# This program is free software: you can redistribute it and/or modify
|
|
12 |
# it under the terms of the GNU General Public License version 3, as
|
|
13 |
# published by the Free Software Foundation.
|
|
14 |
#
|
|
15 |
# This program is distributed in the hope that it will be useful,
|
|
16 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
17 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
18 |
# GNU General Public License for more details.
|
|
19 |
#
|
|
20 |
# You should have received a copy of the GNU General Public License
|
|
21 |
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
559.2.83
by Joshua Harlow
Update with parsing of a requirments file, changelog for this new refactoring stuff and setup.py for both of those. |
22 |
|
23 |
from glob import glob |
|
24 |
||
25 |
import os |
|
26 |
||
559.2.265
by Joshua Harlow
Use setuptools instead of disttools, this seems to be needed for requirements to work |
27 |
import setuptools |
559.2.427
by Joshua Harlow
Add the ability to have setup.py have a CLI option that specifies the daemon type |
28 |
from setuptools.command.install import install |
29 |
||
30 |
from distutils.errors import DistutilsArgError |
|
559.2.83
by Joshua Harlow
Update with parsing of a requirments file, changelog for this new refactoring stuff and setup.py for both of those. |
31 |
|
559.2.340
by Joshua Harlow
Use the new tool created to get the version. |
32 |
import subprocess |
33 |
||
559.2.369
by harlowja
Copy the tiny_p from the packager code |
34 |
|
559.2.427
by Joshua Harlow
Add the ability to have setup.py have a CLI option that specifies the daemon type |
35 |
def is_f(p): |
36 |
return os.path.isfile(p) |
|
37 |
||
38 |
||
559.2.435
by Scott Moser
setup.py: rename "daemon type" to "init system" |
39 |
INITSYS_FILES = { |
616.1.1
by Scott Moser
pylint: setup.py |
40 |
'sysvinit': [f for f in glob('sysvinit/*') if is_f(f)], |
41 |
'systemd': [f for f in glob('systemd/*') if is_f(f)], |
|
42 |
'upstart': [f for f in glob('upstart/*') if is_f(f)], |
|
559.2.427
by Joshua Harlow
Add the ability to have setup.py have a CLI option that specifies the daemon type |
43 |
}
|
559.2.435
by Scott Moser
setup.py: rename "daemon type" to "init system" |
44 |
INITSYS_ROOTS = { |
45 |
'sysvinit': '/etc/rc.d/init.d', |
|
559.2.427
by Joshua Harlow
Add the ability to have setup.py have a CLI option that specifies the daemon type |
46 |
'systemd': '/etc/systemd/system/', |
47 |
'upstart': '/etc/init/', |
|
48 |
}
|
|
559.2.435
by Scott Moser
setup.py: rename "daemon type" to "init system" |
49 |
INITSYS_TYPES = sorted(list(INITSYS_ROOTS.keys())) |
559.2.427
by Joshua Harlow
Add the ability to have setup.py have a CLI option that specifies the daemon type |
50 |
|
51 |
||
559.2.369
by harlowja
Copy the tiny_p from the packager code |
52 |
def tiny_p(cmd, capture=True): |
53 |
# Darn python 2.6 doesn't have check_output (argggg)
|
|
54 |
stdout = subprocess.PIPE |
|
55 |
stderr = subprocess.PIPE |
|
56 |
if not capture: |
|
57 |
stdout = None |
|
58 |
stderr = None |
|
59 |
sp = subprocess.Popen(cmd, stdout=stdout, |
|
60 |
stderr=stderr, stdin=None) |
|
559.2.343
by Joshua Harlow
Use the standard utils now in tools for reading requires/dependencies/versions. |
61 |
(out, err) = sp.communicate() |
559.2.369
by harlowja
Copy the tiny_p from the packager code |
62 |
if sp.returncode not in [0]: |
63 |
raise RuntimeError("Failed running %s [rc=%s] (%s, %s)" |
|
64 |
% (cmd, sp.returncode, out, err)) |
|
559.2.343
by Joshua Harlow
Use the standard utils now in tools for reading requires/dependencies/versions. |
65 |
return (out, err) |
66 |
||
25
by Soren Hansen
* Distutils added |
67 |
|
559.2.340
by Joshua Harlow
Use the new tool created to get the version. |
68 |
def get_version(): |
69 |
cmd = ['tools/read-version'] |
|
559.2.343
by Joshua Harlow
Use the standard utils now in tools for reading requires/dependencies/versions. |
70 |
(ver, _e) = tiny_p(cmd) |
616.1.1
by Scott Moser
pylint: setup.py |
71 |
return str(ver).strip() |
559.2.83
by Joshua Harlow
Update with parsing of a requirments file, changelog for this new refactoring stuff and setup.py for both of those. |
72 |
|
73 |
||
559.2.343
by Joshua Harlow
Use the standard utils now in tools for reading requires/dependencies/versions. |
74 |
def read_requires(): |
75 |
cmd = ['tools/read-dependencies'] |
|
76 |
(deps, _e) = tiny_p(cmd) |
|
616.1.1
by Scott Moser
pylint: setup.py |
77 |
return str(deps).splitlines() |
559.2.83
by Joshua Harlow
Update with parsing of a requirments file, changelog for this new refactoring stuff and setup.py for both of those. |
78 |
|
249
by Scott Moser
fix setup.py to handle directories in doc |
79 |
|
559.2.427
by Joshua Harlow
Add the ability to have setup.py have a CLI option that specifies the daemon type |
80 |
# TODO: Is there a better way to do this??
|
559.2.435
by Scott Moser
setup.py: rename "daemon type" to "init system" |
81 |
class InitsysInstallData(install): |
616.1.1
by Scott Moser
pylint: setup.py |
82 |
init_system = None |
559.2.427
by Joshua Harlow
Add the ability to have setup.py have a CLI option that specifies the daemon type |
83 |
user_options = install.user_options + [ |
559.2.435
by Scott Moser
setup.py: rename "daemon type" to "init system" |
84 |
# This will magically show up in member variable 'init_sys'
|
85 |
('init-system=', None, |
|
86 |
('init system to configure (%s) [default: None]') % |
|
87 |
(", ".join(INITSYS_TYPES)) |
|
559.2.427
by Joshua Harlow
Add the ability to have setup.py have a CLI option that specifies the daemon type |
88 |
),
|
89 |
]
|
|
90 |
||
91 |
def initialize_options(self): |
|
92 |
install.initialize_options(self) |
|
559.2.436
by Joshua Harlow
Fix the initsys variable, setuptools/distools will automatically assign |
93 |
self.init_system = None |
559.2.427
by Joshua Harlow
Add the ability to have setup.py have a CLI option that specifies the daemon type |
94 |
|
95 |
def finalize_options(self): |
|
96 |
install.finalize_options(self) |
|
559.2.436
by Joshua Harlow
Fix the initsys variable, setuptools/distools will automatically assign |
97 |
if self.init_system and self.init_system not in INITSYS_TYPES: |
616.1.1
by Scott Moser
pylint: setup.py |
98 |
raise DistutilsArgError(("You must specify one of (%s) when" |
99 |
" specifying a init system!") % (", ".join(INITSYS_TYPES))) |
|
559.2.436
by Joshua Harlow
Fix the initsys variable, setuptools/distools will automatically assign |
100 |
elif self.init_system: |
616.1.1
by Scott Moser
pylint: setup.py |
101 |
self.distribution.data_files.append( |
102 |
(INITSYS_ROOTS[self.init_system], |
|
103 |
INITSYS_FILES[self.init_system])) |
|
559.2.427
by Joshua Harlow
Add the ability to have setup.py have a CLI option that specifies the daemon type |
104 |
# Force that command to reinitalize (with new file list)
|
105 |
self.distribution.reinitialize_command('install_data', True) |
|
106 |
||
107 |
||
559.2.265
by Joshua Harlow
Use setuptools instead of disttools, this seems to be needed for requirements to work |
108 |
setuptools.setup(name='cloud-init', |
559.2.340
by Joshua Harlow
Use the new tool created to get the version. |
109 |
version=get_version(), |
25
by Soren Hansen
* Distutils added |
110 |
description='EC2 initialisation magic', |
141
by Scott Moser
remove ec2-is-compat-env and minor changes to setup.py |
111 |
author='Scott Moser', |
112 |
author_email='scott.moser@canonical.com', |
|
146
by Scott Moser
more removal of 'ec2init' string, replacement with cloud-init |
113 |
url='http://launchpad.net/cloud-init/', |
559.2.267
by Joshua Harlow
Add a license and use find_packages to locate the needed packages |
114 |
packages=setuptools.find_packages(exclude=['tests']), |
559.2.251
by Scott Moser
update tools/bddeb and debian.trunk packaging |
115 |
scripts=['bin/cloud-init', |
493.1.2
by Scott Moser
replace cloud-init-run-module with cloud-init-per |
116 |
'tools/cloud-init-per', |
79
by Scott Moser
add cloud-init-run-module and ec2init/execute.py |
117 |
],
|
559.2.267
by Joshua Harlow
Add a license and use find_packages to locate the needed packages |
118 |
license='GPLv3', |
271
by Scott Moser
remove 'biultin' config, separate cloud.cfg |
119 |
data_files=[('/etc/cloud', glob('config/*.cfg')), |
364
by Scott Moser
change from yaml+'#include' to yaml + config.d format for cloud.cfg |
120 |
('/etc/cloud/cloud.cfg.d', glob('config/cloud.cfg.d/*')), |
139
by Scott Moser
move etc/ec2-init/templates to etc/cloud/templates |
121 |
('/etc/cloud/templates', glob('templates/*')), |
146
by Scott Moser
more removal of 'ec2init' string, replacement with cloud-init |
122 |
('/usr/share/cloud-init', []), |
559.2.83
by Joshua Harlow
Update with parsing of a requirments file, changelog for this new refactoring stuff and setup.py for both of those. |
123 |
('/usr/lib/cloud-init', |
616.1.1
by Scott Moser
pylint: setup.py |
124 |
['tools/uncloud-init', |
125 |
'tools/write-ssh-key-fingerprints']), |
|
126 |
('/usr/share/doc/cloud-init', |
|
127 |
[f for f in glob('doc/*') if is_f(f)]), |
|
128 |
('/usr/share/doc/cloud-init/examples', |
|
129 |
[f for f in glob('doc/examples/*') if is_f(f)]), |
|
130 |
('/usr/share/doc/cloud-init/examples/seed', |
|
131 |
[f for f in glob('doc/examples/seed/*') if is_f(f)]), |
|
132 |
],
|
|
559.2.343
by Joshua Harlow
Use the standard utils now in tools for reading requires/dependencies/versions. |
133 |
install_requires=read_requires(), |
559.2.427
by Joshua Harlow
Add the ability to have setup.py have a CLI option that specifies the daemon type |
134 |
cmdclass = { |
135 |
# Use a subclass for install that handles
|
|
559.2.435
by Scott Moser
setup.py: rename "daemon type" to "init system" |
136 |
# adding on the right init system configuration files
|
137 |
'install': InitsysInstallData, |
|
559.2.427
by Joshua Harlow
Add the ability to have setup.py have a CLI option that specifies the daemon type |
138 |
},
|
25
by Soren Hansen
* Distutils added |
139 |
)
|