mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
Merge branch 'master' into 3722/fix-all-dev-uninstalls-shared-dependencies
This commit is contained in:
@@ -0,0 +1 @@
|
||||
Fix a bug that incorrect Python path will be used when ``--system`` flag is on.
|
||||
@@ -0,0 +1 @@
|
||||
Fix falsely flagging a Homebrew installed Python as a virtual environment
|
||||
@@ -1946,6 +1946,8 @@ def do_install(
|
||||
# Automatically use an activated virtualenv.
|
||||
if PIPENV_USE_SYSTEM:
|
||||
system = True
|
||||
if system:
|
||||
os.environ["PIPENV_USE_SYSTEM"] = "1"
|
||||
# Check if the file is remote or not
|
||||
if remote:
|
||||
click.echo(
|
||||
|
||||
+12
-2
@@ -41,6 +41,7 @@ class Environment(object):
|
||||
def __init__(
|
||||
self,
|
||||
prefix=None, # type: Optional[str]
|
||||
python=None, # type: Optional[str]
|
||||
is_venv=False, # type: bool
|
||||
base_working_set=None, # type: pkg_resources.WorkingSet
|
||||
pipfile=None, # type: Optional[Union[tomlkit.toml_document.TOMLDocument, TPipfile]]
|
||||
@@ -51,6 +52,9 @@ class Environment(object):
|
||||
self._modules = {'pkg_resources': pkg_resources, 'pipenv': pipenv}
|
||||
self.base_working_set = base_working_set if base_working_set else BASE_WORKING_SET
|
||||
prefix = normalize_path(prefix)
|
||||
self._python = None
|
||||
if python is not None:
|
||||
self._python = vistir.compat.Path(python).absolute().as_posix()
|
||||
self.is_venv = is_venv or prefix != normalize_path(sys.prefix)
|
||||
if not sources:
|
||||
sources = []
|
||||
@@ -267,9 +271,15 @@ class Environment(object):
|
||||
def python(self):
|
||||
# type: () -> str
|
||||
"""Path to the environment python"""
|
||||
py = vistir.compat.Path(self.script_basedir).joinpath("python").absolute().as_posix()
|
||||
if self._python is not None:
|
||||
return self._python
|
||||
if os.name == "nt" and not self.is_venv:
|
||||
py = vistir.compat.Path(self.prefix).joinpath("python").absolute().as_posix()
|
||||
else:
|
||||
py = vistir.compat.Path(self.script_basedir).joinpath("python").absolute().as_posix()
|
||||
if not py:
|
||||
return vistir.compat.Path(sys.executable).as_posix()
|
||||
py = vistir.compat.Path(sys.executable).as_posix()
|
||||
self._python = py
|
||||
return py
|
||||
|
||||
@cached_property
|
||||
|
||||
@@ -81,7 +81,7 @@ PIPENV_IS_CI = bool("CI" in os.environ or "TF_BUILD" in os.environ)
|
||||
|
||||
# HACK: Prevent invalid shebangs with Homebrew-installed Python:
|
||||
# https://bugs.python.org/issue22490
|
||||
_OSX_VENV = os.environ.pop("__PYVENV_LAUNCHER__", None)
|
||||
os.environ.pop("__PYVENV_LAUNCHER__", None)
|
||||
|
||||
# Load patched pip instead of system pip
|
||||
os.environ["PIP_SHIMS_BASE_MODULE"] = fs_str("pipenv.patched.notpip")
|
||||
@@ -326,7 +326,7 @@ PIPENV_TEST_INDEX = os.environ.get("PIPENV_TEST_INDEX")
|
||||
PIPENV_USE_SYSTEM = False
|
||||
PIPENV_VIRTUALENV = None
|
||||
if "PIPENV_ACTIVE" not in os.environ and not PIPENV_IGNORE_VIRTUALENVS:
|
||||
PIPENV_VIRTUALENV = os.environ.get("VIRTUAL_ENV") or _OSX_VENV
|
||||
PIPENV_VIRTUALENV = os.environ.get("VIRTUAL_ENV")
|
||||
PIPENV_USE_SYSTEM = bool(PIPENV_VIRTUALENV)
|
||||
|
||||
# Internal, tells Pipenv to skip case-checking (slow internet connections).
|
||||
@@ -370,7 +370,7 @@ def is_quiet(threshold=-1):
|
||||
def _is_using_venv():
|
||||
# type: () -> bool
|
||||
"""Check for venv-based virtual environment which sets sys.base_prefix"""
|
||||
return _OSX_VENV is not None or sys.prefix != getattr(sys, "base_prefix", sys.prefix)
|
||||
return sys.prefix != getattr(sys, "base_prefix", sys.prefix)
|
||||
|
||||
|
||||
def _is_using_virtualenv():
|
||||
|
||||
+4
-2
@@ -352,12 +352,14 @@ class Project(object):
|
||||
is_venv = is_in_virtualenv()
|
||||
if allow_global and not is_venv:
|
||||
prefix = sys.prefix
|
||||
python = sys.executable
|
||||
else:
|
||||
prefix = self.virtualenv_location
|
||||
python = None
|
||||
sources = self.sources if self.sources else [DEFAULT_SOURCE]
|
||||
environment = Environment(
|
||||
prefix=prefix, is_venv=is_venv, sources=sources, pipfile=self.parsed_pipfile,
|
||||
project=self
|
||||
prefix=prefix, python=python, is_venv=is_venv, sources=sources,
|
||||
pipfile=self.parsed_pipfile, project=self
|
||||
)
|
||||
pipenv_dist = get_pipenv_dist(pkg="pipenv")
|
||||
if pipenv_dist:
|
||||
|
||||
Reference in New Issue
Block a user