Commit 30965bb2 by Sébastien Eustace

Fix virtualenv detection

parent 77618678
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
### Fixed ### Fixed
- Fixed possible error on some combinations of markers. - Fixed possible error on some combinations of markers.
- Fixed venv detection so that it only uses `VIRTUAL_ENV` to detect activated virtualenvs.
## [0.12.3] - 2018-10-18 ## [0.12.3] - 2018-10-18
......
...@@ -90,23 +90,19 @@ class Env(object): ...@@ -90,23 +90,19 @@ class Env(object):
return self._bin("pip") return self._bin("pip")
@classmethod @classmethod
def get(cls, reload=False, cwd=None): # type: (IO, bool) -> Env def get(cls, reload=False, cwd=None): # type: (bool, Path) -> Env
if cls._env is not None and not reload: if cls._env is not None and not reload:
return cls._env return cls._env
# Check if we are inside a virtualenv or not # Check if we are inside a virtualenv or not
in_venv = ( in_venv = os.environ.get("VIRTUAL_ENV") is not None
os.environ.get("VIRTUAL_ENV") is not None
or hasattr(sys, "real_prefix")
or (hasattr(sys, "base_prefix") and sys.base_prefix != sys.prefix)
)
if not in_venv: if not in_venv:
# Checking if a local virtualenv exists # Checking if a local virtualenv exists
if cwd and (cwd / ".venv").exists(): if cwd and (cwd / ".venv").exists():
venv = cwd / ".venv" venv = cwd / ".venv"
return VirtualEnv(Path(venv)) return VirtualEnv(venv)
config = Config.create("config.toml") config = Config.create("config.toml")
create_venv = config.setting("settings.virtualenvs.create", True) create_venv = config.setting("settings.virtualenvs.create", True)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment