Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ContinuumIO/conda
Browse files Browse the repository at this point in the history
  • Loading branch information
bryevdv committed Apr 24, 2013
2 parents 7241a5a + b189d38 commit cc4b37b
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 134 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
2013-XX-XX 1.5.1:
2013-XX-XX 1.5.2:
-------------------
* fixed issue 59: bad error message when pkgs dir is not writable


2013-04-19 1.5.1:
-------------------
* fixed issue 71 and (73 duplicate): not being able to install packages
starting with conda (such as 'conda-api')
* fixed issue 69 (not being able to update Python / NumPy)
* fixed issue 76 (cannot install mkl on OSX)


2013-03-22 1.5.0:
Expand Down
24 changes: 18 additions & 6 deletions conda/builder/index.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import os
import bz2
import json
import base64
import hashlib
import tarfile
from os.path import join, getmtime

from utils import bzip2, file_info
from utils import file_info


app_meta_path_fmt = 'App/%(name)s/meta.json'
Expand All @@ -31,6 +32,17 @@ def read_index_tar(tar_path):
add_app_metadata(t, info)
return info

def write_repodata(repodata, dir_path):
data = json.dumps(repodata, indent=2, sort_keys=True)
# strip trailing whitespace
data = '\n'.join(line.rstrip() for line in data.split('\n'))
# make sure we have newline at the end
if not data.endswith('\n'):
data += '\n'
with open(join(dir_path, 'repodata.json'), 'w') as fo:
fo.write(data)
with open(join(dir_path, 'repodata.json.bz2'), 'wb') as fo:
fo.write(bz2.compress(data))

def update_index(dir_path, verbose=False, force=False):
if verbose:
Expand Down Expand Up @@ -77,8 +89,8 @@ def update_index(dir_path, verbose=False, force=False):
except KeyError:
pass

repodata = {'packages': index, 'icons': icons, 'info': {}}
repodata_path = join(dir_path, 'repodata.json')
with open(repodata_path, 'w') as fo:
json.dump(repodata, fo, indent=2, sort_keys=True)
bzip2(repodata_path)
repodata = {'packages': index, 'info': {}}
if icons:
repodata['icons'] = icons

write_repodata(repodata, dir_path)
12 changes: 0 additions & 12 deletions conda/builder/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import bz2
import sys
import hashlib
import platform
Expand All @@ -21,17 +20,6 @@ def rel_lib(f):
return normpath(f.count('/') * '../') + '/lib'


def bzip2(path, verbose=False):
bz2path = path + '.bz2'
if verbose:
print "bz2ing:", path
with open(path, 'rb') as fi:
data = fi.read()
data = bz2.compress(data)
with open(bz2path, 'wb') as fo:
fo.write(data)


def md5_file(path):
with open(path, 'rb') as fi:
h = hashlib.new('md5')
Expand Down
83 changes: 52 additions & 31 deletions conda/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,39 +62,60 @@ def fetch_file(url, fn, md5=None, size=None, progress=None,
for x in range(retries):
try:
fi = urllib2.urlopen(url + fn)
log.debug("fetching: %s [%s]" % (fn, url))
n = 0
h = hashlib.new('md5')
if size is None:
length = int(fi.headers["Content-Length"])
else:
length = size
except IOError:
log.debug("Attempt %d failed at urlopen" % x)
continue
log.debug("Fetching: %s [%s]" % (fn, url))
n = 0
h = hashlib.new('md5')
if size is None:
length = int(fi.headers["Content-Length"])
else:
length = size

if progress:
progress.widgets[0] = fn
progress.maxval = length
progress.start()

need_retry = False

try:
fo = open(pp, 'wb')
except IOError:
raise RuntimeError("Could not open %r for writing. "
"Permissions problem or missing directory?" % pp)
while True:
try:
chunk = fi.read(16384)
except IOError:
log.debug("Attempt %d failed at read" % x)
need_retry = True
break
if not chunk:
break
try:
fo.write(chunk)
except IOError:
raise RuntimeError("Failed to write to %r." % pp)
if md5:
h.update(chunk)
n += len(chunk)
if progress:
progress.widgets[0] = fn
progress.maxval = length
progress.start()

with open(pp, 'wb') as fo:
while True:
chunk = fi.read(16384)
if not chunk:
break
fo.write(chunk)
if md5:
h.update(chunk)
n += len(chunk)
if progress:
progress.update(n)

fi.close()
if progress: progress.finish()
if md5 and h.hexdigest() != md5:
raise RuntimeError("MD5 sums mismatch for download: %s" %
fn)
progress.update(n)

fo.close()
if need_retry:
continue

fi.close()
if progress: progress.finish()
if md5 and h.hexdigest() != md5:
raise RuntimeError("MD5 sums mismatch for download: %s" % fn)
try:
os.rename(pp, path)
return url
except IOError:
log.debug('download failed try: %d' % x)
except OSError:
raise RuntimeError("Could not rename %r to %r." % (pp, path))
return url

raise RuntimeError("Could not locate file '%s' on any repository" % fn)
134 changes: 50 additions & 84 deletions docs/source/examples/depends.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,130 +8,96 @@ for a given package.

.. code-block:: bash
$ conda depends numpy
numpy depends on the following packages:
nose 1.1.2
python 2.7
readline 6.2
sqlite 3.7.13
zlib 1.2.7
$ conda depends scipy
scipy depends on the following packages:
nose-1.2.1
numpy-1.7.0
python-2.7.3
readline-6.2
sqlite-3.7.13
tk-8.5.13
zlib-1.2.7
To check a package dependency in a specific named environment in /anaconda/envs, the name option (``-n``) is used.

.. code-block:: bash
$ conda depends -n foo numpy
numpy depends on the following packages:
nose-1.1.2
$ conda depends -n foo scipy
scipy depends on the following packages:
nose-1.2.1
numpy-1.7.0
python-2.7.3
readline-6.2
sqlite-3.7.13
tk-8.5.13
zlib-1.2.7
Running ``conda depends`` with the prefix option (``-p``) checks a specified packages dependencies within an Anaconda environment
located at a given path.

.. code-block:: bash
$ conda depends -p ~/anaconda/envs/foo/ numpy
numpy depends on the following packages:
nose-1.1.2
$ conda depends -p ~/anaconda/envs/foo/ scipy
scipy depends on the following packages:
nose-1.2.1
numpy-1.7.0
python-2.7.3
readline-6.2
sqlite-3.7.13
tk-8.5.13
zlib-1.2.7
Running ``conda depends`` with the reverse dependency command shows all packages that require NumPy.

.. code-block:: bash
$ conda depends -r numpy
The following activated packages depend on numpy:
h5py-2.0.1
iopro-1.1.0
matplotlib-1.1.1
numba-0.1.1
numbapro-0.6
numexpr-2.0.1
pandas-0.8.1
pysal-1.4.0
pytables-2.4.0
scikit-learn-0.11
scikits-image-0.6.1
scipy-0.11.0
$ conda depends -r scipy
The following activated packages depend on scipy:
accelerate-1.0.1
pandas-0.10.1
pysal-1.5.0
scikit-learn-0.13
statsmodels-0.4.3
wiserf-0.9
wiserf-1.1
Using reverse dependency in addition to the verbose (``-v``) and ``no-prefix`` commands offers
Using reverse dependency in addition to the verbose (``-v``) commands offers
more information and includes packages that depend on any version of NumPy.

.. code-block:: bash
$ conda depends --no-prefix -rv numpy
The following packages depend on numpy:
chaco-4.2.1.dev-np17py27_0
h5py-2.0.1-np17py26_0
h5py-2.0.1-np17py27_0
h5py-2.1.0-np17py26_0
h5py-2.1.0-np17py27_0
....
statsmodels-0.4.3-np16py26_0
statsmodels-0.4.3-np16py27_0
statsmodels-0.4.3-np17py26_0
$ conda depends -rv scipy
The following activated packages depend on scipy:
accelerate-1.0.1-np17py27_p0
pandas-0.10.1-np17py27_0
pysal-1.5.0-np17py27_0
scikit-learn-0.13-np17py27_0
statsmodels-0.4.3-np17py27_0
wiserf-0.9-np17py27_0
``conda depends`` with just ``--no-prefix -r`` shows us any version of NumPy's dependencies in a more easily parsed
form, showing how many versions of NumPy can be used to build that specific package.
wiserf-1.1-np17py27_1
.. code-block:: bash
$ conda depends --no-prefix -r numpy
The following packages depend on numpy:
chaco-4.2.1.dev
h5py-2.0.1 (2 builds)
h5py-2.1.0 (2 builds)
iopro-1.0 (2 builds)
iopro-1.1.0 (2 builds)
iopro-1.2rc1 (2 builds)
....
pytables-2.4.0 (4 builds)
scikit-learn-0.11 (13 builds)
scikits-image-0.6.1 (6 builds)
scipy-0.11.0 (3 builds)
scipy-0.11.0rc2 (3 builds)
statsmodels-0.4.3 (4 builds)
wiserf-0.9
Adding the ``MAX_DEPTH`` command allows greater control over how many levels
deep conda's dependency list will go. By default, it is set to 0, but
for the purposes of demonstration, it is made explicit here.

.. code-block:: bash
$ conda depends -rm 0 sqlite
The following activated packages depend on sqlite:
anaconda-launcher-0.0
bitarray-0.8.0
bitey-0.0
conda-1.0
cython-0.17.1
dateutil-1.5
flask-0.9
gevent-0.13.7
gevent-websocket-0.3.6
....
sympy-0.7.1
tornado-2.3
werkzeug-0.8.3
wiserf-0.9
$ conda depends -rm 0 sqlite
The following activated packages depend on sqlite:
_license-1.1
accelerate-1.0.1
astropy-0.2
biopython-1.60
bitarray-0.8.1
bitey-0.0
boto-2.6.0
chaco-4.2.1.dev
cubes-0.10.2
...
werkzeug-0.8.3
wiserf-1.1
xlrd-0.9.0
xlwt-0.7.4

In this example, setting the ``MAX_DEPTH`` to 1 shows only the packages
that depend on sqlite, while not displaying what these packages depend
Expand Down

0 comments on commit cc4b37b

Please sign in to comment.