Skip to content

Commit

Permalink
Added support to conda version 4.4 and above (#52)
Browse files Browse the repository at this point in the history
* To solve Conda new config location

It solves #50

* Added support to conda version 4.4 and above

To solve #50

* Update conda_interface.py

* Update to add conda version 4.5.3

* Correct versions Conda to 4.5.3 and Python to 3.5

* Trying to add conda 4.4 compatibility

* Take 2 - UnlinkLinkTransation Conda 4.4 and above

* Trying to add 4.4 compatibility using Solver

* Take two - to solve mismatching MatchSpec

* Added temporal comments

* Take 3 - Using Solver

* Compatibility to conda 4.4 - clean the code

Added compatibility with conda 4.4 and above by using core.Solver and models.match_spec.MatchSpec

* Remove comments to fully test patch

* Added Python 3.5 and removed 3.4

Conda in TravisCI was unable to create the env using Python 3.4.
Error was:
conda install --yes python=$PYTHON_VERSION --file requirements.txt
Solving environment: failed
UnsatisfiableError: The following specifications were found to be in conflict:
  - python=3.4
  - urllib3 -> ipaddress -> python[version='>=2.7,<2.8.0a0'] -> readline=7
  - urllib3 -> ipaddress -> python[version='>=2.7,<2.8.0a0'] -> tk=8.6

* Solve hopefully conda_42 incompatibly

Changed back to common.yaml for conda_42
  • Loading branch information
cvelascof authored and pelson committed May 25, 2018
1 parent 8faebf4 commit 7e74d64
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 deletions.
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ sudo: false

env:
- PYTHON_VERSION=2.7 CONDA_VERSION=4.2.16
- PYTHON_VERSION=3.4 CONDA_VERSION=4.2.16
- PYTHON_VERSION=3.5 CONDA_VERSION=4.2.16
- PYTHON_VERSION=3.6 CONDA_VERSION=4.2.16
- PYTHON_VERSION=2.7 CONDA_VERSION=4.3.21
- PYTHON_VERSION=3.4 CONDA_VERSION=4.3.21
- PYTHON_VERSION=3.5 CONDA_VERSION=4.3.21
- PYTHON_VERSION=3.6 CONDA_VERSION=4.3.21
- PYTHON_VERSION=2.7 CONDA_VERSION=4.5.3
- PYTHON_VERSION=3.5 CONDA_VERSION=4.5.3
- PYTHON_VERSION=3.6 CONDA_VERSION=4.5.3

install:
- export CONDA_BASE=http://repo.continuum.io/miniconda/Miniconda3
Expand Down
19 changes: 13 additions & 6 deletions conda_execute/conda_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,33 @@ def parse_conda_version_major_minor(string):
CONDA_VERSION_MAJOR_MINOR = parse_conda_version_major_minor(CONDA_VERSION)
conda_42 = CONDA_VERSION_MAJOR_MINOR >= (4, 2)
conda_43 = CONDA_VERSION_MAJOR_MINOR >= (4, 3)
conda_44 = CONDA_VERSION_MAJOR_MINOR >= (4, 4)
conda_45 = CONDA_VERSION_MAJOR_MINOR >= (4, 5)

from conda.lock import Locked
from conda.config import user_rc_path, sys_rc_path
user_rc_path, sys_rc_path = user_rc_path, sys_rc_path
Locked = Locked


if conda_42:
if conda_44:
from conda.base.context import user_rc_path, sys_rc_path
from conda.exports import envs_dirs, pkgs_dirs
from conda.exports import Resolve
from conda.exports import get_index
from conda.common.serialize import yaml_dump, yaml_load
elif conda_42:
from conda.config import user_rc_path, sys_rc_path
from conda.exports import envs_dirs, pkgs_dirs
from conda.exports import Resolve
from conda.exports import get_index

from conda.common.yaml import yaml_load
else:
from conda.config import user_rc_path, sys_rc_path
from conda.config import envs_dirs, pkgs_dirs
from conda.resolve import Resolve
from conda.api import get_index

from conda.utils import yaml_load

user_rc_path, sys_rc_path = user_rc_path, sys_rc_path

envs_dirs, pkgs_dirs = envs_dirs, pkgs_dirs
Resolve = Resolve
get_index = get_index
Expand Down
16 changes: 13 additions & 3 deletions conda_execute/tmpenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,16 @@ def _create_env_conda_43(prefix, index, full_list_of_packages):
txn = UnlinkLinkTransaction.create_from_dists(index, prefix, (), full_list_of_packages)
txn.execute()


def _create_env_conda_44(prefix, full_list_of_packages):
assert CONDA_VERSION_MAJOR_MINOR >= (4, 4)
from conda.models.match_spec import MatchSpec
from conda.core.solve import Solver

matched_list_of_packages = (MatchSpec(d) for d in full_list_of_packages)
m = Solver(prefix, (), specs_to_add=matched_list_of_packages)
txn = m.solve_for_transaction()
txn.execute()

def create_env(spec, force_recreation=False, extra_channels=()):
"""
Create a temporary environment from the given specification.
Expand Down Expand Up @@ -110,8 +119,9 @@ def create_env(spec, force_recreation=False, extra_channels=()):

# Put out a newline. Conda's solve doesn't do it for us.
log.info('\n')

if CONDA_VERSION_MAJOR_MINOR >= (4, 3):
if CONDA_VERSION_MAJOR_MINOR >= (4, 4):
_create_env_conda_44(env_locn, full_list_of_packages)
elif CONDA_VERSION_MAJOR_MINOR >= (4, 3):
sorted_list_of_packages = r.dependency_sort({d.name: d for d in full_list_of_packages})
_create_env_conda_43(env_locn, index, sorted_list_of_packages)
else:
Expand Down

0 comments on commit 7e74d64

Please sign in to comment.