Skip to content

Commit

Permalink
Merge branch 'release/0.17.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
lasote committed Dec 15, 2016
2 parents 0474142 + 5452aa7 commit 8086384
Show file tree
Hide file tree
Showing 13 changed files with 206 additions and 42 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,9 @@ License
.. |Build Status2| image:: https://travis-ci.org/conan-io/conan.svg?branch=develop
:target: https://travis-ci.org/conan-io/conan
.. |Build status3| image:: https://ci.appveyor.com/api/projects/status/dae0ple27akmpgj4/branch/master?svg=true
:target: https://ci.appveyor.com/api/projects/status/dae0ple27akmpgj4/branch/master
:target: https://ci.appveyor.com/project/ConanCIintegration/conan/branch/master
.. |Build status4| image:: https://ci.appveyor.com/api/projects/status/dae0ple27akmpgj4/branch/develop?svg=true
:target: https://ci.appveyor.com/api/projects/status/dae0ple27akmpgj4/branch/develop
:target: https://ci.appveyor.com/project/ConanCIintegration/conan/branch/develop
.. _`pip docs`: https://pip.pypa.io/en/stable/installing/
.. _`brew homepage`: http://brew.sh/

2 changes: 1 addition & 1 deletion conans/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
COMPLEX_SEARCH_CAPABILITY = "complex_search"
SERVER_CAPABILITIES = [COMPLEX_SEARCH_CAPABILITY, ]

__version__ = '0.17.0'
__version__ = '0.17.1'

4 changes: 2 additions & 2 deletions conans/client/client_cache.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
from conans.util.files import save, load, path_exists, mkdir, normalize
from conans.util.files import save, load, mkdir, normalize
from conans.model.settings import Settings
from conans.client.conf import ConanClientConfigParser, default_client_conf, default_settings_yml
from conans.model.values import Values
Expand Down Expand Up @@ -122,7 +122,7 @@ def read_package_recipe_hash(self, package_folder):

def conan_manifests(self, conan_reference):
digest_path = self.digestfile_conanfile(conan_reference)
if not path_exists(digest_path, self.store):
if not os.path.exists(digest_path):
return None, None
return self._digests(digest_path)

Expand Down
15 changes: 10 additions & 5 deletions conans/client/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,19 @@ def download(self, reference, package_ids, remote=None):
assert(isinstance(reference, ConanFileReference))
remote_proxy = ConanProxy(self._client_cache, self._user_io, self._remote_manager, remote)

package = remote_proxy.search(reference, None)
if not package: # Search the reference first, and raise if it doesn't exist
raise ConanException("'%s' not found in remote" % str(reference))

if package_ids:
remote_proxy.download_packages(reference, package_ids)
else: # Not specified packages, download all
else:
packages_props = remote_proxy.search_packages(reference, None)
if not packages_props: # No filter by properties
raise ConanException("'%s' not found in remote" % str(reference))

remote_proxy.download_packages(reference, list(packages_props.keys()))
if not packages_props:
output = ScopedOutput(str(reference), self._user_io.out)
output.warn("No remote binary packages found in remote")
else:
remote_proxy.download_packages(reference, list(packages_props.keys()))

def _get_graph(self, reference, current_path, remote, options, settings, filename, update,
check_updates, manifest_manager, scopes, package_settings, env, package_env):
Expand Down
5 changes: 2 additions & 3 deletions conans/client/proxy.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from conans.client.output import ScopedOutput
from conans.util.files import path_exists, rmdir
from conans.util.files import rmdir
from conans.model.ref import PackageReference
from conans.errors import (ConanException, ConanConnectionError, ConanOutdatedClient,
NotFoundException)
Expand Down Expand Up @@ -103,9 +103,8 @@ def _refresh():

# check if it is in disk
conanfile_path = self._client_cache.conanfile(conan_reference)
path_exist = path_exists(conanfile_path, self._client_cache.store)

if path_exist:
if os.path.exists(conanfile_path):
if self._check_updates:
ret = self.update_available(conan_reference)
if ret != 0: # Found and not equal
Expand Down
4 changes: 3 additions & 1 deletion conans/client/remote_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from requests.exceptions import ConnectionError

from conans.errors import ConanException, ConanConnectionError
from conans.util.files import tar_extract, relative_dirs
from conans.util.files import tar_extract, relative_dirs, rmdir
from conans.util.log import logger
from conans.paths import PACKAGE_TGZ_NAME, CONANINFO, CONAN_MANIFEST, CONANFILE, EXPORT_TGZ_NAME,\
rm_conandir
Expand Down Expand Up @@ -108,6 +108,7 @@ def get_recipe(self, conan_reference, dest_folder, remote):
Will iterate the remotes to find the conans unless remote was specified
returns (dict relative_filepath:abs_path , remote_name)"""
rmdir(dest_folder) # Remove first the destination folder
zipped_files = self._call_remote(remote, "get_recipe", conan_reference, dest_folder)
files = unzip_and_get_files(zipped_files, dest_folder, EXPORT_TGZ_NAME)
# Make sure that the source dir is deleted
Expand All @@ -125,6 +126,7 @@ def get_package(self, package_reference, dest_folder, remote):
Will iterate the remotes to find the conans unless remote was specified
returns (dict relative_filepath:abs_path , remote_name)"""
rm_conandir(dest_folder) # Remove first the destination folder
zipped_files = self._call_remote(remote, "get_package", package_reference, dest_folder)
files = unzip_and_get_files(zipped_files, dest_folder, PACKAGE_TGZ_NAME)
# Issue #214 https://github.com/conan-io/conan/issues/214
Expand Down
5 changes: 5 additions & 0 deletions conans/client/rest/uploader_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ def __init__(self, requester, output, verify, chunk_size=1000):
self.verify = verify

def download(self, url, file_path=None, auth=None):

if file_path and os.path.exists(file_path):
# Should not happen, better to raise, probably we had to remove the dest folder before
raise ConanException("Error, the file to download already exists: '%s'" % file_path)

ret = bytearray()
response = self.requester.get(url, stream=True, verify=self.verify, auth=auth)
if not response.ok:
Expand Down
30 changes: 30 additions & 0 deletions conans/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,34 @@ def _rm_conandir(path):
rm_conandir = rmdir


def is_case_insensitive_os():
system = platform.system()
return system != "Linux" and system != "FreeBSD"


if is_case_insensitive_os():
def _check_ref_case(conan_reference, conan_folder, store_folder):
if not os.path.exists(conan_folder): # If it doesn't exist, not a problem
return
# If exists, lets check path
tmp = store_folder
for part in conan_reference:
items = os.listdir(tmp)
if part not in items:
offending = ""
for item in items:
if item.lower() == part.lower():
offending = item
break
raise ConanException("Requested '%s' but found case incompatible '%s'\n"
"Case insensitive filesystem can't manage this"
% (str(conan_reference), offending))
tmp = os.path.normpath(tmp + os.sep + part)
else:
def _check_ref_case(conan_reference, conan_folder, store_folder): # @UnusedVariable
pass


def _shortener(path, short_paths):
""" short_paths is 4-state:
False: Never shorten the path
Expand Down Expand Up @@ -143,10 +171,12 @@ def source(self, conan_reference, short_paths=False):

def conanfile(self, conan_reference):
export = self.export(conan_reference)
_check_ref_case(conan_reference, export, self.store)
return normpath(join(export, CONANFILE))

def digestfile_conanfile(self, conan_reference):
export = self.export(conan_reference)
_check_ref_case(conan_reference, export, self.store)
return normpath(join(export, CONAN_MANIFEST))

def digestfile_package(self, package_reference, short_paths=False):
Expand Down
1 change: 0 additions & 1 deletion conans/test/command/source_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ def basic_source_test(self):
class ConanLib(ConanFile):
name = "Hello"
version = "0.1"
exports = "*"
def source(self):
self.output.info("Running source!")
Expand Down
83 changes: 83 additions & 0 deletions conans/test/integration/case_sensitive_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import unittest
from conans.test.tools import TestClient, TestServer
from conans.test.utils.cpp_test_files import cpp_hello_conan_files
from conans.paths import is_case_insensitive_os, CONANFILE


conanfile = '''
from conans import ConanFile
class ConanLib(ConanFile):
name = "Hello0"
version = "0.1"
def source(self):
self.output.info("Running source!")
'''


class CaseSensitiveTest(unittest.TestCase):

def install_test(self):
test_server = TestServer()
servers = {"default": test_server}
client = TestClient(servers=servers, users={"default": [("lasote", "mypass")]})

files = cpp_hello_conan_files("Hello0", "0.1", build=False)
client.save(files)
client.run("export lasote/stable")

client.run("install Hello0/0.1@lasote/stable --build missing")
client.run("upload Hello0/0.1@lasote/stable --all")

# If we try to install the same package with --build oudated it's already ok
files = cpp_hello_conan_files("Hello1", "0.1", deps=["hello0/0.1@lasote/stable"],
build=False)
client.save(files)
error = client.run("install", ignore_error=True)
self._check(error, client)

def _check(self, error, client):
self.assertTrue(error)
if is_case_insensitive_os():
self.assertIn("case incompatible 'Hello0'", client.user_io.out)
else:
self.assertNotIn("case incompatible 'Hello0'", client.user_io.out)

def install_same_test(self):
client = TestClient()
client.save({CONANFILE: conanfile})
client.run("export lasote/stable")
error = client.run("install hello0/0.1@lasote/stable --build=missing", ignore_error=True)
self._check(error, client)

def imports_test(self):
client = TestClient()
client.save({CONANFILE: conanfile})
client.run("export lasote/stable")
client.run("install Hello0/0.1@lasote/stable --build=missing")
error = client.run("imports hello0/0.1@lasote/stable", ignore_error=True)
self._check(error, client)

def package_test(self):
client = TestClient()
client.save({CONANFILE: conanfile})
client.run("export lasote/stable")
client.run("install Hello0/0.1@lasote/stable --build=missing")
error = client.run("package hello0/0.1@lasote/stable", ignore_error=True)
self._check(error, client)

def copy_test(self):
client = TestClient()
client.save({CONANFILE: conanfile})
client.run("export lasote/stable")
client.run("install Hello0/0.1@lasote/stable --build=missing")
error = client.run("copy hello0/0.1@lasote/stable otheruser/testing", ignore_error=True)
self._check(error, client)

def source_test(self):
client = TestClient()
client.save({CONANFILE: conanfile})
client.run("export lasote/stable")
error = client.run("source hello0/0.1@lasote/stable", ignore_error=True)
self._check(error, client)
63 changes: 56 additions & 7 deletions conans/test/integration/install_selected_packages_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@
import os
from conans.test.utils.cpp_test_files import cpp_hello_conan_files
from conans.paths import CONANFILE
from conans.model.ref import ConanFileReference
from conans.model.ref import ConanFileReference, PackageReference
from conans.util.files import load


class InstallSelectedPackagesTest(unittest.TestCase):

def setUp(self):
test_server = TestServer()
self.servers = {"default": test_server}
self.client = TestClient(servers=self.servers, users={"default":[("lasote", "mypass")]})
self.client = TestClient(servers=self.servers, users={"default": [("lasote", "mypass")]})
self.package_ids = self._upload_some_packages(self.client)
self.new_client = TestClient(servers=self.servers,
users={"default":[("lasote", "mypass")]})
self.new_client = TestClient(servers=self.servers,
users={"default": [("lasote", "mypass")]})

def install_all_test(self):
# Should retrieve the three packages
Expand All @@ -35,12 +36,60 @@ def install_some_reference_test(self):
packages = os.listdir(self.new_client.paths.packages(self.ref))
self.assertEquals(len(packages), 2)

def download_recipe_twice_test(self):
expected_conanfile_contents = self.files[CONANFILE]
self.new_client.run("install Hello0/0.1@lasote/stable --all")
got_conanfile = load(os.path.join(self.new_client.paths.export(self.ref), CONANFILE))
self.assertEquals(expected_conanfile_contents, got_conanfile)

self.new_client.run("install Hello0/0.1@lasote/stable --all")
got_conanfile = load(os.path.join(self.new_client.paths.export(self.ref), CONANFILE))
self.assertEquals(expected_conanfile_contents, got_conanfile)

self.new_client.run("install Hello0/0.1@lasote/stable --all")
got_conanfile = load(os.path.join(self.new_client.paths.export(self.ref), CONANFILE))
self.assertEquals(expected_conanfile_contents, got_conanfile)

def download_packages_twice_test(self):
expected_header_contents = self.files["helloHello0.h"]
package_folder = self.new_client.paths.package(PackageReference(self.ref, self.package_ids[0]))

self.new_client.run("install Hello0/0.1@lasote/stable --all")
got_header = load(os.path.join(package_folder, "include", "helloHello0.h"))
self.assertEquals(expected_header_contents, got_header)

self.new_client.run("install Hello0/0.1@lasote/stable --all")
got_header = load(os.path.join(package_folder, "include", "helloHello0.h"))
self.assertEquals(expected_header_contents, got_header)

self.new_client.run("install Hello0/0.1@lasote/stable --all")
got_header = load(os.path.join(package_folder, "include", "helloHello0.h"))
self.assertEquals(expected_header_contents, got_header)

def install_all_but_no_packages_test(self):

# Remove all from remote
self.new_client.run("remove Hello* -f -r default")

# Try to install all
self.new_client.run("install Hello0/0.1@lasote/stable --all", ignore_error=True)
self.assertIn("'Hello0/0.1@lasote/stable' not found in remote", self.new_client.user_io.out)

# Upload only the recipe
self.new_client.save(self.files)
self.new_client.run("export lasote/stable")
self.new_client.run("upload Hello0/0.1@lasote/stable --all")

# And try to download all
self.new_client.run("install Hello0/0.1@lasote/stable --all")
self.assertIn("No remote binary packages found in remote", self.new_client.user_io.out)

def _upload_some_packages(self, client):
self.ref = ConanFileReference.loads("Hello0/0.1@lasote/stable")
files = cpp_hello_conan_files("Hello0", "0.1")
self.files = cpp_hello_conan_files("Hello0", "0.1")
# No build.
files[CONANFILE] = files[CONANFILE].replace("def build(self):", "def build(self):\n return\n")
client.save(files)
self.files[CONANFILE] = self.files[CONANFILE].replace("def build(self):", "def build(self):\n return\n")
client.save(self.files)
client.run("export lasote/stable")
client.run("install Hello0/0.1@lasote/stable -s os=Windows --build missing")
client.run("install Hello0/0.1@lasote/stable -s os=Linux --build missing")
Expand Down
8 changes: 4 additions & 4 deletions conans/test/path_exists_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ def test_conanfile_not_found(self):

test_server = TestServer()
self.servers = {"default": test_server}
self.client = TestClient(servers=self.servers, users={"default":[("lasote", "mypass")]})
self.client = TestClient(servers=self.servers, users={"default": [("lasote", "mypass")]})

files = cpp_hello_conan_files("Hello0", "0.1")
files = cpp_hello_conan_files("Hello0", "0.1", build=False)

self.client.save(files)
self.client.run("export lasote/stable")
Expand All @@ -35,12 +35,12 @@ def test_conanfile_not_found(self):
self.client.run("upload Hello0/0.1@lasote/stable")

# Now with requirements.txt (bug in server)
self.client = TestClient(servers=self.servers, users={"default":[("lasote", "mypass")]})
self.client = TestClient(servers=self.servers, users={"default": [("lasote", "mypass")]})
self.client.save({"conanfile.txt": "[requires]\nHello0/0.1@lasote/stable\n[generators]\ntxt"})
self.client.run("install --build missing ")
build_info = load(os.path.join(self.client.current_folder, "conanbuildinfo.txt"))
self.assertIn("helloHello0", build_info)

self.client = TestClient(servers=self.servers, users={"default":[("lasote", "mypass")]})
self.client = TestClient(servers=self.servers, users={"default": [("lasote", "mypass")]})
self.client.save({"conanfile.txt": "[requires]\nhello0/0.1@lasote/stable\n[generators]\ntxt"})
self.assertRaises(Exception, self.client.run, "install")
Loading

0 comments on commit 8086384

Please sign in to comment.