diff --git a/changes/packaging.py b/changes/packaging.py index 7d7a48f..0f254dc 100644 --- a/changes/packaging.py +++ b/changes/packaging.py @@ -10,24 +10,19 @@ def install(): module_name, dry_run, new_version = config.common_arguments() - commands = ['setup.py', 'clean', 'bdist_wheel'] - - result = 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 - try: - print(package_name) - print(tmp_dir) - venv.install(package_name, 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) + commands = ['setup.py', 'clean', 'sdist', 'bdist_wheel'] + 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(): @@ -40,7 +35,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/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) 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)) 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={