Skip to content

Commit

Permalink
Merge branch 'release/0.29.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
lasote committed Nov 23, 2017
2 parents 1315c41 + a612794 commit 4f92f62
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 73 deletions.
3 changes: 2 additions & 1 deletion conans/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@
COMPLEX_SEARCH_CAPABILITY = "complex_search"
SERVER_CAPABILITIES = [COMPLEX_SEARCH_CAPABILITY, ]

__version__ = '0.29.0'
__version__ = '0.29.1'

68 changes: 43 additions & 25 deletions conans/client/migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
import shutil

from conans.client.client_cache import CONAN_CONF, PROFILES_FOLDER
from conans.errors import ConanException
from conans.migrations import Migrator, CONAN_VERSION
from conans.migrations import Migrator
from conans.paths import EXPORT_SOURCES_DIR_OLD
from conans.util.files import load, save
from conans.util.files import load, save, list_folder_subdirs
from conans.model.version import Version
from conans.errors import ConanException


class ClientMigrator(Migrator):
Expand Down Expand Up @@ -41,8 +41,8 @@ def _make_migrations(self, old_version):
# VERSION 0.1
if old_version is None:
return

if old_version < Version("0.25"):
if old_version < Version("0.29.1"):
_migrate_lock_files(self.client_cache, self.out)
old_settings = """
os:
Windows:
Expand All @@ -51,46 +51,40 @@ def _make_migrations(self, old_version):
Android:
api_level: ANY
iOS:
version: ["7.0", "7.1", "8.0", "8.1", "8.2", "8.3", "9.0", "9.1", "9.2", "9.3", "10.0", "10.1", "10.2", "10.3"]
version: ["7.0", "7.1", "8.0", "8.1", "8.2", "8.3", "9.0", "9.1", "9.2", "9.3", "10.0", "10.1", "10.2", "10.3", "11.0"]
watchOS:
version: ["4.0"]
tvOS:
version: ["11.0"]
FreeBSD:
SunOS:
arch: [x86, x86_64, ppc64le, ppc64, armv6, armv7, armv7hf, armv8, sparc, sparcv9, mips, mips64]
Arduino:
board: ANY
arch: [x86, x86_64, ppc64le, ppc64, armv6, armv7, armv7hf, armv8, sparc, sparcv9, mips, mips64, avr, armv7s, armv7k]
compiler:
sun-cc:
version: ["5.10", "5.11", "5.12", "5.13", "5.14"]
threads: [None, posix]
libcxx: [libCstd, libstdcxx, libstlport, libstdc++]
version: ["5.10", "5.11", "5.12", "5.13", "5.14"]
threads: [None, posix]
libcxx: [libCstd, libstdcxx, libstlport, libstdc++]
gcc:
version: ["4.1", "4.4", "4.5", "4.6", "4.7", "4.8", "4.9", "5.1", "5.2", "5.3", "5.4", "6.1", "6.2", "6.3", "7.1"]
version: ["4.1", "4.4", "4.5", "4.6", "4.7", "4.8", "4.9", "5.1", "5.2", "5.3", "5.4", "6.1", "6.2", "6.3", "6.4", "7.1", "7.2"]
libcxx: [libstdc++, libstdc++11]
threads: [None, posix, win32] # Windows MinGW
exception: [None, dwarf2, sjlj, seh] # Windows MinGW
Visual Studio:
runtime: [MD, MT, MTd, MDd]
version: ["8", "9", "10", "11", "12", "14", "15"]
clang:
version: ["3.3", "3.4", "3.5", "3.6", "3.7", "3.8", "3.9", "4.0"]
version: ["3.3", "3.4", "3.5", "3.6", "3.7", "3.8", "3.9", "4.0", "5.0"]
libcxx: [libstdc++, libstdc++11, libc++]
apple-clang:
version: ["5.0", "5.1", "6.0", "6.1", "7.0", "7.3", "8.0", "8.1"]
version: ["5.0", "5.1", "6.0", "6.1", "7.0", "7.3", "8.0", "8.1", "9.0"]
libcxx: [libstdc++, libc++]
build_type: [None, Debug, Release]
"""
self._update_settings_yml(old_settings)

if old_version < Version("0.20"):
conf_path = os.path.join(self.client_cache.conan_folder, CONAN_CONF)
if conf_path:
backup_path = conf_path + ".backup"
save(backup_path, load(conf_path))
os.unlink(conf_path)
os.unlink(os.path.join(self.client_cache.conan_folder, CONAN_VERSION))
self.out.warn("*" * 40)
self.out.warn("Migration: Your Conan version was too old.")
self.out.warn("Your old conan.conf file has been backup'd to: %s" % backup_path)
self.out.warn("*" * 40)

if old_version < Version("0.25"):
from conans.paths import DEFAULT_PROFILE_NAME
default_profile_path = os.path.join(self.client_cache.conan_folder, PROFILES_FOLDER,
Expand All @@ -106,6 +100,30 @@ def _make_migrations(self, old_version):
migrate_c_src_export_source(self.client_cache, self.out)


def _migrate_lock_files(client_cache, out):
out.warn("Migration: Removing old lock files")
base_dir = client_cache.store
pkgs = list_folder_subdirs(base_dir, 4)
for pkg in pkgs:
out.info("Removing locks for %s" % pkg)
try:
count = os.path.join(base_dir, pkg, "rw.count")
if os.path.exists(count):
os.remove(count)
count = os.path.join(base_dir, pkg, "rw.count.lock")
if os.path.exists(count):
os.remove(count)
locks = os.path.join(base_dir, pkg, "locks")
if os.path.exists(locks):
shutil.rmtree(locks)
except Exception as e:
raise ConanException("Something went wrong while removing %s locks\n"
"Error: %s\n"
"Please clean your local conan cache manually"
% (pkg, str(e)))
out.warn("Migration: Removing old lock files finished\n")


def migrate_to_default_profile(conf_path, default_profile_path):
tag = "[settings_defaults]"
old_conf = load(conf_path)
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 @@ -179,6 +179,8 @@ def get_win_version_name(version):
def get_osx_version_name(version):
if not version:
return None
elif version.minor() == "10.13.Z":
return "High Sierra"
elif version.minor() == "10.12.Z":
return "Sierra"
elif version.minor() == "10.11.Z":
Expand Down
1 change: 0 additions & 1 deletion conans/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ distro>=1.0.2, <1.1.0
pylint>=1.6.5, <=1.8.0
future==0.16.0
pygments>=2.0, <3.0
psutil>=5.4.1
11 changes: 9 additions & 2 deletions conans/server/conf/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
"""
Server's configuration variables
"""
import six

from conans import tools
from conans.util.env_reader import get_env
from datetime import timedelta
import os
Expand Down Expand Up @@ -58,7 +60,11 @@ def _get_file_conf(self, section, varname=None):

if not self._loaded:
self._loaded = True
self.read(self.config_filename)
# To avoid encoding problems we use our tools.load
if six.PY3:
self.read_string(tools.load(self.config_filename))
else:
self.read(self.config_filename)

if varname:
section = dict(self.items(section))
Expand Down Expand Up @@ -150,7 +156,8 @@ def validate_pass_encoding(password):
try:
password.encode('ascii')
except (UnicodeDecodeError, UnicodeEncodeError):
raise ConanException("Password contains invalid characters. Only ASCII encoding is supported")
raise ConanException("Password contains invalid characters. "
"Only ASCII encoding is supported")
return password

if self.env_config["users"]:
Expand Down
16 changes: 7 additions & 9 deletions conans/test/util/tools_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,13 @@ def test_replace_in_file(self):
replace_in_file(self.win_file, "nis", "nus")
replace_in_file(self.bytes_file, "nis", "nus")

with open(self.win_file, "rt") as handler:
content = handler.read()
self.assertNotIn("nis", content)
self.assertIn("nus", content)

with open(self.bytes_file, "rt") as handler:
content = handler.read()
self.assertNotIn("nis", content)
self.assertIn("nus", content)
content = tools.load(self.win_file)
self.assertNotIn("nis", content)
self.assertIn("nus", content)

content = tools.load(self.bytes_file)
self.assertNotIn("nis", content)
self.assertIn("nus", content)


class ToolsTest(unittest.TestCase):
Expand Down
47 changes: 12 additions & 35 deletions conans/util/locks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
from conans.util.log import logger
import time
from conans.util.files import save, load
import psutil
import os


class NoLock(object):
Expand Down Expand Up @@ -48,64 +46,43 @@ def _info_locked(self):
self._output.info("If not the case, quit, and do 'conan remove %s -f'"
% str(self._locked_item))

def _pids(self):
def _readers(self):
try:
contents = load(self._count_file)
return int(load(self._count_file))
except IOError:
return []
else:
if not contents:
return []
pids = [int(i) for i in contents.split(',')]
valid_pids = []
for pid in pids:
if not psutil.pid_exists(abs(pid)):
lock_type = "write" if pid < 0 else "read"
self._output.info("invalidate %s lock from PID %s" % (lock_type, abs(pid)))
else:
valid_pids.append(pid)
return valid_pids
return 0


class ReadLock(Lock):

def _save_pids(self, pids):
save(self._count_file, ','.join(str(pid) for pid in pids))

def __enter__(self):
while True:
with fasteners.InterProcessLock(self._count_lock_file, logger=logger):
pids = self._pids()
if len(pids) >= 0:
pids.append(os.getpid())
save(self._count_file, ','.join(str(pid) for pid in pids))
readers = self._readers()
if readers >= 0:
save(self._count_file, str(readers + 1))
break
self._info_locked()
time.sleep(READ_BUSY_DELAY)

def __exit__(self, exc_type, exc_val, exc_tb): # @UnusedVariable
with fasteners.InterProcessLock(self._count_lock_file, logger=logger):
pids = self._pids()
try:
pids.remove(os.getpid())
except ValueError:
# legal situation - conan may remove directory with lock file during write
pass
self._save_pids(pids)
readers = self._readers()
save(self._count_file, str(readers - 1))


class WriteLock(Lock):

def __enter__(self):
while True:
with fasteners.InterProcessLock(self._count_lock_file, logger=logger):
pids = self._pids()
if not pids:
save(self._count_file, "-%s" % os.getpid())
readers = self._readers()
if readers == 0:
save(self._count_file, "-1")
break
self._info_locked()
time.sleep(WRITE_BUSY_DELAY)

def __exit__(self, exc_type, exc_val, exc_tb): # @UnusedVariable
with fasteners.InterProcessLock(self._count_lock_file, logger=logger):
save(self._count_file, "")
save(self._count_file, "0")

0 comments on commit 4f92f62

Please sign in to comment.