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

Add --force-platform to conda-lock install command. #753

Merged
merged 8 commits into from
Nov 25, 2024
Merged
Changes from 1 commit
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
56 changes: 52 additions & 4 deletions tests/test_conda_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -2061,16 +2061,16 @@ def test_solve_arch_multiple_categories():
assert numpy_deps[0].categories == {"test", "dev"}


def _check_package_installed(package: str, prefix: str):
import glob

files = list(glob.glob(f"{prefix}/conda-meta/{package}-*.json"))
def _check_package_installed(package: str, prefix: str, subdir: Optional[str] = None):
files = list(glob(f"{prefix}/conda-meta/{package}-*.json"))
assert len(files) >= 1
# TODO: validate that all the files are in there
for fn in files:
data = json.load(open(fn))
for expected_file in data["files"]:
assert (Path(prefix) / Path(expected_file)).exists()
if subdir is not None:
assert data["subdir"] == subdir
return True


Expand Down Expand Up @@ -2650,6 +2650,54 @@ def test_fake_conda_env(conda_exe: str, conda_lock_yaml: Path):
assert platform == path.parent.name


def test_forced_platform(
conda_exe: str,
tmp_path: Path,
conda_lock_yaml: Path,
capsys: "pytest.CaptureFixture[str]",
):
if is_micromamba(conda_exe):
pytest.skip(reason="micromamba tests are failing")
if platform_subdir() != "osx-arm64":
pytest.skip("Test is only relevant for macOS on ARM64")

root_prefix = tmp_path / "root_prefix"
root_prefix.mkdir(exist_ok=True)
prefix = root_prefix / "test_env"

package = "bzip2"
platform = "osx-64"
assert platform != platform_subdir()

install_args = [
"install",
"--conda",
conda_exe,
"--prefix",
str(prefix),
"--force-platform",
platform,
str(conda_lock_yaml),
]
with capsys.disabled():
runner = CliRunner(mix_stderr=False)
result = runner.invoke(main, install_args, catch_exceptions=False)

print(result.stdout, file=sys.stdout)
print(result.stderr, file=sys.stderr)
if Path(conda_lock_yaml).exists():
logging.debug(
"lockfile contents: \n\n=======\n%s\n\n==========",
Path(conda_lock_yaml).read_text(),
)

assert _check_package_installed(
package=package,
prefix=str(prefix),
subdir=platform,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's checking the subdir value of the metadata here

), f"Package {package} does not exist in {prefix} environment"


@pytest.mark.parametrize("placeholder", ["$QUETZ_API_KEY", "${QUETZ_API_KEY}"])
@flaky
def test_private_lock(
Expand Down
Loading