Skip to content

Commit

Permalink
fix lockfile
Browse files Browse the repository at this point in the history
  • Loading branch information
frostming committed Mar 29, 2020
1 parent 63fa7b5 commit 76f34f2
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 8 deletions.
29 changes: 29 additions & 0 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions pdm/models/environment.py
Expand Up @@ -18,7 +18,6 @@

from pdm.exceptions import NoPythonVersion
from pdm.iostream import stream
from pdm.models.specifiers import PySpecSet
from pdm.utils import (
allow_all_wheels,
cached_property,
Expand Down Expand Up @@ -342,12 +341,6 @@ class GlobalEnvironment(Environment):

is_global = True

def __init__(self, project: Project) -> None:
super().__init__(project)
self.python_requires = PySpecSet(
"==" + get_python_version(self.python_executable, True)
)

def get_paths(self) -> Dict[str, str]:
paths = get_sys_config_paths(self.python_executable)
paths["prefix"] = paths["data"]
Expand Down
9 changes: 8 additions & 1 deletion pdm/project/core.py
Expand Up @@ -29,6 +29,7 @@
atomic_open_for_write,
cached_property,
find_project_root,
get_python_version,
get_venv_python,
)

Expand Down Expand Up @@ -141,7 +142,13 @@ def is_pdm(self) -> bool:
@cached_property
def environment(self) -> Environment:
if self.is_global:
return GlobalEnvironment(self)
env = GlobalEnvironment(self)
# Rewrite global project's python requires to be
# compatible with the exact version
env.python_requires = PySpecSet(
"==" + get_python_version(env.python_executable, True)
)
return env
if self.config["use_venv"] and "VIRTUAL_ENV" in os.environ:
self.project_config["python.path"] = get_venv_python()
return GlobalEnvironment(self)
Expand Down
1 change: 1 addition & 0 deletions pdm/utils.py
Expand Up @@ -423,6 +423,7 @@ def get_venv_python() -> Optional[str]:
@contextmanager
def atomic_open_for_write(filename: Union[Path, str], *, encoding: str = "utf-8"):
fd, name = tempfile.mkstemp("-atomic-write", "pdm-")
filename = str(filename)
try:
f = open(fd, "w", encoding=encoding)
yield f
Expand Down

0 comments on commit 76f34f2

Please sign in to comment.