From 57d341f03e39258fb6f32abd6c83dda45c534841 Mon Sep 17 00:00:00 2001 From: Michael Joseph Date: Mon, 14 Jul 2014 11:22:27 +0200 Subject: [PATCH 1/4] Install fabric, rm virtualenv --- requirements.txt | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index e3bb9b6..d358ee7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ +Fabric < 2.0.0 coverage < 4.0.0 docopt < 1.0.0 flake8 < 3.0.0 @@ -14,5 +15,4 @@ sphinxcontrib-httpdomain < 2.0.0 testtube < 1.0.0 tox < 2.0.0 unittest2 < 1.0.0 -virtualenv-api < 2.1.0 wheel < 1.0.0 diff --git a/setup.py b/setup.py index fcc46b5..ddbeaaa 100644 --- a/setup.py +++ b/setup.py @@ -14,11 +14,11 @@ url=metadata['url'], packages=['changes'], install_requires=[ + 'Fabric < 2.0.0', 'docopt < 1.0.0', 'path.py < 5.0.0', 'semantic_version < 3.0.0', 'sh < 2.0.0', - 'virtualenv < 2.0.0', 'wheel < 1.0.0', ], entry_points={ From ada17f5fa19973863121dbed6ca97ff44dfe4dab Mon Sep 17 00:00:00 2001 From: Michael Joseph Date: Mon, 14 Jul 2014 11:24:59 +0200 Subject: [PATCH 2/4] Use fabric to create a tmp venv and install --- changes/packaging.py | 19 ++++++++----------- changes/venv.py | 9 +++------ 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/changes/packaging.py b/changes/packaging.py index 7d7a48f..0d44331 100644 --- a/changes/packaging.py +++ b/changes/packaging.py @@ -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(): @@ -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) diff --git a/changes/venv.py b/changes/venv.py index 3e1f6c0..46e8126 100644 --- a/changes/venv.py +++ b/changes/venv.py @@ -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)) From f576c0271d63623c8dafc609cc6549e4dc697add Mon Sep 17 00:00:00 2001 From: Michael Joseph Date: Mon, 14 Jul 2014 11:25:20 +0200 Subject: [PATCH 3/4] Fix tests --- changes/shell.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/changes/shell.py b/changes/shell.py index acd1412..1cfc579 100644 --- a/changes/shell.py +++ b/changes/shell.py @@ -6,12 +6,12 @@ log = logging.getLogger(__name__) -def handle_dry_run(function, *args): +def handle_dry_run(fn, *args): if not config.arguments.get('--dry-run', True): - return function(*args) + return fn(*args) else: - log.debug('dry run of %s %s, skipping' % (function, args)) - return True + log.debug('dry run of %s %s, skipping' % (fn, args)) + return True def execute(command, dry_run=True): @@ -19,7 +19,7 @@ def execute(command, dry_run=True): try: return check_output(command.split(' ')).split('\n') except CalledProcessError as e: - log.debug('return code: %s, output: %s', e.returncode, e.output) + log.error('return code: %s, output: %s', e.returncode, e.output) return False else: log.debug('dry run of %s, skipping' % command) From 7f514a05cdf7717998cddf7819995163c82e6923 Mon Sep 17 00:00:00 2001 From: Michael Joseph Date: Mon, 14 Jul 2014 11:30:04 +0200 Subject: [PATCH 4/4] Improve error handling --- changes/packaging.py | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/changes/packaging.py b/changes/packaging.py index 0d44331..0f254dc 100644 --- a/changes/packaging.py +++ b/changes/packaging.py @@ -11,20 +11,18 @@ def install(): module_name, dry_run, new_version = config.common_arguments() commands = ['setup.py', 'clean', 'sdist', 'bdist_wheel'] - - shell.handle_dry_run(sh.python, tuple(commands)) - - with util.mktmpdir() as tmp_dir: - venv.create_venv(tmp_dir=tmp_dir) - for distribution in path('dist').files(): - try: - 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 distribution %s' % distribution, e) + try: + if (shell.handle_dry_run(sh.python, tuple(commands))): + with util.mktmpdir() as tmp_dir: + venv.create_venv(tmp_dir=tmp_dir) + for distribution in path('dist').files(): + 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 distribution %s' % distribution, e) def upload():