Skip to content

Commit

Permalink
Merge branch 'release/0.27.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
lasote committed Sep 20, 2017
2 parents 1936d10 + ff405a0 commit b7ab0e5
Show file tree
Hide file tree
Showing 110 changed files with 2,659 additions and 1,768 deletions.
14 changes: 12 additions & 2 deletions .ci/appveyor/install.bat
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
if not exist "C:\mingw64" appveyor DownloadFile "https://s3-eu-west-1.amazonaws.com/downloads.conan.io/x86_64-6.3.0-release-posix-sjlj-rt_v5-rev1.7z"
if not exist "C:\mingw64" 7z x x86_64-6.3.0-release-posix-sjlj-rt_v5-rev1.7z -oc:\

set CMAKE_URL="https://cmake.org/files/v3.7/cmake-3.7.0-win64-x64.zip"
mkdir C:\projects\deps
SET ORIGINAL_DIR=%CD%
cd C:\projects\deps
appveyor DownloadFile %CMAKE_URL% -FileName cmake.zip
7z x cmake.zip -oC:\projects\deps > nul
move C:\projects\deps\cmake-* C:\projects\deps\cmake
set PATH=C:\projects\deps\cmake\bin;%PATH%
cmake --version
cd %ORIGINAL_DIR%

SET PATH=%PYTHON%;%PYTHON%\\Scripts;C:\\mingw64\\bin;%PATH%
SET PYTHONPATH=%PYTHONPATH%;%CD%
SET CONAN_LOGGING_LEVEL=10
SET CONAN_COMPILER=Visual Studio
SET CONAN_COMPILER_VERSION=12
%PYTHON%/Scripts/pip.exe install -r conans/requirements.txt
%PYTHON%/Scripts/pip.exe install -r conans/requirements_dev.txt
%PYTHON%/Scripts/pip.exe install -r conans/requirements_server.txt
2 changes: 1 addition & 1 deletion .ci/appveyor/test.bat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nosetests --with-coverage conans.test
nosetests --with-coverage --verbosity=2 conans.test --processes=4 --process-timeout=1000
2 changes: 1 addition & 1 deletion .ci/travis/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ if [[ "$(uname -s)" == 'Darwin' ]]; then
pyenv activate conan
fi

nosetests --with-coverage conans.test
nosetests --with-coverage conans.test --verbosity=2 --processes=4 --process-timeout=1000
16 changes: 9 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
language: python
python:
- 2.7
- 3.4
- 3.5
- 3.6
os: linux
sudo: required
dist: trusty
language: python

matrix:
include:
- python: 2.7
- python: 3.4
if: branch =~ (^release.*)|(^master)
- python: 3.5
if: branch =~ (^release.*)|(^master)
- python: 3.6
- language: generic
os: osx
osx_image: xcode8.3
env: PYVER=py27

if: branch =~ (^release.*)|(^master)
- language: generic
os: osx
osx_image: xcode8.3
Expand All @@ -25,6 +26,7 @@ install:
- ./.ci/travis/install.sh
before_script:
- export PYTHONPATH=$PYTHONPATH:$(pwd)

# command to run tests
script:
- ulimit -n 2048 # Error with py3 and OSX, max file descriptors
Expand Down
2 changes: 1 addition & 1 deletion conans/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
SERVER_CAPABILITIES = [COMPLEX_SEARCH_CAPABILITY, ]


__version__ = '0.26.1'
__version__ = '0.27.0'
6 changes: 1 addition & 5 deletions conans/client/client_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,11 @@ def registry(self):

@property
def conan_config(self):
def generate_default_config_file():
save(self.conan_conf_path, normalize(default_client_conf))

if not self._conan_config:
if not os.path.exists(self.conan_conf_path):
generate_default_config_file()
save(self.conan_conf_path, normalize(default_client_conf))

self._conan_config = ConanClientConfigParser(self.conan_conf_path)

return self._conan_config

@property
Expand Down
28 changes: 21 additions & 7 deletions conans/client/cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@ def _get_env_cmake_system_name():
class CMake(object):

def __init__(self, settings_or_conanfile, generator=None, cmake_system_name=True,
parallel=True):
parallel=True, build_type=None):
"""
:param settings_or_conanfile: Conanfile instance (or settings for retro compatibility)
:param generator: Generator name to use or none to autodetect
:param cmake_system_name: False to not use CMAKE_SYSTEM_NAME variable,
True for auto-detect or directly a string with the system name
:param parallel: Try to build with multiple cores if available
:param build_type: Overrides default build type comming from settings
"""
if isinstance(settings_or_conanfile, Settings):
self._settings = settings_or_conanfile
Expand All @@ -64,10 +65,10 @@ def __init__(self, settings_or_conanfile, generator=None, cmake_system_name=True
self._compiler = self._settings.get_safe("compiler")
self._compiler_version = self._settings.get_safe("compiler.version")
self._arch = self._settings.get_safe("arch")
self._build_type = self._settings.get_safe("build_type")
self._op_system_version = self._settings.get_safe("os.version")
self._libcxx = self._settings.get_safe("compiler.libcxx")
self._runtime = self._settings.get_safe("compiler.runtime")
self._build_type = self._settings.get_safe("build_type")

self.generator = generator or self._generator()
self.build_dir = None
Expand All @@ -76,6 +77,23 @@ def __init__(self, settings_or_conanfile, generator=None, cmake_system_name=True
self._cmake_system_name = cmake_system_name
self.parallel = parallel
self.definitions = self._get_cmake_definitions()
if build_type and build_type != self._build_type:
# Call the setter to warn and update the definitions if needed
self.build_type = build_type

@property
def build_type(self):
return self._build_type

@build_type.setter
def build_type(self, build_type):
settings_build_type = self._settings.get_safe("build_type")
if build_type != settings_build_type:
self._conanfile.output.warn(
'Set CMake build type "%s" is different than the settings build_type "%s"'
% (build_type, settings_build_type))
self._build_type = build_type
self.definitions.update(self._build_type_definition())

@property
def flags(self):
Expand Down Expand Up @@ -213,18 +231,14 @@ def command_line(self):
'-Wno-dev'
])

@property
def build_type(self):
return self._defs_to_string(self._build_type_definition())

def _build_type_definition(self):
if self._build_type and not self.is_multi_configuration:
return {'CMAKE_BUILD_TYPE': self._build_type}
return {}

@property
def runtime(self):
return self._defs_to_string(self._runtime_definition())
return _defs_to_string(self._runtime_definition())

def _runtime_definition(self):
if self._runtime:
Expand Down
25 changes: 18 additions & 7 deletions conans/client/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,19 +268,21 @@ def install(self, *args):
filename=args.file, cwd=args.cwd)

def config(self, *args):
"""Manages conan.conf information
"""Manages conan configuration information
"""
parser = argparse.ArgumentParser(description=self.config.__doc__, prog="conan config")

subparsers = parser.add_subparsers(dest='subcommand', help='sub-command help')
rm_subparser = subparsers.add_parser('rm', help='rm an existing config element')
set_subparser = subparsers.add_parser('set', help='set/add value')
get_subparser = subparsers.add_parser('get', help='get the value of existing element')
install_subparser = subparsers.add_parser('install',
help='install a full configuration from a zip file, local or remote')

rm_subparser.add_argument("item", help="item to remove")
get_subparser.add_argument("item", nargs="?", help="item to print")
set_subparser.add_argument("item", help="key=value to set")

install_subparser.add_argument("item", nargs="?", help="configuration file to use")
args = parser.parse_args(*args)

if args.subcommand == "set":
Expand All @@ -293,6 +295,8 @@ def config(self, *args):
return self._conan.config_get(args.item)
elif args.subcommand == "rm":
return self._conan.config_rm(args.item)
elif args.subcommand == "install":
return self._conan.config_install(args.item)

def info(self, *args):
"""Prints information about a package recipe's dependency graph.
Expand Down Expand Up @@ -368,11 +372,11 @@ def info(self, *args):
only = []
if only and args.paths and (set(only) - set(path_only_options)):
raise ConanException("Invalid --only value '%s' with --path specified, allowed values: [%s]."
% (only, str_path_only_options))
% (only, str_path_only_options))
elif only and not args.paths and (set(only) - set(info_only_options)):
raise ConanException("Invalid --only value '%s', allowed values: [%s].\n"
"Use --only=None to show only the references." %
(only, str_only_options))
"Use --only=None to show only the references."
% (only, str_only_options))

if args.graph:
self._outputer.info_graph(args.graph, deps_graph, project_reference, args.cwd)
Expand Down Expand Up @@ -451,9 +455,10 @@ def source(self, *args):
" folder, then the execution and retrieval of the source code."
" Otherwise, if the code has already been retrieved, it will"
" do nothing.")
parser.add_argument("--cwd", "-c", help='Use this directory as the current directory')

args = parser.parse_args(*args)
return self._conan.source(args.reference, args.force)
return self._conan.source(args.reference, args.force, cwd=args.cwd)

def imports(self, *args):
""" Execute the 'imports' stage of a conanfile.txt or a conanfile.py.
Expand Down Expand Up @@ -712,7 +717,6 @@ def remote(self, *args):

verify_ssl = get_bool_from_text(args.verify_ssl) if hasattr(args, 'verify_ssl') else False


remote = args.remote if hasattr(args, 'remote') else None
url = args.url if hasattr(args, 'url') else None

Expand Down Expand Up @@ -761,6 +765,10 @@ def profile(self, *args):
parser_update.add_argument('item', help='key="value to set", e.j: settings.compiler=gcc')
parser_update.add_argument('profile', help='name of the profile')

parser_get = subparsers.add_parser('get', help='Get a profile key')
parser_get.add_argument('item', help='key="value to get", e.j: settings.compiler')
parser_get.add_argument('profile', help='name of the profile')

parser_remove = subparsers.add_parser('remove', help='Remove a profile key')
parser_remove.add_argument('item', help='key", e.j: settings.compiler')
parser_remove.add_argument('profile', help='name of the profile')
Expand All @@ -783,6 +791,9 @@ def profile(self, *args):
except:
raise ConanException("Please specify key=value")
self._conan.update_profile(profile, key, value)
elif args.subcommand == "get":
key = args.item
self._outputer.writeln(self._conan.get_profile_key(profile, key))
elif args.subcommand == "remove":
self._conan.delete_profile_key(profile, args.item)

Expand Down
48 changes: 40 additions & 8 deletions conans/client/conan_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@

def get_basic_requester(client_cache):
requester = requests.Session()
requester.proxies = client_cache.conan_config.proxies
proxies = client_cache.conan_config.proxies
if proxies:
# Account for the requests NO_PROXY env variable, not defined as a proxy like http=
no_proxy = proxies.pop("no_proxy", None)
if no_proxy:
os.environ["NO_PROXY"] = no_proxy
requester.proxies = proxies
return requester


Expand Down Expand Up @@ -168,8 +174,8 @@ def new(self, name, header=False, pure_c=False, test=False, exports_sources=Fals
@api_method
def test_package(self, profile_name=None, settings=None, options=None, env=None,
scope=None, test_folder=None, not_export=False, build=None, keep_source=False,
verify=default_manifest_folder, manifests=default_manifest_folder,
manifests_interactive=default_manifest_folder,
verify=None, manifests=None,
manifests_interactive=None,
remote=None, update=False, cwd=None, user=None, channel=None, name=None,
version=None):
settings = settings or []
Expand Down Expand Up @@ -260,8 +266,8 @@ def test_package(self, profile_name=None, settings=None, options=None, env=None,
@api_method
def create(self, profile_name=None, settings=None,
options=None, env=None, scope=None, test_folder=None, not_export=False, build=None,
keep_source=False, verify=default_manifest_folder,
manifests=default_manifest_folder, manifests_interactive=default_manifest_folder,
keep_source=False, verify=None,
manifests=None, manifests_interactive=None,
remote=None, update=False, cwd=None,
user=None, channel=None, name=None, version=None):

Expand Down Expand Up @@ -359,8 +365,8 @@ def package_files(self, reference, source_folder=None, build_folder=None, packag

@api_method
def install(self, reference="", package=None, settings=None, options=None, env=None, scope=None, all=False,
remote=None, werror=False, verify=default_manifest_folder, manifests=default_manifest_folder,
manifests_interactive=default_manifest_folder, build=None, profile_name=None,
remote=None, werror=False, verify=None, manifests=None,
manifests_interactive=None, build=None, profile_name=None,
update=False, generator=None, no_imports=False, filename=None, cwd=None):

self._user_io.out.werror_active = werror
Expand Down Expand Up @@ -414,6 +420,11 @@ def config_rm(self, item):
config_parser = ConanClientConfigParser(self._client_cache.conan_conf_path)
config_parser.rm_item(item)

@api_method
def config_install(self, item):
from conans.client.conf.config_installer import configuration_install
return configuration_install(item, self._client_cache, self._user_io.out, self._runner)

@api_method
def info_build_order(self, reference, settings=None, options=None, env=None, scope=None, profile_name=None,
filename=None, remote=None, build_order=None, check_updates=None, cwd=None):
Expand Down Expand Up @@ -526,7 +537,6 @@ def imports(self, reference, undo=False, dest=None, filename=None, cwd=None):
current_path = reference
self._manager.imports_undo(current_path)
else:
cwd = prepare_cwd(cwd)
current_path, reference = _get_reference(reference, cwd)
self._manager.imports(current_path, reference, filename, dest)

Expand Down Expand Up @@ -686,6 +696,26 @@ def update_profile(self, profile_name, key, value):
profile_path = get_profile_path(profile_name, self._client_cache.profiles_path, os.getcwd())
save(profile_path, contents)

@api_method
def get_profile_key(self, profile_name, key):
first_key, rest_key = self._get_profile_keys(key)
profile, _ = read_profile(profile_name, os.getcwd(), self._client_cache.profiles_path)
try:
if first_key == "settings":
return profile.settings[rest_key]
elif first_key == "options":
return dict(profile.options.as_list())[rest_key]
elif first_key == "env":
package = None
var = rest_key
if ":" in rest_key:
package, var = rest_key.split(":")
return profile.env_values.data[package][var]
elif first_key == "build_requires":
raise ConanException("List the profile manually to see the build_requires")
except KeyError:
raise ConanException("Key not found: '%s'" % key)

@api_method
def delete_profile_key(self, profile_name, key):
first_key, rest_key = self._get_profile_keys(key)
Expand Down Expand Up @@ -759,6 +789,8 @@ def _parse_manifests_arguments(verify, manifests, manifests_interactive, cwd):
manifest_folder = verify or manifests or manifests_interactive
if manifest_folder:
if not os.path.isabs(manifest_folder):
if not cwd:
raise ConanException("'cwd' should be defined if the manifest folder is relative.")
manifest_folder = os.path.join(cwd, manifest_folder)
manifest_verify = verify is not None
manifest_interactive = manifests_interactive is not None
Expand Down
3 changes: 3 additions & 0 deletions conans/client/conan_command_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ def __init__(self, user_io, client_cache):
self.user_io = user_io
self.client_cache = client_cache

def writeln(self, value):
self.user_io.out.writeln(value)

def print_profile(self, profile, profile_text):
Printer(self.user_io.out).print_profile(profile, profile_text)

Expand Down
Loading

0 comments on commit b7ab0e5

Please sign in to comment.