summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2014-11-21 12:18:13 -0800
committerJoshua Harlow <harlowja@yahoo-inc.com>2014-11-21 12:18:13 -0800
commit97869ce751f81776ac5d57d1f566b419b836455f (patch)
tree42d57ea5491ae7d86e3d6f48f9d1d119fa7cdbf9
parent3efc7142a6ca72bfb40e63c49ed64e2e04837c51 (diff)
parentce80e672caa299afe786a852afa986abfa28e633 (diff)
downloadvyos-cloud-init-97869ce751f81776ac5d57d1f566b419b836455f.tar.gz
vyos-cloud-init-97869ce751f81776ac5d57d1f566b419b836455f.zip
Only use datafiles and initsys addon outside virtualenvs
To make it so that cloud-init is installable in a virtualenv where it can be tested in an isolated scenario we need to avoid using and including datafiles (which won't be written into the virtualenv) and also avoid using our initsys helper class which also adds on its own files when we are being ran from a virtualenv.
-rw-r--r--ChangeLog1
-rwxr-xr-xsetup.py55
2 files changed, 38 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index 1debc923..e861be23 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,7 @@
- begin adding cloud config module docs to config modules (LP: #1383510)
- retain trailing eol from template files (sources.list) when
rendered with jinja (LP: #1355343)
+ - Only use datafiles and initsys addon outside virtualenvs
0.7.6:
- open 0.7.6
- Enable vendordata on CloudSigma datasource (LP: #1303986)
diff --git a/setup.py b/setup.py
index bd41bc91..3e188089 100755
--- a/setup.py
+++ b/setup.py
@@ -23,6 +23,7 @@
from glob import glob
import os
+import sys
import setuptools
from setuptools.command.install import install
@@ -86,6 +87,17 @@ if os.uname()[0] == 'FreeBSD':
ETC = "/usr/local/etc"
+# Avoid having datafiles installed in a virtualenv...
+def in_virtualenv():
+ try:
+ if sys.real_prefix == sys.prefix:
+ return False
+ else:
+ return True
+ except AttributeError:
+ return False
+
+
def get_version():
cmd = ['tools/read-version']
(ver, _e) = tiny_p(cmd)
@@ -135,6 +147,29 @@ class InitsysInstallData(install):
self.distribution.reinitialize_command('install_data', True)
+if in_virtualenv():
+ data_files = []
+ cmdclass = {}
+else:
+ data_files = [
+ (ETC + '/cloud', glob('config/*.cfg')),
+ (ETC + '/cloud/cloud.cfg.d', glob('config/cloud.cfg.d/*')),
+ (ETC + '/cloud/templates', glob('templates/*')),
+ (USR + '/lib/cloud-init', ['tools/uncloud-init',
+ 'tools/write-ssh-key-fingerprints']),
+ (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',
+ [f for f in glob('doc/examples/seed/*') if is_f(f)]),
+ ]
+ # Use a subclass for install that handles
+ # adding on the right init system configuration files
+ cmdclass = {
+ 'install': InitsysInstallData,
+ }
+
+
setuptools.setup(name='cloud-init',
version=get_version(),
description='EC2 initialisation magic',
@@ -146,23 +181,7 @@ setuptools.setup(name='cloud-init',
'tools/cloud-init-per',
],
license='GPLv3',
- data_files=[(ETC + '/cloud', glob('config/*.cfg')),
- (ETC + '/cloud/cloud.cfg.d', glob('config/cloud.cfg.d/*')),
- (ETC + '/cloud/templates', glob('templates/*')),
- (USR + '/lib/cloud-init',
- ['tools/uncloud-init',
- 'tools/write-ssh-key-fingerprints']),
- (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',
- [f for f in glob('doc/examples/seed/*') if is_f(f)]),
- ],
+ data_files=data_files,
install_requires=read_requires(),
- cmdclass={
- # Use a subclass for install that handles
- # adding on the right init system configuration files
- 'install': InitsysInstallData,
- },
+ cmdclass=cmdclass,
)