Skip to content

Commit

Permalink
Merge branch 'release/0.15.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
lasote committed Nov 8, 2016
2 parents 829c724 + c069e45 commit 08e0bd8
Show file tree
Hide file tree
Showing 45 changed files with 1,299 additions and 288 deletions.
2 changes: 1 addition & 1 deletion conans/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
from conans.util.files import load
import os

__version__ = '0.14.1'
__version__ = '0.15.0'

26 changes: 15 additions & 11 deletions conans/client/client_cache.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import os
from conans.util.files import save, load, relative_dirs, path_exists, mkdir
from conans.util.files import save, load, path_exists, mkdir
from conans.model.settings import Settings
from conans.client.conf import ConanClientConfigParser, default_client_conf, default_settings_yml
from conans.model.values import Values
from conans.client.detect import detect_defaults_settings
from conans.model.ref import ConanFileReference
from conans.model.manifest import FileTreeManifest
from conans.paths import SimplePaths
from conans.paths import SimplePaths, CONANINFO
from genericpath import isdir
from conans.model.profile import Profile
from conans.model.info import ConanInfo
from conans.errors import ConanException

CONAN_CONF = 'conan.conf'
CONAN_SETTINGS = "settings.yml"
Expand Down Expand Up @@ -82,14 +84,6 @@ def settings(self):
self._settings = settings
return self._settings

def export_paths(self, conan_reference):
''' Returns all file paths for a conans (relative to conans directory)'''
return relative_dirs(self.export(conan_reference))

def package_paths(self, package_reference, short_paths):
''' Returns all file paths for a package (relative to conans directory)'''
return relative_dirs(self.package(package_reference, short_paths))

def conan_packages(self, conan_reference):
""" Returns a list of package_id from a local cache package folder """
assert isinstance(conan_reference, ConanFileReference)
Expand Down Expand Up @@ -122,6 +116,11 @@ def load_package_manifest(self, package_reference):
filename = self.digestfile_package(package_reference, short_paths=None)
return FileTreeManifest.loads(load(filename))

def read_package_recipe_hash(self, package_folder):
filename = os.path.join(package_folder, CONANINFO)
info = ConanInfo.loads(load(filename))
return info.recipe_hash

def conan_manifests(self, conan_reference):
digest_path = self.digestfile_conanfile(conan_reference)
if not path_exists(digest_path, self.store):
Expand Down Expand Up @@ -156,7 +155,12 @@ def profile_path(self, name):
return os.path.join(self.profiles_path, name)

def load_profile(self, name):
text = load(self.profile_path(name))
try:
text = load(self.profile_path(name))
except Exception:
current_profiles = ", ".join(self.current_profiles()) or "[]"
raise ConanException("Specified profile '%s' doesn't exist.\nExisting profiles: "
"%s" % (name, current_profiles))
return Profile.loads(text)

def current_profiles(self):
Expand Down
53 changes: 37 additions & 16 deletions conans/client/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def _parse_args(self, parser):
--build Build all from sources, do not use binary packages.
--build=never Default option. Never build, use binary packages or fail if a binary package is not found.
--build=missing Build from code if a binary package is not found.
--build=outdated Build from code if the binary is not built with the current recipe or when missing binary package.
--build=[pattern] Build always these packages from source, but never build the others. Allows multiple --build parameters.
''')

Expand All @@ -103,6 +104,8 @@ def _get_build_sources_parameter(self, build_param):
# False if building is forbidden
# A list with patterns: Will force build matching libraries,
# will look for the package for the rest
# "outdated" if will build when the package is not generated with
# the current exported recipe

if isinstance(build_param, list):
if len(build_param) == 0: # All packages from source
Expand All @@ -111,6 +114,8 @@ def _get_build_sources_parameter(self, build_param):
return False # Default
elif len(build_param) == 1 and build_param[0] == "missing":
return True
elif len(build_param) == 1 and build_param[0] == "outdated":
return "outdated"
else: # A list of expressions to match (if matches, will build from source)
return ["%s*" % ref_expr for ref_expr in build_param]
else:
Expand Down Expand Up @@ -252,6 +257,7 @@ def test_package(self, *args):
conanfile = loader.load_conan(test_conanfile, self._user_io.out, consumer=True)
try:
# convert to list from ItemViews required for python3
conanfile.requirements()
reqs = list(conanfile.requires.items())
first_dep = reqs[0][1].conan_reference
except Exception:
Expand Down Expand Up @@ -431,8 +437,8 @@ def info(self, *args):
scopes=scopes)

def build(self, *args):
""" calls your project conanfile.py "build" method.
EX: conan build ./my_project
""" Calls your project conanfile.py "build" method.
E.g. conan build ./my_project
Intended for package creators, requires a conanfile.py.
"""
parser = argparse.ArgumentParser(description=self.build.__doc__, prog="conan build")
Expand All @@ -450,52 +456,67 @@ def build(self, *args):
self._manager.build(root_path, current_path, filename=args.file, profile_name=args.profile)

def package(self, *args):
""" calls your conanfile.py "package" method for a specific package or
regenerates the existing package's manifest.
It will not create a new package, use 'install' or 'test_package' instead.
""" Calls your conanfile.py "package" method for a specific package recipe.
It will not create a new package, use 'install' or 'test_package' instead for
packages in the conan local cache, or `build' for conanfile.py in user space.
Intended for package creators, for regenerating a package without
recompiling the source, i.e. for troubleshooting,
and fixing the package() method, not normal operation. It requires
the package has been built locally, it will not re-package otherwise.
e.g. conan package MyPackage/1.2@user/channel 9cf83afd07b678da9c1645f605875400847ff3
E.g. conan package MyPackage/1.2@user/channel 9cf83afd07b678da9c1645f605875400847ff3
When used in a user space project, it will execute from the build folder specified
as parameter, and the current directory. This is useful while creating package recipes
or just for extracting artifacts from the current project, without even being a package
"""
parser = argparse.ArgumentParser(description=self.package.__doc__, prog="conan package")
parser.add_argument("reference", help='package recipe reference name. '
'e.g., MyPackage/1.2@user/channel')
parser.add_argument("reference", help='package recipe reference '
'e.g. MyPkg/0.1@user/channel, or local path to the build folder'
' (relative or absolute)')
parser.add_argument("package", nargs="?", default="",
help='Package ID to regenerate. e.g., '
'9cf83afd07b678d38a9c1645f605875400847ff3'
' If not specified, ALL binaries for this recipe are re-packaged')

args = parser.parse_args(*args)

current_path = os.getcwd()
try:
reference = ConanFileReference.loads(args.reference)
self._manager.package(reference, args.package)
except:
raise ConanException("Invalid package recipe reference. "
"e.g., MyPackage/1.2@user/channel")

self._manager.package(reference, args.package)
if "@" in args.reference:
raise
build_folder = args.reference
if not os.path.isabs(build_folder):
build_folder = os.path.normpath(os.path.join(current_path, build_folder))
self._manager.local_package(current_path, build_folder)

def source(self, *args):
""" Calls your conanfile.py "source" method to configure the source directory.
I.e., downloads and unzip the package source.
"""
parser = argparse.ArgumentParser(description=self.source.__doc__, prog="conan source")
parser.add_argument("reference", help="package recipe reference name. e.g., zlib-ng/1.2.8@plex/stable")
parser.add_argument("reference", nargs='?', default="", help="package recipe reference. e.g., MyPackage/1.2@user/channel or ./my_project/")
parser.add_argument("-f", "--force", default=False, action="store_true", help="force remove the source directory and run again.")

args = parser.parse_args(*args)

current_path = os.getcwd()
try:
reference = ConanFileReference.loads(args.reference)
except:
raise ConanException("Invalid package recipe reference. e.g., zlib-ng/1.2.8@plex/stable")
if "@" in args.reference:
raise
if not os.path.isabs(args.reference):
reference = os.path.normpath(os.path.join(current_path, args.reference))
else:
reference = args.reference

self._manager.source(reference, args.force)
self._manager.source(current_path, reference, args.force)

def export(self, *args):
""" copies the package recipe (conanfile.py and associated files) to your local store,
""" Copies the package recipe (conanfile.py and associated files) to your local store,
where it can be shared and reused in other projects.
From that store, it can be uploaded to any remote with "upload" command.
"""
Expand Down
10 changes: 8 additions & 2 deletions conans/client/configure_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ def _gcc_env(self):
lib_paths = " ".join(["-L%s" % lib for lib in self._deps_cpp_info.lib_paths])
ldflags = 'LDFLAGS="%s %s %s %s $LDFLAGS"' % (lib_paths, archflag,
exe_linker_flags, shared_linker_flags)
debug = "-g" if self.build_type == "Debug" else "-s -DNDEBUG"
if self.build_type == "Debug":
debug = "-g"
else:
debug = "-s -DNDEBUG" if self.compiler == "gcc" else "-DNDEBUG"
include_flags = " ".join(['-I%s' % i for i in self._deps_cpp_info.include_paths])
defines = " ".join(['-D%s' % i for i in self._deps_cpp_info.defines])
cflags = 'CFLAGS="$CFLAGS %s %s %s %s %s"' % (archflag,
Expand Down Expand Up @@ -144,7 +147,10 @@ def compile_flags(self):
flags.append("-m32")
flags.extend(self._deps_cpp_info.exelinkflags)
flags.extend(self._deps_cpp_info.sharedlinkflags)
flags.append("-g" if self.build_type == "Debug" else "-s -DNDEBUG")
if self.build_type == "Debug":
flags.append("-g")
else:
flags.append("-s -DNDEBUG" if self.compiler == "gcc" else "-DNDEBUG")
flags.extend('-D%s' % i for i in self._deps_cpp_info.defines)
flags.extend('-I"%s"' % i for i in self._deps_cpp_info.include_paths)
flags.extend('-L"%s"' % i for i in self._deps_cpp_info.lib_paths)
Expand Down
3 changes: 2 additions & 1 deletion conans/client/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ def export_conanfile(output, paths, file_patterns, origin_folder, conan_ref, sho
if remove:
output.info("Removing 'source' folder, this can take a while for big packages")
try:
rmdir(source, short_paths)
# remove only the internal
rmdir(source)
except BaseException as e:
output.error("Unable to delete source folder. "
"Will be marked as dirty for deletion")
Expand Down
3 changes: 2 additions & 1 deletion conans/client/generators/env.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from conans.model import Generator
from conans.paths import CONANENV


class ConanEnvGenerator(Generator):

@property
def filename(self):
return "conanenv.txt"
return CONANENV

@property
def content(self):
Expand Down
8 changes: 4 additions & 4 deletions conans/client/generators/virtualenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ def adjust_var_name(name):
# Allow path with spaces in non-windows platforms
if platform.system() != "Windows" and name in ["PATH", "PYTHONPATH"]:
value = ['"%s"' % v for v in value]
multiple_to_set[name] = os.pathsep.join(value)
multiple_to_set[name] = os.pathsep.join(value).replace("\\", "/")
else:
simple_to_set[name] = value

# It works in windows too using "/" and allows to use MSYS shell
simple_to_set[name] = value.replace("\\", "/")
return multiple_to_set, simple_to_set


Expand All @@ -58,7 +58,7 @@ def content(self):
all_vars = copy.copy(multiple_to_set)
all_vars.update(simple_to_set)
venv_name = os.path.basename(self.conanfile.conanfile_directory)
venv_dir = self.conanfile.conanfile_directory
venv_dir = self.conanfile.conanfile_directory.replace("\\", "/")
deactivate_lines = ["@echo off"] if platform.system() == "Windows" else []
for name in all_vars.keys():
old_value = os.environ.get(name, "")
Expand Down
Loading

0 comments on commit 08e0bd8

Please sign in to comment.