Skip to content

Commit be85c33

Browse files
committed
Merge branch 'main' of github.com:pypa/pipenv
2 parents 861c01b + 91ddb2d commit be85c33

File tree

6 files changed

+62
-43
lines changed

6 files changed

+62
-43
lines changed

README.md

+44-42
Original file line numberDiff line numberDiff line change
@@ -150,35 +150,36 @@ Magic shell completions are now enabled!
150150
☤ Usage
151151
-------
152152

153-
$ pipenv --help
154-
Usage: pipenv [OPTIONS] COMMAND [ARGS]...
155-
156-
Options:
157-
--where Output project home information.
158-
--venv Output virtualenv information.
159-
--py Output Python interpreter information.
160-
--envs Output Environment Variable options.
161-
--rm Remove the virtualenv.
162-
--bare Minimal output.
163-
--man Display manpage.
164-
--support Output diagnostic information for use in
165-
GitHub issues.
166-
--site-packages / --no-site-packages
167-
Enable site-packages for the virtualenv.
168-
[env var: PIPENV_SITE_PACKAGES]
169-
--python TEXT Specify which version of Python virtualenv
170-
should use.
171-
--three Use Python 3 when creating virtualenv.
172-
--clear Clears caches (pipenv, pip). [env var:
173-
PIPENV_CLEAR]
174-
-q, --quiet Quiet mode.
175-
-v, --verbose Verbose mode.
176-
--pypi-mirror TEXT Specify a PyPI mirror.
177-
--version Show the version and exit.
178-
-h, --help Show this message and exit.
153+
$ pipenv --help
154+
Usage: pipenv [OPTIONS] COMMAND [ARGS]...
155+
156+
Options:
157+
--where Output project home information.
158+
--venv Output virtualenv information.
159+
--py Output Python interpreter information.
160+
--envs Output Environment Variable options.
161+
--rm Remove the virtualenv.
162+
--bare Minimal output.
163+
--man Display manpage.
164+
--support Output diagnostic information for use in
165+
GitHub issues.
166+
--site-packages / --no-site-packages
167+
Enable site-packages for the virtualenv.
168+
[env var: PIPENV_SITE_PACKAGES]
169+
--python TEXT Specify which version of Python virtualenv
170+
should use.
171+
--three Use Python 3 when creating virtualenv.
172+
--clear Clears caches (pipenv, pip). [env var:
173+
PIPENV_CLEAR]
174+
-q, --quiet Quiet mode.
175+
-v, --verbose Verbose mode.
176+
--pypi-mirror TEXT Specify a PyPI mirror.
177+
--version Show the version and exit.
178+
-h, --help Show this message and exit.
179179

180180

181181
Usage Examples:
182+
182183
Create a new project using Python 3.7, specifically:
183184
$ pipenv --python 3.7
184185

@@ -204,22 +205,23 @@ Magic shell completions are now enabled!
204205
$ pipenv run pip freeze
205206

206207
Commands:
207-
check Checks for PyUp Safety security vulnerabilities and against
208-
PEP 508 markers provided in Pipfile.
209-
clean Uninstalls all packages not specified in Pipfile.lock.
210-
graph Displays currently-installed dependency graph information.
211-
install Installs provided packages and adds them to Pipfile, or (if no
212-
packages are given), installs all packages from Pipfile.
213-
lock Generates Pipfile.lock.
214-
open View a given module in your editor.
215-
requirements Generate a requirements.txt from Pipfile.lock.
216-
run Spawns a command installed into the virtualenv.
217-
scripts Lists scripts in current environment config.
218-
shell Spawns a shell within the virtualenv.
219-
sync Installs all packages specified in Pipfile.lock.
220-
uninstall Uninstalls a provided package and removes it from Pipfile.
221-
update Runs lock, then sync.
222-
verify Verify the hash in Pipfile.lock is up-to-date.
208+
209+
check Checks for PyUp Safety security vulnerabilities and against
210+
PEP 508 markers provided in Pipfile.
211+
clean Uninstalls all packages not specified in Pipfile.lock.
212+
graph Displays currently-installed dependency graph information.
213+
install Installs provided packages and adds them to Pipfile, or (if no
214+
packages are given), installs all packages from Pipfile.
215+
lock Generates Pipfile.lock.
216+
open View a given module in your editor.
217+
requirements Generate a requirements.txt from Pipfile.lock.
218+
run Spawns a command installed into the virtualenv.
219+
scripts Lists scripts in current environment config.
220+
shell Spawns a shell within the virtualenv.
221+
sync Installs all packages specified in Pipfile.lock.
222+
uninstall Uninstalls a provided package and removes it from Pipfile.
223+
update Runs lock, then sync.
224+
verify Verify the hash in Pipfile.lock is up-to-date.
223225

224226

225227
Locate the project:

news/5296.bugfix.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix an issue when using ``pipenv install --system`` on systems that having the ``python`` executable pointing to Python 2 and a Python 3 executable being ``python3``.

news/5299.bugfix.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Sorting ``constraints`` before resolving, which fixes ``pipenv lock`` generates nondeterminism environment markers.

pipenv/utils/resolver.py

+1
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,7 @@ def constraints(self):
647647
# Only use default_constraints when installing dev-packages
648648
if self.dev:
649649
self._constraints += self.default_constraints
650+
self._constraints.sort(key=lambda ireq: ireq.name)
650651
return self._constraints
651652

652653
@contextlib.contextmanager

pipenv/utils/shell.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ def project_python(project, system=False):
445445
if not system:
446446
python = project._which("python")
447447
else:
448-
interpreters = [system_which(p) for p in ("python", "python3")]
448+
interpreters = [system_which(p) for p in ("python3", "python")]
449449
interpreters = [i for i in interpreters if i] # filter out not found interpreters
450450
python = interpreters[0] if interpreters else None
451451
if not python:

tests/unit/test_utils.py

+14
Original file line numberDiff line numberDiff line change
@@ -458,3 +458,17 @@ def test_invalid_prepare_pip_source_args(self):
458458
sources = [{}]
459459
with pytest.raises(PipenvUsageError):
460460
indexes.prepare_pip_source_args(sources, pip_args=None)
461+
462+
@pytest.mark.utils
463+
def test_project_python_tries_python3_before_python_if_system_is_true(self):
464+
def mock_shutil_which(command, path=None):
465+
if command != "python3":
466+
return f"/usr/bin/{command}"
467+
return "/usr/local/bin/python3"
468+
469+
with mock.patch("pipenv.utils.shell.shutil.which", wraps=mock_shutil_which):
470+
# Setting project to None as system=True doesn't use it
471+
project = None
472+
python = shell.project_python(project, system=True)
473+
474+
assert python == "/usr/local/bin/python3"

0 commit comments

Comments
 (0)