Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create macOS platform tags using packaging #439

Merged
merged 4 commits into from
Jun 28, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 13 additions & 19 deletions conda_lock/pypi_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from clikit.api.io.flags import VERY_VERBOSE
from clikit.io import ConsoleIO, NullIO
from packaging.tags import compatible_tags, cpython_tags
from packaging.tags import compatible_tags, cpython_tags, mac_platforms

from conda_lock._vendor.poetry.core.packages import Dependency as PoetryDependency
from conda_lock._vendor.poetry.core.packages import Package as PoetryPackage
Expand Down Expand Up @@ -40,6 +40,8 @@

# NB: in principle these depend on the glibc in the conda env
MANYLINUX_TAGS = ["1", "2010", "2014", "_2_17"]
# This needs to be updated periodically as new macOS versions are released.
MACOS_VERSION = (13, 4)


class PlatformEnv(Env):
Expand All @@ -49,40 +51,32 @@ class PlatformEnv(Env):

def __init__(self, python_version: str, platform: str):
super().__init__(path=Path(sys.prefix))
if platform.startswith("linux-"):
arch = platform.split("-")[-1]
if arch == "64":
arch = "x86_64"
system, arch = platform.split("-")
if arch == "64":
arch = "x86_64"

if system == "linux":
self._platforms = [
f"manylinux{tag}_{arch}" for tag in reversed(MANYLINUX_TAGS)
]
self._platforms.append(f"linux_{arch}")
elif platform == "osx-64":
self._platforms = [
"macosx_10_9_x86_64",
*(f"macosx_10_{version}_universal2" for version in range(16, 3, -1)),
*(f"macosx_10_{version}_universal" for version in range(16, 3, -1)),
]
elif platform == "osx-arm64":
self._platforms = [
"macosx_11_0_arm64",
*(f"macosx_10_{version}_universal2" for version in range(16, 3, -1)),
]
elif system == "osx":
self._platforms = list(mac_platforms(MACOS_VERSION, arch))
elif platform == "win-64":
self._platforms = ["win_amd64"]
else:
raise ValueError(f"Unsupported platform '{platform}'")
self._python_version = tuple(map(int, python_version.split(".")))

if platform.startswith("osx-"):
if system == "osx":
self._sys_platform = "darwin"
self._platform_system = "Darwin"
self._os_name = "posix"
elif platform.startswith("linux-"):
elif system == "linux":
self._sys_platform = "linux"
self._platform_system = "Linux"
self._os_name = "posix"
elif platform.startswith("win-"):
elif system == "win":
self._sys_platform = "win32"
self._platform_system = "Windows"
self._os_name = "nt"
Expand Down
Loading