Skip to content

Commit

Permalink
Use fabric to create a tmp venv and install
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljoseph committed Jul 14, 2014
1 parent 57d341f commit ada17f5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
19 changes: 8 additions & 11 deletions changes/packaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,21 @@

def install():
module_name, dry_run, new_version = config.common_arguments()
commands = ['setup.py', 'clean', 'bdist_wheel']
commands = ['setup.py', 'clean', 'sdist', 'bdist_wheel']

result = shell.handle_dry_run(sh.python, tuple(commands))
shell.handle_dry_run(sh.python, tuple(commands))

if result:
with util.mktmpdir() as tmp_dir:
venv.create_venv(tmp_dir=tmp_dir)
package_name = config.arguments.get('--package-name') or module_name
with util.mktmpdir() as tmp_dir:
venv.create_venv(tmp_dir=tmp_dir)
for distribution in path('dist').files():
try:
print(package_name)
print(tmp_dir)
venv.install(package_name, tmp_dir)
venv.install(distribution, tmp_dir)
log.info('Successfully installed %s sdist', module_name)
if verification.run_test_command():
log.info('Successfully ran test command: %s',
config.arguments['--test-command'])
except Exception, e:
raise Exception('Error installing %s sdist', module_name, e)
raise Exception('Error installing distribution %s' % distribution, e)


def upload():
Expand All @@ -40,7 +37,7 @@ def upload():

upload_result = shell.handle_dry_run(sh.python, tuple(upload_args))
if not upload_result:
raise Exception('Error uploading')
raise Exception('Error uploading: %s' % upload_result)
else:
log.info('Successfully uploaded %s %s', module_name, new_version)

Expand Down
9 changes: 3 additions & 6 deletions changes/venv.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
import os
import tempfile

import virtualenv
from fabric.api import local


def create_venv(tmp_dir=None):
if not tmp_dir:
tmp_dir = tempfile.mkdtemp()
virtualenv.create_environment(tmp_dir, site_packages=False)
local('virtualenv --no-site-packages %s' % tmp_dir)
return tmp_dir


def install(package_name, venv_dir):
if not os.path.exists(venv_dir):
venv_dir = create_venv()
virtualenv.install_wheel(
[package_name],
'%s/bin/python' % venv_dir,
)
local('%s/bin/pip install %s' % (venv_dir, package_name))

0 comments on commit ada17f5

Please sign in to comment.