diff --git a/conda_vendor/conda_vendor.py b/conda_vendor/conda_vendor.py index c3996b8..10cbee7 100644 --- a/conda_vendor/conda_vendor.py +++ b/conda_vendor/conda_vendor.py @@ -16,8 +16,12 @@ from conda_build import api from conda_vendor.iron_bank_generator import yaml_dump_ironbank_manifest -def get_lock_spec_for_environment_file(environment_file) -> LockSpecification: - lock_spec = CondaLockWrapper.parse_environment_file(environment_file) +def get_lock_spec_for_environment_file(environment_file, platform) -> LockSpecification: + # conda lock expects a list + if isinstance(platform, str): + platform = [platform] + + lock_spec = CondaLockWrapper.parse_environment_file(environment_file, platform) return lock_spec @@ -92,7 +96,7 @@ def _scrub_virtual_pkgs(dry_run_install, chan): return dry_run_install def solve_environment(lock_spec, solver, platform) -> DryRunInstall: - specs = get_specs(lock_spec) + specs = get_specs(lock_spec, platform) click.echo(click.style(f"Using Solver: {solver}", bold=True, bg='black', fg='cyan')) click.echo(click.style(f"Solving for Platform: {platform}", bold=True, bg='black', fg='cyan')) @@ -118,8 +122,8 @@ def solve_environment(lock_spec, solver, platform) -> DryRunInstall: # get formatted List(str) to pass to CondaLockWrapper.solve_specs_for_arch() -def get_specs(lock_spec) -> List[str]: - versioned_deps = lock_spec.dependencies +def get_specs(lock_spec, platform) -> List[str]: + versioned_deps = lock_spec.dependencies[platform] specs = [] for dep in versioned_deps: if dep.version == '': @@ -288,7 +292,7 @@ def vendor(file,solver, platform, dry_run, ironbank_gen): click.echo(click.style("Dry Run - Will Not Download Files", bold=True, fg='red')) # generate conda-locks LockSpecification - lock_spec = get_lock_spec_for_environment_file(environment_yaml) + lock_spec = get_lock_spec_for_environment_file(environment_yaml, platform) # generate DryRunInstall dry_run_install = solve_environment(lock_spec, solver, platform) diff --git a/environment.yaml b/environment.yaml index b2888b8..b0252bb 100644 --- a/environment.yaml +++ b/environment.yaml @@ -2,17 +2,15 @@ name: conda-vendor-dependencies channels: - conda-forge dependencies: - - python + - python>=3.8 - click - - conda-lock=1.1.2 + - conda-lock=2.1.1 - conda-build - pip - - pydantic=1.8.1 - # solvers - - conda=4.12.0 + - pydantic=1.10.17 + - conda - mamba - micromamba - # teset dependencies - pytest - pytest-mock - setuptools diff --git a/setup.py b/setup.py index 462d6ac..e683b10 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ entry_points={"console_scripts": ["conda-vendor = conda_vendor.__main__:cli"]}, install_requires=["ruamel.yaml", "conda-lock", "click"], setup_requires=["wheel"], - python_requires=">=3.6", + python_requires=">=3.8", long_description=long_description, long_description_content_type="text/markdown", ) diff --git a/tests/conftest.py b/tests/conftest.py index 6f38505..5908939 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -63,7 +63,7 @@ def python_conda_mirror_main_conda_forge_environment(tmpdir_factory): # conda-locks LockSpecification object @pytest.fixture(scope="function") def lock_spec_fixture(python_conda_mirror_main_conda_forge_environment) -> LockSpecification: - lock_spec = get_lock_spec_for_environment_file(python_conda_mirror_main_conda_forge_environment) + lock_spec = get_lock_spec_for_environment_file(python_conda_mirror_main_conda_forge_environment, "linux-64") return lock_spec # conda-lock's DryRunInstall object diff --git a/tests/test_integration.py b/tests/test_integration.py index dd37370..b5e1752 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -49,9 +49,10 @@ def test_vendor_full_runthrough(python_main_defaults_environment, tmp_path_facto # get _lock_spec_for_environment_file contains the packages defined in # the python_conda_mirror_main_conda_forge_environment test fixture def test_get_lock_spec_for_environmen_file(python_conda_mirror_main_conda_forge_environment): - lock_spec = get_lock_spec_for_environment_file(python_conda_mirror_main_conda_forge_environment) - assert any(versioned_dep.name == 'python' for versioned_dep in lock_spec.dependencies) - assert any(versioned_dep.version == '3.9.5.*' for versioned_dep in lock_spec.dependencies) + platform = 'linux-64' + lock_spec = get_lock_spec_for_environment_file(python_conda_mirror_main_conda_forge_environment, platform) + assert any(versioned_dep.name == 'python' for versioned_dep in lock_spec.dependencies[platform]) + assert any(versioned_dep.version == '3.9.5.*' for versioned_dep in lock_spec.dependencies[platform]) # test that solve_environment's DryRunInstall object's # 'success' field is True