Skip to content

Commit

Permalink
Merge branch 'release/1.12.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
lasote committed Feb 18, 2019
2 parents 3ba8012 + e9e5f7e commit a52dcdc
Show file tree
Hide file tree
Showing 18 changed files with 235 additions and 121 deletions.
1 change: 0 additions & 1 deletion .ci/jenkins/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ def test_revisions = true
def is_pr = false
def excluded_tags = []


if(env.JOB_NAME == "ConanNightly"){
full_py_vers = true
test_revisions = true
Expand Down
2 changes: 1 addition & 1 deletion conans/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
SERVER_CAPABILITIES = [COMPLEX_SEARCH_CAPABILITY, REVISIONS] # Server is always with revisions
DEFAULT_REVISION_V1 = "0"

__version__ = '1.12.2'
__version__ = '1.12.3'
2 changes: 2 additions & 0 deletions conans/client/build/cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def __init__(self, conanfile, generator=None, cmake_system_name=True,
self._cmake_program = os.getenv("CONAN_CMAKE_PROGRAM") or cmake_program or "cmake"

self.generator = generator or get_generator(conanfile.settings)
if not self.generator:
self._conanfile.output.warn("CMake generator could not be deduced from settings")
self.parallel = parallel
# Initialize definitions (won't be updated if conanfile or any of these variables change)
builder = CMakeDefinitionsBuilder(self._conanfile,
Expand Down
5 changes: 4 additions & 1 deletion conans/client/build/cmake_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def get_generator(settings):

if not compiler or not compiler_version or not arch:
if os_build == "Windows":
return "MinGW Makefiles"
logger.warning("CMake generator could not be deduced from settings")
return None
return "Unix Makefiles"

if compiler == "Visual Studio":
Expand Down Expand Up @@ -64,6 +65,8 @@ def get_generator(settings):


def is_multi_configuration(generator):
if not generator:
return False
return "Visual" in generator or "Xcode" in generator


Expand Down
3 changes: 2 additions & 1 deletion conans/client/build/msbuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from conans.errors import ConanException
from conans.model.conan_file import ConanFile
from conans.model.version import Version
from conans.tools import vcvars_command as tools_vcvars_command
from conans.util.env_reader import get_env
from conans.util.files import decode_text, save

Expand Down Expand Up @@ -221,7 +222,7 @@ def format_macro(name, value):
@staticmethod
def get_version(settings):
msbuild_cmd = "msbuild -version"
vcvars = vcvars_command(settings)
vcvars = tools_vcvars_command(settings)
command = "%s && %s" % (vcvars, msbuild_cmd)
try:
out, _ = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True).communicate()
Expand Down
2 changes: 1 addition & 1 deletion conans/client/cmd/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def _search_packages_in_all(self, ref=None, query=None, outdated=False):
continue
return references

return self._search_packages_in(self, 'all', ref, query, outdated)
return self._search_packages_in('all', ref, query, outdated)

def _search_packages_in(self, remote_name, ref=None, query=None, outdated=False):
remote = self._registry.remotes.get(remote_name)
Expand Down
2 changes: 1 addition & 1 deletion conans/client/generators/virtualbuildenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def __init__(self, conanfile):
compiler = conanfile.settings.get_safe("compiler")
if compiler == "Visual Studio":
self.env = VisualStudioBuildEnvironment(conanfile).vars_dict
self.env.update(vcvars_dict(conanfile.settings))
self.env.update(vcvars_dict(conanfile.settings, output=conanfile.output))
else:
self.env = AutoToolsBuildEnvironment(conanfile).vars_dict

Expand Down
31 changes: 21 additions & 10 deletions conans/client/loader_txt.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ class ConanFileTextLoader(object):
def __init__(self, input_text):
# Prefer composition over inheritance, the __getattr__ was breaking things
self._config_parser = ConfigParser(input_text, ["requires", "generators", "options",
"imports", "build_requires"], parse_lines=True)
"imports", "build_requires"],
parse_lines=True)

@property
def requirements(self):
Expand All @@ -33,8 +34,13 @@ def _import_parameters(self):
def _parse_args(param_string):
root_package, ignore_case, folder, excludes, keep_path = None, False, False, None, True
params = param_string.split(",")
params = [p.split("=") for p in params if p]
for (var, value) in params:
params = [p.strip() for p in params if p.strip()]
for param in params:
try:
var, value = param.split("=")
except ValueError:
raise ConanException("Wrong imports argument '%s'. "
"Need a 'arg=value' pair." % param)
var = var.strip()
value = value.strip()
if var == "root_package":
Expand All @@ -52,11 +58,15 @@ def _parse_args(param_string):
return root_package, ignore_case, folder, excludes, keep_path

def _parse_import(line):
pair = line.split("->")
source = pair[0].strip().split(',', 1)
dest = pair[1].strip()
src, pattern = source[0].strip(), source[1].strip()
return pattern, dest, src
try:
pair = line.split("->", 1)
source = pair[0].strip().split(',', 1)
dest = pair[1].strip()
src, pattern = source[0].strip(), source[1].strip()
return pattern, dest, src
except Exception:
raise ConanException("Wrong imports line: %s\n"
"Use syntax: path, pattern -> local-folder" % line)

ret = []
local_install_text = self._config_parser.imports
Expand All @@ -72,15 +82,16 @@ def _parse_import(line):
raise ConanException("%s\n%s" % (invalid_line_msg,
"Import's paths can't begin with '/' or '..'"))
try:
tokens = line.split("@", 1)
tokens = line.rsplit("@", 1)
if len(tokens) > 1:
line = tokens[0]
params = tokens[1]
else:
params = ""
root_package, ignore_case, folder, excludes, keep_path = _parse_args(params)
pattern, dest, src = _parse_import(line)
ret.append((pattern, dest, src, root_package, folder, ignore_case, excludes, keep_path))
ret.append((pattern, dest, src, root_package, folder, ignore_case, excludes,
keep_path))
except Exception as e:
raise ConanException("%s\n%s" % (invalid_line_msg, str(e)))
return ret
Expand Down
2 changes: 2 additions & 0 deletions conans/client/tools/oss.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ class _OSVERSIONINFOEXW(ctypes.Structure):

os_version = _OSVERSIONINFOEXW()
os_version.dwOSVersionInfoSize = ctypes.sizeof(os_version)
if not hasattr(ctypes, "windll"):
return None
retcode = ctypes.windll.Ntdll.RtlGetVersion(ctypes.byref(os_version))
if retcode != 0:
return None
Expand Down
2 changes: 1 addition & 1 deletion conans/model/package_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def loads(data):
ret = _RecipeMetadata()
ret.revision = data["revision"]
ret.properties = data["properties"]
ret.time = data["time"]
ret.time = data.get("time")
return ret


Expand Down
38 changes: 38 additions & 0 deletions conans/test/functional/build_helpers/cmake_flags_test.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import os
import platform
import unittest
from textwrap import dedent

from nose.plugins.attrib import attr
from parameterized.parameterized import parameterized

from conans import load
from conans.client.build.cmake import CMake
from conans.model.version import Version
from conans.test.utils.tools import TestClient
Expand Down Expand Up @@ -431,3 +433,39 @@ def build(self):
client.save({"CMakeLists.txt": tmp, "conanfile.py": conanfile}, clean_first=True)
client.run("create . user/channel -o MyLib:fPIC=True")
self.assertNotIn("Conan: Adjusting fPIC flag", client.out)

def header_only_generator_test(self):
""" Test cmake.install() is possible although Generetaor could not be deduced from
settings
"""
conanfile = dedent("""
from conans import ConanFile, CMake
class TestConan(ConanFile):
name = "kk"
version = "1.0"
exports = "*"
def package(self):
cmake = CMake(self)
self.output.info("Configure command: %s" % cmake.command_line)
cmake.configure()
cmake.install()
""")
cmakelists = dedent("""
cmake_minimum_required(VERSION 3.3)
project(test)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
""")
client = TestClient()
client.save({"conanfile.py": conanfile, "CMakeLists.txt": cmakelists, "include/file.h": ""})
client.run("create . danimtb/testing")
if platform.system() == "Windows":
self.assertIn("WARN: CMake generator could not be deduced from settings", client.out)
self.assertIn('Configure command: -DCONAN_EXPORTED="1" -DCONAN_IN_LOCAL_CACHE="ON" '
'-DCMAKE_INSTALL_PREFIX=', client.out)
else:
self.assertIn('Configure command: -G "Unix Makefiles" -DCONAN_EXPORTED="1" '
'-DCONAN_IN_LOCAL_CACHE="ON" -DCMAKE_INSTALL_PREFIX=', client.out)
9 changes: 5 additions & 4 deletions conans/test/functional/build_helpers/msbuild_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from nose.plugins.attrib import attr
from parameterized import parameterized

from conans.client import tools
from conans.client.tools.files import replace_in_file
from conans.model.ref import PackageReference
from conans.paths import CONANFILE
from conans.test.utils.tools import TestClient
Expand Down Expand Up @@ -51,9 +51,10 @@ def package(self):
files[CONANFILE] = conan_build_vs

# Try to not update the project
client.cache._conan_config = None # Invalidate cached config
tools.replace_in_file(client.cache.conan_conf_path, "[general]",
"[general]\nskip_vs_projects_upgrade = True")
client.cache._config = None # Invalidate cached config
replace_in_file(client.cache.conan_conf_path, "[general]",
"[general]\nskip_vs_projects_upgrade = True", output=client.out)

client.save(files, clean_first=True)
client.run("create . Hello/1.2.1@lasote/stable --build")
self.assertNotIn("devenv", client.user_io.out)
Expand Down
26 changes: 26 additions & 0 deletions conans/test/functional/command/search_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import os
import shutil
import textwrap
import unittest
from collections import OrderedDict

Expand Down Expand Up @@ -1076,3 +1077,28 @@ class Test(ConanFile):
client.run("search Test/0.1@lasote/testing %s --outdated" % remote)
self.assertIn("os: Windows", client.user_io.out)
self.assertNotIn("os: Linux", client.user_io.out)


class SearchRemoteAllTestCase(unittest.TestCase):
def setUp(self):
""" Create a remote called 'all' with some recipe in it """
self.remote_name = 'all'
servers = {self.remote_name: TestServer(users={"user": "passwd"})}
self.client = TestClient(servers=servers, users={self.remote_name: [("user", "passwd")], })

conanfile = textwrap.dedent("""
from conans import ConanFile
class MyLib(ConanFile):
pass
""")

self.reference = "name/version@user/channel"
self.client.save({'conanfile.py': conanfile})
self.client.run("export . {}".format(self.reference))
self.client.run("upload --force -r {} {}".format(self.remote_name, self.reference))

def test_search_by_name(self):
self.client.run("remote list")
self.assertIn("all: http://fake", self.client.out)
self.client.run("search -r {} {}".format(self.remote_name, self.reference))
self.assertIn("Existing recipe in remote 'all':", self.client.out) # Searching in 'all'
46 changes: 43 additions & 3 deletions conans/test/functional/conanfile/imports_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,46 @@ def imports_folders_txt_test(self):
self.assertEqual(load(os.path.join(client.current_folder, "licenses/LibC/license.txt")),
"LicenseC")

def imports_wrong_args_txt_test(self):
client = TestClient()
conanfile = """
[imports]
., license* -> lic@myfolder @ something
"""
client.save({"conanfile.txt": conanfile})
client.run("install .", assert_error=True)
self.assertIn("Wrong imports argument 'something'. Need a 'arg=value' pair.", client.out)

def imports_wrong_line_txt_test(self):
client = TestClient()
conanfile = """
[imports]
., license*
"""
client.save({"conanfile.txt": conanfile})
client.run("install .", assert_error=True)
self.assertIn("Wrong imports line: ., license*", client.out)
self.assertIn("Use syntax: path, pattern -> local-folder", client.out)

def imports_folders_extrachars_txt_test(self):
# https://github.com/conan-io/conan/issues/4524
client = self._set_up()

conanfile = """[requires]
LibC/0.1@lasote/testing
[imports]
., license* -> lic@myfolder @ folder=True, ignore_case=True, excludes=*.md # comment
., *.md -> lic@myfolder @ # This is mandatory, otherwise it will fail
"""
client.save({"conanfile.txt": conanfile}, clean_first=True)
client.run("install . --build=missing")
self.assertEqual(load(os.path.join(client.current_folder, "lic@myfolder/LibA/LICENSE.txt")),
"LicenseA")
self.assertEqual(load(os.path.join(client.current_folder, "lic@myfolder/LICENSE.md")),
"LicenseB")
self.assertEqual(load(os.path.join(client.current_folder, "lic@myfolder/LibC/license.txt")),
"LicenseC")

def conanfile_txt_multi_excludes_test(self):
# https://github.com/conan-io/conan/issues/2293
client = TestClient()
Expand Down Expand Up @@ -138,14 +178,14 @@ def imports(self):
client.save({"conanfile.py": testconanfile}, clean_first=True)
client.run("install . --build=missing")
self.assertTrue(os.path.exists(os.path.join(client.current_folder,
"licenses/path/to/license.txt")))
"licenses/path/to/license.txt")))

# keep_path = False AND conanfile.py
testconanfile = testconanfile.replace("keep_path=True", "keep_path=False")
client.save({"conanfile.py": testconanfile}, clean_first=True)
client.run("install . --build=missing")
self.assertTrue(os.path.exists(os.path.join(client.current_folder,
"licenses/license.txt")))
"licenses/license.txt")))

# keep_path = True AND conanfile.txt
testconanfile = conanfile_txt % "LibC/0.1@lasote/testing"
Expand All @@ -156,7 +196,7 @@ def imports(self):
client.save({"conanfile.txt": testconanfile}, clean_first=True)
client.run("install . --build=missing")
self.assertTrue(os.path.exists(os.path.join(client.current_folder,
"licenses/path/to/license.txt")))
"licenses/path/to/license.txt")))

# keep_path = False AND conanfile.txt
testconanfile = testconanfile.replace("keep_path=True", "keep_path=False")
Expand Down
12 changes: 8 additions & 4 deletions conans/test/functional/generators/cmake_generator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,20 @@ def _check_build_generator(self, os_build, generator):
client.run("install . -p my_profile")
client.run("build .")

self.assertIn('cmake -G "{}"'.format(generator), client.out)
self.assertTrue(os.path.isfile(os.path.join(client.current_folder, "Makefile")))
if generator:
self.assertIn('cmake -G "{}"'.format(generator), client.out)
self.assertTrue(os.path.isfile(os.path.join(client.current_folder, "Makefile")))
else:
self.assertNotIn("cmake -G", client.out)
self.assertFalse(os.path.isfile(os.path.join(client.current_folder, "Makefile")))

@unittest.skipUnless(tools.os_info.is_linux, "Compilation with real gcc needed")
def test_cmake_default_generator_linux(self):
self._check_build_generator("Linux", "Unix Makefiles")

@unittest.skipUnless(tools.os_info.is_windows, "MinGW is only supported on Windows")
@unittest.skipUnless(tools.os_info.is_windows, "Windows does not support default compiler")
def test_cmake_default_generator_windows(self):
self._check_build_generator("Windows", "MinGW Makefiles")
self._check_build_generator("Windows", None)

@unittest.skipUnless(tools.os_info.is_macos, "Compilation with real clang is needed")
def test_cmake_default_generator_osx(self):
Expand Down
Loading

0 comments on commit a52dcdc

Please sign in to comment.