From 38c851e58e09c5574661ef4b2d2e66f6e38063d1 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Tue, 6 Jan 2015 12:02:38 -0500 Subject: tools/run-pep8: remove leading ',' fed to --ignore --ignore was being called with ',E121,E...' rather than 'E121,E...'. that resulted in odd behavior, missing the pep8 errors that are fixed here. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setup.py') diff --git a/setup.py b/setup.py index ab72ec18..25f09e58 100755 --- a/setup.py +++ b/setup.py @@ -164,7 +164,7 @@ else: (USR + '/share/doc/cloud-init', [f for f in glob('doc/*') if is_f(f)]), (USR + '/share/doc/cloud-init/examples', [f for f in glob('doc/examples/*') if is_f(f)]), - (USR + '/share/doc/cloud-init/examples/seed', + (USR + '/share/doc/cloud-init/examples/seed', [f for f in glob('doc/examples/seed/*') if is_f(f)]), ] # Use a subclass for install that handles -- cgit v1.2.3 From ee4a174e2e3b3268ef95485b99d81edea1ca3458 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Wed, 21 Jan 2015 15:14:24 -0500 Subject: * Added a simple tox.ini file * Use universal_newlines in setup.py so it will work properly in Python 3. * Fix a pyflakes complaint in setup.py * Add a simple MANIFEST.in --- .bzrignore | 3 +++ MANIFEST.in | 8 ++++++++ setup.py | 7 ++++--- tox.ini | 13 +++++++++++++ 4 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 .bzrignore create mode 100644 MANIFEST.in create mode 100644 tox.ini (limited to 'setup.py') diff --git a/.bzrignore b/.bzrignore new file mode 100644 index 00000000..32f5a949 --- /dev/null +++ b/.bzrignore @@ -0,0 +1,3 @@ +.tox +dist +cloud_init.egg-info diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 00000000..90f6c7d5 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,8 @@ +include *.py MANIFEST.in ChangeLog +global-include *.txt *.rst *.ini *.in *.conf *.cfg *.sh +graft tools +prune build +prune dist +prune .tox +prune .bzr +exclude .bzrignore diff --git a/setup.py b/setup.py index 25f09e58..507d5b25 100755 --- a/setup.py +++ b/setup.py @@ -45,7 +45,8 @@ def tiny_p(cmd, capture=True): stdout = None stderr = None sp = subprocess.Popen(cmd, stdout=stdout, - stderr=stderr, stdin=None) + stderr=stderr, stdin=None, + universal_newlines=True) (out, err) = sp.communicate() ret = sp.returncode if ret not in [0]: @@ -144,9 +145,9 @@ class InitsysInstallData(install): raise DistutilsArgError( "Invalid --init-system: %s" % (','.join(bad))) - for sys in self.init_system: + for system in self.init_system: self.distribution.data_files.append( - (INITSYS_ROOTS[sys], INITSYS_FILES[sys])) + (INITSYS_ROOTS[system], INITSYS_FILES[system])) # Force that command to reinitalize (with new file list) self.distribution.reinitialize_command('install_data', True) diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..883f6196 --- /dev/null +++ b/tox.ini @@ -0,0 +1,13 @@ +[tox] +envlist = py26,py27,py34 +recreate = True + +[testenv] +commands = python -m nose tests +deps = + httpretty>=0.7.1 + mock + mocker + nose + pep8==1.5.7 + pyflakes -- cgit v1.2.3 From 463d626ba53e54160f350d84831e1877b24f4024 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Wed, 21 Jan 2015 15:28:32 -0500 Subject: Only install cheetah (and only run the cheetah templating test) when in Python 2. Cheetah is not compatible with Python 3. --- requirements.txt | 4 +++- setup.py | 7 ++++++- tests/unittests/test_templating.py | 4 ++++ 3 files changed, 13 insertions(+), 2 deletions(-) (limited to 'setup.py') diff --git a/requirements.txt b/requirements.txt index 943dbef7..2a12ca3e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,6 @@ # Pypi requirements for cloud-init to work # Used for untemplating any files or strings with parameters. -cheetah jinja2 # This is used for any pretty printing of tabular data. @@ -32,3 +31,6 @@ requests # For patching pieces of cloud-config together jsonpatch + +# For Python 2/3 compatibility +six diff --git a/setup.py b/setup.py index 507d5b25..e88d9e88 100755 --- a/setup.py +++ b/setup.py @@ -175,6 +175,11 @@ else: } +requirements = read_requires() +if sys.version_info < (3,): + requirements.append('cheetah') + + setuptools.setup(name='cloud-init', version=get_version(), description='EC2 initialisation magic', @@ -187,6 +192,6 @@ setuptools.setup(name='cloud-init', ], license='GPLv3', data_files=data_files, - install_requires=read_requires(), + install_requires=requirements, cmdclass=cmdclass, ) diff --git a/tests/unittests/test_templating.py b/tests/unittests/test_templating.py index 3ba4ed8a..957467f6 100644 --- a/tests/unittests/test_templating.py +++ b/tests/unittests/test_templating.py @@ -16,6 +16,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +import six +import unittest + from . import helpers as test_helpers import textwrap @@ -38,6 +41,7 @@ class TestTemplates(test_helpers.TestCase): out_data = templater.basic_render(in_data, {'b': 2}) self.assertEqual(expected_data.strip(), out_data) + @unittest.skipIf(six.PY3, 'Cheetah is not compatible with Python 3') def test_detection(self): blob = "## template:cheetah" -- cgit v1.2.3 From 3aeec2dd6460fbdd3b8f217ad8aa231acb4bfd45 Mon Sep 17 00:00:00 2001 From: Daniel Watkins Date: Tue, 21 Jul 2015 13:06:11 +0100 Subject: Add udev rules for Azure ephemeral disks. And install them in the Debian packaging. --- packages/debian/dirs | 1 + setup.py | 2 ++ udev/66-azure-ephemeral.rules | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+) create mode 100644 udev/66-azure-ephemeral.rules (limited to 'setup.py') diff --git a/packages/debian/dirs b/packages/debian/dirs index f3de468d..9a633c60 100644 --- a/packages/debian/dirs +++ b/packages/debian/dirs @@ -3,3 +3,4 @@ usr/bin etc/init usr/share/doc/cloud etc/cloud +lib/udev/rules.d diff --git a/setup.py b/setup.py index e88d9e88..5f61681b 100755 --- a/setup.py +++ b/setup.py @@ -84,6 +84,7 @@ INITSYS_TYPES = sorted(list(INITSYS_ROOTS.keys())) USR = "/usr" ETC = "/etc" USR_LIB_EXEC = "/usr/lib" +LIB = "/lib" if os.uname()[0] == 'FreeBSD': USR = "/usr/local" USR_LIB_EXEC = "/usr/local/lib" @@ -167,6 +168,7 @@ else: [f for f in glob('doc/examples/*') if is_f(f)]), (USR + '/share/doc/cloud-init/examples/seed', [f for f in glob('doc/examples/seed/*') if is_f(f)]), + (LIB + '/udev/rules.d', ['udev/66-azure-ephemeral.rules']), ] # Use a subclass for install that handles # adding on the right init system configuration files diff --git a/udev/66-azure-ephemeral.rules b/udev/66-azure-ephemeral.rules new file mode 100644 index 00000000..b9c5c3ef --- /dev/null +++ b/udev/66-azure-ephemeral.rules @@ -0,0 +1,18 @@ +# Azure specific rules +ACTION!="add|change", GOTO="cloud_init_end" +SUBSYSTEM!="block", GOTO="cloud_init_end" +ATTRS{ID_VENDOR}!="Msft", GOTO="cloud_init_end" +ATTRS{ID_MODEL}!="Virtual_Disk", GOTO="cloud_init_end" + +# Root has a GUID of 0000 as the second value +# The resource/resource has GUID of 0001 as the second value +ATTRS{device_id}=="?00000000-0000-*", ENV{fabric_name}="azure_root", GOTO="ci_azure_names" +ATTRS{device_id}=="?00000000-0001-*", ENV{fabric_name}="azure_resource", GOTO="ci_azure_names" +GOTO="cloud_init_end" + +# Create the symlinks +LABEL="ci_azure_names" +ENV{DEVTYPE}=="disk", SYMLINK+="disk/cloud/$env{fabric_name}" +ENV{DEVTYPE}=="partition", SYMLINK+="disk/cloud/$env{fabric_name}-part%n" + +LABEL="cloud_init_end" -- cgit v1.2.3 From 316bdf523b01241036335b27a0afd89f6d3207c2 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Mon, 29 Feb 2016 23:02:55 -0500 Subject: setup.py: pep8/flake8 changes only --- setup.py | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'setup.py') diff --git a/setup.py b/setup.py index 5f61681b..6ff6dde9 100755 --- a/setup.py +++ b/setup.py @@ -45,13 +45,13 @@ def tiny_p(cmd, capture=True): stdout = None stderr = None sp = subprocess.Popen(cmd, stdout=stdout, - stderr=stderr, stdin=None, - universal_newlines=True) + stderr=stderr, stdin=None, + universal_newlines=True) (out, err) = sp.communicate() ret = sp.returncode if ret not in [0]: - raise RuntimeError("Failed running %s [rc=%s] (%s, %s)" - % (cmd, ret, out, err)) + raise RuntimeError("Failed running %s [rc=%s] (%s, %s)" % + (cmd, ret, out, err)) return (out, err) @@ -122,9 +122,8 @@ class InitsysInstallData(install): user_options = install.user_options + [ # This will magically show up in member variable 'init_sys' ('init-system=', None, - ('init system(s) to configure (%s) [default: None]') % - (", ".join(INITSYS_TYPES)) - ), + ('init system(s) to configure (%s) [default: None]' % + (", ".join(INITSYS_TYPES)))), ] def initialize_options(self): @@ -138,7 +137,8 @@ class InitsysInstallData(install): self.init_system = self.init_system.split(",") if len(self.init_system) == 0: - raise DistutilsArgError(("You must specify one of (%s) when" + raise DistutilsArgError( + ("You must specify one of (%s) when" " specifying init system(s)!") % (", ".join(INITSYS_TYPES))) bad = [f for f in self.init_system if f not in INITSYS_TYPES] @@ -182,18 +182,18 @@ if sys.version_info < (3,): requirements.append('cheetah') -setuptools.setup(name='cloud-init', - version=get_version(), - description='EC2 initialisation magic', - author='Scott Moser', - author_email='scott.moser@canonical.com', - url='http://launchpad.net/cloud-init/', - packages=setuptools.find_packages(exclude=['tests']), - scripts=['bin/cloud-init', - 'tools/cloud-init-per', - ], - license='GPLv3', - data_files=data_files, - install_requires=requirements, - cmdclass=cmdclass, - ) +setuptools.setup( + name='cloud-init', + version=get_version(), + description='EC2 initialisation magic', + author='Scott Moser', + author_email='scott.moser@canonical.com', + url='http://launchpad.net/cloud-init/', + packages=setuptools.find_packages(exclude=['tests']), + scripts=['bin/cloud-init', + 'tools/cloud-init-per'], + license='GPLv3', + data_files=data_files, + install_requires=requirements, + cmdclass=cmdclass, + ) -- cgit v1.2.3 From 0a89426da655b2bf7badf54b38b3b4be2b70e738 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Mon, 29 Feb 2016 23:14:39 -0500 Subject: update setup.py to install generator --- setup.py | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'setup.py') diff --git a/setup.py b/setup.py index 6ff6dde9..0b261dfe 100755 --- a/setup.py +++ b/setup.py @@ -55,29 +55,40 @@ def tiny_p(cmd, capture=True): return (out, err) -def systemd_unitdir(): - cmd = ['pkg-config', '--variable=systemdsystemunitdir', 'systemd'] +def pkg_config_read(library, var): + fallbacks = { + 'systemd': { + 'systemdsystemunitdir': '/lib/systemd/system', + 'systemdsystemgeneratordir': '/lib/systemd/system-generators', + } + } + cmd = ['pkg-config', '--variable=%s' % var, library] try: (path, err) = tiny_p(cmd) except: - return '/lib/systemd/system' + return fallbacks[library][var] return str(path).strip() + INITSYS_FILES = { 'sysvinit': [f for f in glob('sysvinit/redhat/*') if is_f(f)], 'sysvinit_freebsd': [f for f in glob('sysvinit/freebsd/*') if is_f(f)], 'sysvinit_deb': [f for f in glob('sysvinit/debian/*') if is_f(f)], - 'systemd': [f for f in glob('systemd/*') if is_f(f)], + 'systemd': [f for f in (glob('systemd/*.service') + + glob('systemd/*.target')) if is_f(f)], + 'systemd.generators': [f for f in glob('systemd/*-generator') if is_f(f)], 'upstart': [f for f in glob('upstart/*') if is_f(f)], } INITSYS_ROOTS = { 'sysvinit': '/etc/rc.d/init.d', 'sysvinit_freebsd': '/usr/local/etc/rc.d', 'sysvinit_deb': '/etc/init.d', - 'systemd': systemd_unitdir(), + 'systemd': pkg_config_read('systemd', 'systemdsystemunitdir'), + 'systemd.generators': pkg_config_read('systemd', + 'systemdsystemgeneratordir'), 'upstart': '/etc/init/', } -INITSYS_TYPES = sorted(list(INITSYS_ROOTS.keys())) +INITSYS_TYPES = sorted([f.partition(".")[0] for f in INITSYS_ROOTS.keys()]) # Install everything in the right location and take care of Linux (default) and # FreeBSD systems. @@ -147,8 +158,12 @@ class InitsysInstallData(install): "Invalid --init-system: %s" % (','.join(bad))) for system in self.init_system: - self.distribution.data_files.append( - (INITSYS_ROOTS[system], INITSYS_FILES[system])) + # add data files for anything that starts with '.' + datakeys = [k for k in INITSYS_ROOTS + if k.partition(".")[0] == system] + for k in datakeys: + self.distribution.data_files.append( + (INITSYS_ROOTS[k], INITSYS_FILES[k])) # Force that command to reinitalize (with new file list) self.distribution.reinitialize_command('install_data', True) -- cgit v1.2.3