Skip to content

Commit

Permalink
Merge pull request #14 from gtalarico/fix-python-version
Browse files Browse the repository at this point in the history
Fix get python version calls
  • Loading branch information
gtalarico committed May 16, 2018
2 parents d721d5b + 7108026 commit 279875b
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 15 deletions.
10 changes: 10 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
History
=======

0.6.1 (2018-05-15)
--------------------------
* Fix Python binary version detect call


0.6.0 (2018-05-15)
--------------------------
* Added completion helper flag and completion docs


0.5.1 (2018-05-13)
--------------------------
* Bug fix: Setup.py missing picker package
Expand Down
7 changes: 4 additions & 3 deletions pipenv_pipes/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,12 @@ def find_binary(envpath):
def get_binary_version(envpath):
""" Returns a string indicating the Python version (Python 3.5.6) """
pybinpath = find_binary(envpath)
version, code = call_python_version(pybinpath)
output, code = call_python_version(pybinpath)
if not code:
return version
return output
else:
raise EnvironmentError('could not get binary version')
raise EnvironmentError(
'could not get binary version: {}'.format(output))


###############################
Expand Down
5 changes: 4 additions & 1 deletion pipenv_pipes/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
""" Pipes: Pipenv Shell Switcher """

import os
import sys


class EnvVars():

def __init__(self):
self.IS_WINDOWS = os.name == 'nt'
self.IS_WINDOWS = sys.platform == 'win32'
self.IS_MAC = sys.platform == 'darwin'
self.IS_LINUX = sys.platform == 'linux'

if self.IS_WINDOWS:
default_home = '~/.virtualenvs'
Expand Down
2 changes: 1 addition & 1 deletion pipenv_pipes/pipenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ def call_pipenv_shell(cwd, envname='pipenv-shell', timeout=None):
def call_python_version(pybinpath):
# TODO Rename this module
binpath = os.path.dirname(pybinpath)
output, code = PipedPopen(cmds=['python', '--version'], cwd=binpath)
output, code = PipedPopen(cmds=['./python', '--version'], cwd=binpath)
return output, code
6 changes: 3 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[bumpversion]
current_version = 0.6.0-beta1
current_version = 0.6.0
commit = True
tag = True
message = Bump version: {current_version} -> {new_version}
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+)\.(?P<num>\d+))?
serialize =
serialize =
{major}.{minor}.{patch}-{release}.{num}
{major}.{minor}.{patch}

[bumpversion:part:release]
first_value = alpha
optional_value = alpha
values =
values =
alpha
beta
rc
Expand Down
20 changes: 13 additions & 7 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest
import os
import sys
from contextlib import contextmanager
from tempfile import TemporaryDirectory
import shutil
Expand All @@ -12,7 +13,7 @@
find_environments,
write_project_dir_project_file,
)

from pipenv_pipes.environment import EnvVars

HERE = os.path.dirname(__file__)
VENVS_ARCHIVE = os.path.join(HERE, 'venvs')
Expand All @@ -31,19 +32,24 @@ def unzip_tar(src, dst):


@pytest.fixture
def venv_archive_path():
filename = 'unix.tar.gz'
if 'nt' in os.name:
filename = 'win.tar.gz'
def env_vars():
return EnvVars()


@pytest.fixture
def venv_archive_path(env_vars):
""" Note: This provides a path to zipped envs create for the
for the purpose of optimizing test run time """
filename = '{}.tar.gz'.format(sys.platform)
return os.path.join(VENVS_ARCHIVE, filename)


@pytest.fixture
def win_tempdir():
def win_tempdir(env_vars):
# Default %TEMP% returns windows short path (C:\\Users\\GTALAR~1\\AppData)
# The`~1`` breaks --venv hash resolution, so we must build path manually
# On other systems this will be none, so default env will be used
if 'nt' not in os.name:
if not env_vars.IS_WINDOWS:
return None
path = os.path.join(os.environ['USERPROFILE'], 'AppData', 'Local', 'Temp')
assert '~' not in path
Expand Down
File renamed without changes.
Binary file added tests/venvs/linux.tar.gz
Binary file not shown.
File renamed without changes.

0 comments on commit 279875b

Please sign in to comment.