Skip to content

Commit 744b8e0

Browse files
committed
Merge pull request #38 from cloudify-cosmo/36-use-correct-python-executable
36 use correct python executable
2 parents fde6717 + 6d4b4d6 commit 744b8e0

File tree

5 files changed

+39
-34
lines changed

5 files changed

+39
-34
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,6 @@ coverage.xml
5353
docs/_build/
5454

5555
*.iml
56+
.idea/*
5657

5758
*COMMIT_MSG

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
# * See the License for the specific language governing permissions and
1414
# * limitations under the License.
1515

16-
from setuptools import setup
1716
import os
1817
import codecs
18+
from setuptools import setup
1919

2020
here = os.path.abspath(os.path.dirname(__file__))
2121

@@ -27,13 +27,13 @@ def read(*parts):
2727

2828
setup(
2929
name='wagon',
30-
version='0.3.0',
30+
version='0.3.1',
3131
url='https://github.com/cloudify-cosmo/wagon',
3232
author='Gigaspaces',
3333
author_email='cosmo-admin@gigaspaces.com',
3434
license='LICENSE',
3535
platforms='All',
36-
description='Creates Python Wheel based archives.',
36+
description='Creates Python Wheel based archives with dependencies.',
3737
long_description=read('README.rst'),
3838
packages=['wagon'],
3939
include_package_data=True,

wagon/tests/test_wagon.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@
1313
# * See the License for the specific language governing permissions and
1414
# * limitations under the License.
1515

16-
import click.testing as clicktest
17-
from contextlib import closing
18-
import tarfile
19-
import testtools
2016
import os
2117
import json
2218
import shutil
19+
import tarfile
2320
import tempfile
21+
from contextlib import closing
22+
23+
import testtools
24+
import click.testing as clicktest
2425

2526
import wagon.wagon as wagon
2627
import wagon.utils as utils
@@ -51,12 +52,12 @@ def _invoke_click(func, args_dict):
5152
class TestUtils(testtools.TestCase):
5253

5354
def test_run(self):
54-
p = utils.run('uname')
55-
self.assertEqual(0, p.returncode)
55+
proc = utils.run('uname')
56+
self.assertEqual(0, proc.returncode)
5657

5758
def test_run_bad_command(self):
58-
p = utils.run('suname')
59-
self.assertEqual(1 if utils.IS_WIN else 127, p.returncode)
59+
proc = utils.run('suname')
60+
self.assertEqual(1 if utils.IS_WIN else 127, proc.returncode)
6061

6162
def test_download_file(self):
6263
utils.download_file(TEST_FILE, 'file')
@@ -163,7 +164,6 @@ class TestCreate(testtools.TestCase):
163164

164165
def setUp(self):
165166
super(TestCreate, self).setUp()
166-
self.runner = clicktest.CliRunner()
167167
self.wagon = wagon.Wagon(TEST_PACKAGE, verbose=True)
168168
if utils.IS_WIN:
169169
self.wagon.platform = 'win32'
@@ -381,7 +381,6 @@ class TestInstall(testtools.TestCase):
381381

382382
def setUp(self):
383383
super(TestInstall, self).setUp()
384-
self.runner = clicktest.CliRunner()
385384
self.packager = wagon.Wagon(TEST_PACKAGE, verbose=True)
386385
utils.run('virtualenv test_env')
387386
self.archive_path = self.packager.create(force=True)
@@ -408,7 +407,6 @@ class TestValidate(testtools.TestCase):
408407

409408
def setUp(self):
410409
super(TestValidate, self).setUp()
411-
self.runner = clicktest.CliRunner()
412410
self.packager = wagon.Wagon(TEST_PACKAGE, verbose=True)
413411
self.archive_path = self.packager.create(force=True)
414412
utils.untar(self.archive_path, '.')

wagon/utils.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@
1414
# * limitations under the License.
1515

1616
import os
17-
import subprocess
1817
import re
18+
import sys
19+
import time
20+
import json
1921
import urllib
22+
import shutil
2023
import tarfile
2124
import zipfile
2225
import logging
23-
from threading import Thread
24-
import time
25-
import sys
26-
from contextlib import closing
2726
import platform
2827
import tempfile
29-
import json
30-
import shutil
28+
import subprocess
29+
from threading import Thread
30+
from contextlib import closing
3131

3232
from wheel import pep425tags as wheel_tags
3333

@@ -40,7 +40,7 @@
4040
PLATFORM = sys.platform
4141
IS_WIN = (os.name == 'nt')
4242
IS_DARWIN = (PLATFORM == 'darwin')
43-
IS_LINUX = (PLATFORM == 'linux2')
43+
IS_LINUX = PLATFORM.startswith('linux')
4444

4545
PROCESS_POLLING_INTERVAL = 0.1
4646

@@ -98,7 +98,8 @@ def run(cmd, suppress_errors=False, suppress_output=False):
9898
def wheel(package, requirement_files=False, wheels_path='package',
9999
excluded_packages=None, wheel_args=None, no_deps=False):
100100
lgr.info('Downloading Wheels for {0}...'.format(package))
101-
wheel_cmd = ['pip', 'wheel']
101+
pip_executable = os.path.join(os.path.dirname(sys.executable), 'pip')
102+
wheel_cmd = [pip_executable, 'wheel']
102103
wheel_cmd.append('--wheel-dir={0}'.format(wheels_path))
103104
wheel_cmd.append('--find-links={0}'.format(wheels_path))
104105
if no_deps:
@@ -121,6 +122,7 @@ def wheel(package, requirement_files=False, wheels_path='package',
121122
lgr.error('Could not download wheels for: {0}. '
122123
'Please verify that the package you are trying '
123124
'to wheel is wheelable.'.format(package))
125+
lgr.error(p.aggr_stdout)
124126
sys.exit(codes.errors['failed_to_wheel'])
125127
wheels = get_downloaded_wheels(wheels_path)
126128
excluded_packages = excluded_packages or []
@@ -158,9 +160,10 @@ def install_package(package, wheels_path, virtualenv_path=None,
158160
# install_args = install_args or []
159161

160162
lgr.info('Installing {0}...'.format(package))
161-
162-
pip_cmd = ['pip', 'install']
163+
pip_executable = os.path.join(os.path.dirname(sys.executable), 'pip')
164+
pip_cmd = [pip_executable, 'install']
163165
if virtualenv_path:
166+
pip_cmd = ['pip', 'install']
164167
pip_cmd[0] = os.path.join(
165168
_get_env_bin_path(virtualenv_path), pip_cmd[0])
166169
if requirements_file:
@@ -286,8 +289,11 @@ def _get_env_bin_path(env_path):
286289
def check_installed(package, virtualenv):
287290
"""Checks to see if a package is installed within a virtualenv.
288291
"""
289-
pip_path = os.path.join(_get_env_bin_path(virtualenv), 'pip')
290-
p = run('{0} freeze'.format(pip_path), suppress_output=True)
292+
if virtualenv:
293+
pip_executable = os.path.join(_get_env_bin_path(virtualenv), 'pip')
294+
else:
295+
pip_executable = os.path.join(os.path.dirname(sys.executable), 'pip')
296+
p = run('{0} freeze'.format(pip_executable), suppress_output=True)
291297
if re.search(r'{0}'.format(package), p.aggr_stdout.lower()):
292298
lgr.debug('Package {0} is installed in {1}'.format(
293299
package, virtualenv))

wagon/wagon.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
# * See the License for the specific language governing permissions and
1414
# * limitations under the License.
1515

16-
import logging
1716
import os
1817
import sys
18+
import json
1919
import shutil
20+
import logging
2021
import tempfile
21-
import json
2222

2323
import click
2424

@@ -403,10 +403,10 @@ def get_source_name_and_version(self, source):
403403
if os.path.isfile(os.path.join(source, 'setup.py')):
404404
lgr.debug('setup.py file found. Retrieving name and version...')
405405
setuppy_path = os.path.join(source, 'setup.py')
406-
self.name = utils.run('python {0} --name'.format(
407-
setuppy_path)).aggr_stdout.rstrip('\r\n')
408-
self.version = utils.run('python {0} --version'.format(
409-
setuppy_path)).aggr_stdout.rstrip('\r\n')
406+
self.name = utils.run('{0} {1} --name'.format(
407+
sys.executable, setuppy_path)).aggr_stdout.rstrip('\r\n')
408+
self.version = utils.run('{0} {1} --version'.format(
409+
sys.executable, setuppy_path)).aggr_stdout.rstrip('\r\n')
410410
# TODO: maybe we don't want to be that explicit and allow using >=
411411
elif '==' in source:
412412
self.name, self.version = source.split('==')
@@ -543,7 +543,7 @@ def validate(source, verbose):
543543
logger.configure()
544544
validator = Wagon(source, verbose)
545545
if not validator.validate():
546-
sys.exit('validation_failed')
546+
sys.exit(codes.errors['validation_failed'])
547547

548548

549549
@click.command()

0 commit comments

Comments
 (0)