Skip to content

Commit

Permalink
make_virtualenv: support 2.6 (#23)
Browse files Browse the repository at this point in the history
* make_virtualenv: support 2.6

:(

* Repo paths
  • Loading branch information
tehasdf authored May 7, 2019
1 parent 4c4d1d7 commit 7af6799
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 7 deletions.
1 change: 0 additions & 1 deletion agent_packager/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
__author__ = 'nir0s'
2 changes: 1 addition & 1 deletion agent_packager/tests/resources/bad_config_file.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
distribution: Ubuntu
version: 3.0
venv: /home/nir0s/Ubuntu-agent/env
venv: /tmp/venv
6 changes: 3 additions & 3 deletions agent_packager/tests/resources/config_file.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ release: trusty
python_path: '/usr/bin/python'
requirements_file: 'agent_packager/tests/resources/requirements.txt'
# cloudify_agent_version: 3.1
cloudify_agent_module: https://github.com/nir0s/cloudify-agent/archive/master.tar.gz
cloudify_agent_module: https://github.com/cloudify-cosmo/cloudify-agent/archive/master.tar.gz
core_modules:
cloudify_plugins_common: https://github.com/cloudify-cosmo/cloudify-plugins-common/archive/3.1.tar.gz
cloudify_plugins_common: https://github.com/cloudify-cosmo/cloudify-common/archive/master.tar.gz
# cloudify_rest_client: https://github.com/cloudify-cosmo/cloudify-rest-client/archive/3.1.tar.gz
core_plugins:
cloudify_script_plugin: exclude
Expand All @@ -17,6 +17,6 @@ core_plugins:
additional_modules:
- pyyaml==3.10
additional_plugins:
cloudify-fabric-plugin: https://github.com/cloudify-cosmo/cloudify-fabric-plugin/archive/1.1.tar.gz
cloudify-fabric-plugin: https://github.com/cloudify-cosmo/cloudify-fabric-plugin/archive/master.tar.gz
output_tar: Ubuntu-trusty-agent.tar.gz
keep_virtualenv: true
20 changes: 19 additions & 1 deletion agent_packager/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,29 @@ def make_virtualenv(virtualenv_dir, python='/usr/bin/python'):
:param string virtualenv_dir: path of virtualenv to create
"""
lgr.debug('virtualenv_dir: {0}'.format(virtualenv_dir))
p = run('virtualenv -p {0} {1}'.format(python, virtualenv_dir))
command = 'virtualenv -p {0} {1}'.format(python, virtualenv_dir)

if sys.version_info[:2] == (2, 6):
# python 2.6 will fail when creating a virtualenv because it will
# attempt to install the newest setuptools version which does not
# support 2.6. Fall back to not installing setuptools automatically,
# but we'll install it separately after creating the venv, with
# the last version that did support 2.6.
command += ' --no-setuptools'

p = run(command)
if not p.returncode == 0:
lgr.error('Could not create venv: {0}'.format(virtualenv_dir))
sys.exit(codes.errors['could_not_create_virtualenv'])

if sys.version_info[:2] == (2, 6):
p = run('{0}/bin/pip install setuptools==36.8.0'
.format(virtualenv_dir))
if not p.returncode == 0:
lgr.error('Could not install setuptools into venv: {0}'
.format(virtualenv_dir))
sys.exit(codes.errors['could_not_create_virtualenv'])


def install_module(module, venv):
"""installs a module in a virtualenv
Expand Down
2 changes: 1 addition & 1 deletion config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ requirements_file: 'agent_packager/tests/resources/requirements.txt'
# cloudify_agent_version: 3.1
cloudify_agent_module: https://github.com/nir0s/cloudify-agent/archive/master.tar.gz
core_modules:
cloudify_plugins_common: https://github.com/cloudify-cosmo/cloudify-plugins-common/archive/3.1.tar.gz
cloudify_plugins_common: https://github.com/cloudify-cosmo/cloudify-common/archive/master.tar.gz
# cloudify_rest_client: https://github.com/cloudify-cosmo/cloudify-rest-client/archive/3.1.tar.gz
core_plugins:
cloudify_script_plugin: exclude
Expand Down

0 comments on commit 7af6799

Please sign in to comment.