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 back r.get_pkgs() and stubbed package_cache() #4266

Merged
merged 11 commits into from Jan 12, 2017
6 changes: 1 addition & 5 deletions .travis.yml
Expand Up @@ -28,16 +28,12 @@ matrix:
- os: osx
env: PYTHON_VERSION=3.5
language: generic
- python: '3.5'
env: CONDA_BUILD=1.21.14
os: linux
language: python
- python: '3.5'
env: CONDA_BUILD=2.0.12
os: linux
language: python
- python: '3.5'
env: CONDA_BUILD=2.1.0
env: CONDA_BUILD=2.1.1
os: linux
language: python

Expand Down
4 changes: 4 additions & 0 deletions conda/core/index.py
Expand Up @@ -496,3 +496,7 @@ def create_cache_dir():
except OSError:
pass
return cache_dir


def dist_str_in_index(index, dist_str):
return Dist(dist_str) in index
12 changes: 12 additions & 0 deletions conda/core/package_cache.py
Expand Up @@ -512,3 +512,15 @@ def rm_fetched(dist):
def download(url, dst_path, session=None, md5=None, urlstxt=False, retries=3):
from ..gateways.download import download as gateway_download
gateway_download(url, dst_path, md5)


class package_cache(object):

def __contains__(self, dist):
return dist in PackageCache.first_writable()

def keys(self):
return iter(PackageCache.first_writable())

def __delitem__(self, dist):
del PackageCache.first_writable()[dist]
7 changes: 5 additions & 2 deletions conda/exports.py
Expand Up @@ -7,6 +7,9 @@

log = getLogger(__name__)

from . import CondaError # NOQA
CondaError = CondaError

from . import compat, plan # NOQA
compat, plan = compat, plan

Expand All @@ -32,8 +35,8 @@
TmpDownload = TmpDownload
handle_proxy_407 = lambda x, y: warn("handle_proxy_407 is deprecated. "
"Now handled by CondaSession.")
from .core.index import fetch_index # NOQA
fetch_index = fetch_index
from .core.index import dist_str_in_index, fetch_index # NOQA
dist_str_in_index, fetch_index = dist_str_in_index, fetch_index
from .core.package_cache import download, rm_fetched # NOQA
download, rm_fetched = download, rm_fetched

Expand Down
5 changes: 3 additions & 2 deletions conda/gateways/download.py
Expand Up @@ -63,9 +63,10 @@ def download(url, target_full_path, md5sum):
resp = session.get(url, stream=True, proxies=session.proxies, timeout=timeout)
resp.raise_for_status()

content_length = int(resp.headers.get('Content-Length'))
content_length = int(resp.headers.get('Content-Length', 0))

getLogger('fetch.start').info((basename(target_full_path)[:14], content_length))
if content_length:
getLogger('fetch.start').info((basename(target_full_path)[:14], content_length))

digest_builder = hashlib.new('md5')
try:
Expand Down
4 changes: 2 additions & 2 deletions conda/install.py
Expand Up @@ -47,8 +47,8 @@

# backwards compatibility for conda-build
def package_cache():
log.warn('package_cache() is a no-op and deprecated')
return {}
from .core.package_cache import package_cache
return package_cache()


if on_win:
Expand Down
6 changes: 6 additions & 0 deletions conda/models/enums.py
Expand Up @@ -68,6 +68,9 @@ def __int__(self):
def __str__(self):
return self.name

def __json__(self):
return self.name


class PathType(Enum):
"""
Expand All @@ -86,3 +89,6 @@ class PathType(Enum):

def __str__(self):
return self.name

def __json__(self):
return self.name
5 changes: 5 additions & 0 deletions conda/resolve.py
Expand Up @@ -558,6 +558,11 @@ def package_quad(self, dist):
def package_name(self, dist):
return self.package_quad(dist)[0]

def get_pkgs(self, ms, emptyok=False):
# legacy method for conda-build
# TODO: remove in conda 4.4
return self.get_dists_for_spec(ms, emptyok)

def get_dists_for_spec(self, ms, emptyok=False):
ms = MatchSpec(ms)
dists = self.find_matches(ms)
Expand Down
7 changes: 4 additions & 3 deletions utils/travis-run-install.sh
Expand Up @@ -82,7 +82,8 @@ miniconda_install() {

conda_build_install() {
# install conda
python utils/setup-testing.py install
rm -rf $(~/miniconda/bin/python -c "import site; print(site.getsitepackages()[0])")/conda
~/miniconda/bin/python utils/setup-testing.py install
hash -r
conda info

Expand All @@ -91,7 +92,7 @@ conda_build_install() {
conda install -y -q -c conda-forge perl pytest-xdist
conda install -y -q anaconda-client numpy

python -m pip install pytest-capturelog pytest-mock
~/miniconda/bin/python -m pip install pytest-capturelog pytest-mock

conda config --set add_pip_as_python_dependency true

Expand All @@ -101,7 +102,7 @@ conda_build_install() {
# install conda-build
git clone -b $CONDA_BUILD --single-branch --depth 1000 https://github.com/conda/conda-build.git
pushd conda-build
python setup.py install
~/miniconda/bin/pip install .
hash -r
conda info
popd
Expand Down
2 changes: 1 addition & 1 deletion utils/travis-run-script.sh
Expand Up @@ -55,7 +55,7 @@ conda_build_unit_test() {
echo
echo ">>>>>>>>>>>> running conda-build unit tests >>>>>>>>>>>>>>>>>>>>>"
echo
python -m pytest -n 2 --basetemp /tmp/cb tests || echo -e "\n>>>>> conda-build tests exited with code" $? "\n\n\n"
~/miniconda/bin/python -m pytest --basetemp /tmp/cb tests || echo -e "\n>>>>> conda-build tests exited with code" $? "\n\n\n"
popd
}

Expand Down