Skip to content

Commit

Permalink
Merge pull request #1097 from techalchemy/bugfix/1002-allow-global-re…
Browse files Browse the repository at this point in the history
…solving

Pass 'allow_global' to resolve_deps
  • Loading branch information
kennethreitz committed Dec 18, 2017
2 parents ac89256 + 6163898 commit 546b399
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
7 changes: 4 additions & 3 deletions pipenv/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,8 @@ def do_lock(verbose=False, system=False, clear=False, pre=False):
which=which,
which_pip=which_pip,
project=project,
pre=pre
pre=pre,
allow_global=system
)

# Add develop dependencies to lockfile.
Expand Down Expand Up @@ -1092,7 +1093,8 @@ def do_lock(verbose=False, system=False, clear=False, pre=False):
which=which,
which_pip=which_pip,
project=project,
pre=pre
pre=pre,
allow_global=system
)

# Add default dependencies to lockfile.
Expand Down Expand Up @@ -2039,7 +2041,6 @@ def uninstall(
@click.option('--clear', is_flag=True, default=False, help="Clear the dependency cache.")
@click.option('--pre', is_flag=True, default=False, help=u"Allow pre–releases.")
def lock(three=None, python=False, verbose=False, requirements=False, dev=False, clear=False, pre=False):

# Ensure that virtualenv is available.
ensure_project(three=three, python=python)

Expand Down
4 changes: 2 additions & 2 deletions pipenv/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,15 +526,15 @@ class PipCommand(pip.basecommand.Command):
return resolved_tree, resolver


def resolve_deps(deps, which, which_pip, project, sources=None, verbose=False, python=False, clear=False, pre=False):
def resolve_deps(deps, which, which_pip, project, sources=None, verbose=False, python=False, clear=False, pre=False, allow_global=False):
"""Given a list of dependencies, return a resolved list of dependencies,
using pip-tools -- and their hashes, using the warehouse API / pip.
"""

index_lookup = {}
markers_lookup = {}

python_path = which('python')
python_path = which('python', allow_global=allow_global)
backup_python_path = shellquote(sys.executable)

results = []
Expand Down
28 changes: 28 additions & 0 deletions tests/test_pipenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,34 @@ def test_complex_deps_lock_and_install_properly(self):
assert c.return_code == 0

@pytest.mark.lock
@pytest.mark.install
@pytest.mark.system
@pytest.mark.skipif(os.name != 'posix', reason="Windows doesn't have a root")
def test_resolve_system_python_no_virtualenv(self):
"""Ensure we don't error out when we are in a folder off of / and doing an install using --system,
which used to cause the resolver and PIP_PYTHON_PATH to point at /bin/python
Sample dockerfile:
FROM python:3.6-alpine3.6
RUN set -ex && pip install pipenv --upgrade
RUN set -ex && mkdir /app
COPY Pipfile /app/Pipfile
WORKDIR /app
"""
with temp_environ():
os.environ['PIPENV_IGNORE_VIRTUALENVS'] = '1'
os.environ['PIPENV_USE_SYSTEM'] = '1'
with PipenvInstance(chdir=True) as p:
os.chdir('/tmp')
c = p.pipenv('install --system xlrd')
assert c.return_code == 0
for fn in ['Pipfile', 'Pipfile.lock']:
path = os.path.join('/tmp', fn)
if os.path.exists(path):
os.unlink(path)

@pytest.mark.requirements
@pytest.mark.complex
def test_complex_lock_changing_candidate(self):
Expand Down

0 comments on commit 546b399

Please sign in to comment.