Skip to content

Commit

Permalink
Update packages to latest supported versions for project. Misc update…
Browse files Browse the repository at this point in the history
…s for conda-lock platforms argument. Fix tests.
  • Loading branch information
jbouder committed Sep 19, 2024
1 parent 27e02e3 commit 264d082
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 17 deletions.
16 changes: 10 additions & 6 deletions conda_vendor/conda_vendor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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'))
Expand All @@ -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 == '':
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 4 additions & 6 deletions environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 264d082

Please sign in to comment.