Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/conda/conda-build into 1.…
Browse files Browse the repository at this point in the history
…21.x
  • Loading branch information
msarahan committed Jun 15, 2016
2 parents c49d833 + a2c5568 commit 5ef883e
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 37 deletions.
24 changes: 20 additions & 4 deletions conda_build/main_inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@
from os.path import abspath, join, dirname, exists, basename
from collections import defaultdict
from operator import itemgetter
import tempfile

from conda.misc import which_package
from conda.compat import iteritems
from conda.cli.common import add_parser_prefix, get_prefix, InstalledPackages
from conda.cli.common import add_parser_prefix, get_prefix, InstalledPackages, specs_from_args
from conda.cli.conda_argparse import ArgumentParser
import conda.install as ci
import conda.install
from conda import plan

from conda.api import get_index
from conda.cli.install import check_install
from conda.config import get_default_urls

from conda_build.main_build import args_func
Expand Down Expand Up @@ -157,6 +158,21 @@ def main():
args_func(args, p)


def check_install(packages, platform=None, channel_urls=(), prepend=True,
minimal_hint=False):
prefix = tempfile.mkdtemp('conda')
try:
specs = specs_from_args(packages)
index = get_index(channel_urls=channel_urls, prepend=prepend,
platform=platform, prefix=prefix)
actions = plan.install_actions(prefix, index, specs, pinned=False,
minimal_hint=minimal_hint)
plan.display_actions(actions, index)
return actions
finally:
conda.install.rm_rf(prefix)


def print_linkages(depmap, show_files=False):
# Print system and not found last
k = sorted(set(depmap.keys()) - {'system', 'not found'})
Expand Down Expand Up @@ -282,7 +298,7 @@ def execute(args, parser):
sys.exit(not test_installable(channel=args.channel, verbose=args.verbose))

prefix = get_prefix(args)
installed = ci.linked_data(prefix)
installed = conda.install.linked_data(prefix)
installed = {rec['name']: dist for dist, rec in iteritems(installed)}

if not args.packages and not args.untracked and not args.all:
Expand Down
29 changes: 6 additions & 23 deletions conda_build/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,13 @@ def git_source(meta, recipe_dir, verbose=False):
if checkout and verbose:
print('checkout: %r' % checkout)

check_call([git, 'clone', '--recursive', cache_repo_arg, WORK_DIR], stdout=stdout)
check_call([git, 'clone', cache_repo_arg, WORK_DIR], stdout=stdout)
if checkout:
check_call([git, 'checkout', checkout], cwd=WORK_DIR, stdout=stdout)

# Submodules must be updated after checkout.
check_call([git, 'submodule', 'update', '--init', '--recursive'], cwd=WORK_DIR, stdout=stdout)

git_info(verbose=verbose)

if not verbose:
Expand Down Expand Up @@ -314,21 +317,6 @@ def _ensure_unix_line_endings(path):
return out_path


def _commonpath(paths):
"""Python 2 doesn't have os.path.commonpath(), so roll our own"""
folders = [path.split(b'/') for path in paths]
minfolders = min(folders)
maxfolders = max(folders)
common = []
for minf, maxf in zip(minfolders, maxfolders[:len(minfolders)]):
if minf != maxf:
break
common.append(minf)
if len(common):
return b'/'.join(common) + b'/'
return b''


def _guess_patch_strip_level(filesstr, src_dir):
""" Determine the patch strip level automatically. """
maxlevel = None
Expand All @@ -342,11 +330,6 @@ def _guess_patch_strip_level(filesstr, src_dir):
else:
histo = dict()
histo = {i: 0 for i in range(maxlevel + 1)}
if len(files) == 1:
(common,) = files
else:
common = _commonpath(files)
maxlevel = common.count(b'/')
for file in files:
parts = file.split(b'/')
for level in range(maxlevel + 1):
Expand All @@ -361,11 +344,11 @@ def _guess_patch_strip_level(filesstr, src_dir):


def _source_files_from_patch_file(path):
re_source_files = re.compile('^--- ([^\n\t]+)')
re_files = re.compile('^(?:---|\+\+\+) ([^\n\t]+)')
files = set()
with open(path) as f:
files = {m.group(1) for l in f.readlines()
for m in [re_source_files.search(l)]
for m in [re_files.search(l)]
if m and m.group(1) != '/dev/null'}
return files

Expand Down
2 changes: 1 addition & 1 deletion tests/test-recipes/metadata/build_string/run_test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
conda list -p $PREFIX --canonical
# This is actually the build string. We test the build number below
[ "$(conda list -p $PREFIX --canonical)" = "conda-build-test-build-string-1.0-abc" ]
[ "$(conda list -p $PREFIX --canonical)" = "local::conda-build-test-build-string-1.0-abc" ]

cat $PREFIX/conda-meta/conda-build-test-build-string-1.0-abc.json
cat $PREFIX/conda-meta/conda-build-test-build-string-1.0-abc.json | grep '"build_number": 0'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
conda list -p $PREFIX --canonical
# This is actually the build string. We test the build number below
[ "$(conda list -p $PREFIX --canonical)" = "conda-build-test-build-number-1.0-1" ]
[ "$(conda list -p $PREFIX --canonical)" = "local::conda-build-test-build-number-1.0-1" ]

cat $PREFIX/conda-meta/conda-build-test-build-number-1.0-1.json
cat $PREFIX/conda-meta/conda-build-test-build-number-1.0-1.json | grep '"build_number": 1'
16 changes: 8 additions & 8 deletions tests/test_build_recipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ def test_header_finding():
assert "forcing --without-libyaml" not in output


def test_CONDA_BLD_PATH():
env = dict(os.environ)
cmd = 'conda build --no-anaconda-upload {}/source_git_jinja2'.format(metadata_dir)
with TemporaryDirectory() as tmp:
env["CONDA_BLD_PATH"] = tmp
subprocess.check_call(cmd.split(), env=env)
# trick is actually a second pass, to make sure that deletion/trash moving is working OK.
subprocess.check_call(cmd.split(), env=env)
# def test_CONDA_BLD_PATH():
# env = dict(os.environ)
# cmd = 'conda build --no-anaconda-upload {}/source_git_jinja2'.format(metadata_dir)
# with TemporaryDirectory() as tmp:
# env["CONDA_BLD_PATH"] = tmp
# subprocess.check_call(cmd.split(), env=env)
# # trick is actually a second pass, to make sure that deletion/trash moving is working OK.
# subprocess.check_call(cmd.split(), env=env)


# TODO: this does not currently take into account post-build versioning changes with __conda_? files
Expand Down

0 comments on commit 5ef883e

Please sign in to comment.