Ejemplo n.º 1
0
def run():
    conan_version = get_client_version()
    if conan_version < Version("1.18.0"):
        conan_api, client_cache, _ = Conan.factory()
    else:
        conan_api, _, _ = Conan.factory()
        conan_api.create_app()
        client_cache = conan_api.app.cache

    printer = Printer()

    remotes_manager = RemotesManager(conan_api, printer)
    remotes_manager.add_remotes_to_conan()
    default_username = os.getenv("CONAN_USERNAME")
    auth_manager = AuthManager(conan_api,
                               printer,
                               default_username=default_username)

    upload_retry = os.getenv("CPT_UPLOAD_RETRY")
    upload_only_recipe = os.getenv("CPT_UPLOAD_ONLY_RECIPE")
    upload_force = os.getenv("CPT_UPLOAD_FORCE")
    uploader = Uploader(conan_api, remotes_manager, auth_manager, printer,
                        upload_retry, upload_force)
    build_policy = unscape_env(os.getenv("CPT_BUILD_POLICY"))
    test_folder = unscape_env(os.getenv("CPT_TEST_FOLDER"))
    reference = ConanFileReference.loads(os.getenv("CONAN_REFERENCE"))

    profile_text = unscape_env(os.getenv("CPT_PROFILE"))
    abs_profile_path = save_profile_to_tmp(profile_text)
    base_profile_text = unscape_env(os.getenv("CPT_BASE_PROFILE"))
    config_url = unscape_env(os.getenv("CPT_CONFIG_URL"))
    config_args = unscape_env(os.getenv("CPT_CONFIG_ARGS"))
    upload_dependencies = unscape_env(os.getenv("CPT_UPLOAD_DEPENDENCIES"))
    update_dependencies = unscape_env(os.getenv("CPT_UPDATE_DEPENDENCIES"))
    conanfile = unscape_env(os.getenv("CPT_CONANFILE"))
    lockfile = unscape_env(os.getenv("CPT_LOCKFILE"))
    skip_recipe_export = unscape_env(os.getenv("CPT_SKIP_RECIPE_EXPORT"))
    if base_profile_text:
        base_profile_name = unscape_env(os.getenv("CPT_BASE_PROFILE_NAME"))
        tools.save(os.path.join(client_cache.profiles_path, base_profile_name),
                   base_profile_text)

    upload = os.getenv("CPT_UPLOAD_ENABLED")
    runner = CreateRunner(abs_profile_path,
                          reference,
                          conan_api,
                          uploader,
                          build_policy=build_policy,
                          printer=printer,
                          upload=upload,
                          upload_only_recipe=upload_only_recipe,
                          test_folder=test_folder,
                          config_url=config_url,
                          config_args=config_args,
                          upload_dependencies=upload_dependencies,
                          conanfile=conanfile,
                          skip_recipe_export=skip_recipe_export,
                          update_dependencies=update_dependencies,
                          lockfile=lockfile)
    runner.run()
Ejemplo n.º 2
0
 def _create_requesters(conan_user_home=temp_folder()):
     with environment_append({'CONAN_USER_HOME': conan_user_home}):
         conan_api, cache, _ = Conan.factory()
     requester = conan_api._requester
     mock_requester = MockRequesterGet()
     requester._requester = mock_requester
     return requester, mock_requester, cache
Ejemplo n.º 3
0
def deploy_release(packages, config):
    if global_config["upload"]:
        conan_api, client_cache, user_io = Conan.factory()
        conan_repo = {
            v['name']: v['conanuser']
            for v in config['dependencies']
        }

        for package in packages:
            reference = ConanFileReference.loads(package['reference'])
            if reference.name not in conan_repo:
                print("skip uploading due to missing remote: %s" %
                      str(reference))
                continue
            remote = conan_repo[reference.name]
            all_success = True
            for pid in package['package_ids']:
                try:
                    result = conan_api.upload(package['reference'],
                                              package=pid,
                                              confirm=True,
                                              remote_name=remote,
                                              policy="force-upload")
                except Exception as e:
                    print(e)
                    all_success = False
        return all_success
    else:
        print("Upload of binary artifacts is disabled")
        return True
Ejemplo n.º 4
0
def export_package(user, channel, name, package_repo_folder,
                   package_commit_rev):
    conan_api, client_cache, user_io = Conan.factory()

    try:
        _, project_reference = conan_api.info(package_repo_folder)
        version = project_reference.version
    except:
        raise ValueError("missing conan version for: %s" % name)

    conan_api.export(package_repo_folder,
                     name=name,
                     channel=channel,
                     version=version,
                     user=user)

    try:
        conan_file_loc = os.path.join(package_repo_folder, "conanfile.py")
        version = conan_api.inspect(conan_file_loc,
                                    attributes=['version'])['version']
    except ConanException as e:
        print("error retrieving version from package: %s" % str(e))

    return {
        "commit_rev": package_commit_rev,
        "package_repo_folder": package_repo_folder,
        "name": name,
        "version": version,
        "user": user,
        "channel": channel,
    }
Ejemplo n.º 5
0
def upload_package(name, version, user, channel, package_commit_rev, config):
    if global_config["upload"]:
        conan_api, client_cache, user_io = Conan.factory()
        conan_repo = {
            v['name']: v['conanuser']
            for v in config['dependencies']
        }

        ref = "%s/%s@%s/%s" % (name, version, user, channel)
        remote = conan_repo[name]
        if remote is not None:
            result = conan_api.upload(ref,
                                      confirm=True,
                                      remote_name=remote,
                                      policy="force-upload")
    else:
        print("Upload of packages sources is disabled: %s" % name)

    return {
        "commit_rev": package_commit_rev,
        "name": name,
        "version": version,
        "user": user,
        "channel": channel,
    }
Ejemplo n.º 6
0
def export_meta_package(meta_repo_folder, meta_commit_rev, config):
    name = config['meta_package']['name']
    version = config['meta_package']['version']
    user = config['meta_package']['user']
    channel = config['meta_package']['channel']
    conan_api, client_cache, user_io = Conan.factory()

    conan_api.export(meta_repo_folder,
                     name=name,
                     channel=channel,
                     version=version,
                     user=user)

    try:
        conan_file_loc = os.path.join(meta_repo_folder, "conanfile.py")
        version = conan_api.inspect(conan_file_loc,
                                    attributes=['version'])['version']
    except ConanException as e:
        print("error retrieving version from package: %s" % str(e))

    return {
        "commit_rev": meta_commit_rev,
        "meta_repo_folder": meta_repo_folder,
        "name": name,
        "version": version,
        "user": user,
        "channel": channel,
    }
Ejemplo n.º 7
0
    def _init_collaborators(self, user_io=None):

        output = TestBufferConanOutput()
        self.user_io = user_io or MockedUserIO(self.users, out=output)

        self.runner = TestRunner(output, runner=self.conan_runner)

        # Check if servers are real
        real_servers = False
        for server in self.servers.values():
            if isinstance(server, str):  # Just URI
                real_servers = True

        with tools.environment_append(self.client_cache.conan_config.env_vars):
            if real_servers:
                requester = requests.Session()
            else:
                if self.requester_class:
                    requester = self.requester_class(self.servers)
                else:
                    requester = TestRequester(self.servers)

            self.requester = ConanRequester(requester, self.client_cache,
                                            get_request_timeout())

            self.localdb, self.rest_api_client, self.remote_manager = Conan.instance_remote_manager(
                                                            self.requester, self.client_cache,
                                                            self.user_io, self.client_version,
                                                            self.min_server_compatible_version)
            set_global_instances(output, self.requester)
Ejemplo n.º 8
0
def run():
    # Get all from environ
    conan_api, client_cache, _ = Conan.factory()
    printer = Printer()
    if os.path.exists(client_cache.default_profile_path):
        os.remove(client_cache.default_profile_path)

    remotes_manager = RemotesManager(conan_api, printer)
    default_username = os.getenv("CONAN_USERNAME", None)
    auth_manager = AuthManager(conan_api, printer, default_username=default_username)

    uploader = Uploader(conan_api, remotes_manager, auth_manager, printer)
    args = os.getenv("CPT_ARGS", "")
    build_policy = unscape_env(os.getenv("CPT_BUILD_POLICY"))
    reference = ConanFileReference.loads(os.getenv("CONAN_REFERENCE"))

    profile_text = unscape_env(os.getenv("CPT_PROFILE"))
    abs_profile_path = save_profile_to_tmp(profile_text)
    base_profile_text = unscape_env(os.getenv("CPT_BASE_PROFILE"))
    if base_profile_text:
        base_profile_name = unscape_env(os.getenv("CPT_BASE_PROFILE_NAME"))
        tools.save(os.path.join(client_cache.profiles_path, base_profile_name),
                   base_profile_text)

    upload = os.getenv("CPT_UPLOAD_ENABLED", None)
    runner = CreateRunner(abs_profile_path, reference, conan_api, uploader,
                          args=args,
                          build_policy=build_policy, printer=printer, upload=upload)
    runner.run()
Ejemplo n.º 9
0
def _register_using_native_keyring(output, remote):
    conan, _, _ = Conan.factory()
    user_list = conan.users_list(remote.name)
    authenticated, user_name = _get_default_remote_user(user_list)
    if user_name is None:
        output.info(
            "Anonymous login for remote '{}'. Set a user with 'conan user' command."
            .format(str(remote.name)))
        return
    if authenticated:
        return  # Already authenticated

    _check_keyring_backend_availability()
    passwd = keyring.get_password(remote.name, user_name)
    if passwd is None:
        passwd = unicode(
            getpass.getpass("Password for {} at {}:".format(
                user_name, remote.name)), 'utf8')
    valid = False
    while not valid:
        try:
            conan.authenticate(user_name, passwd, remote.name)
            keyring.set_password(remote.name, user_name, passwd)
            valid = True
        except AuthenticationException:
            output.info(
                "Credentials are invalid. Please, type credentials for {}.".
                format(remote.name))
            user_name = raw_input("Username: "******"Password for {} at {}:".format(
                    user_name, remote.name)), 'utf8')
Ejemplo n.º 10
0
def run():
    # Get all from environ
    conan_api, client_cache, _ = Conan.factory()
    printer = Printer()

    remotes_manager = RemotesManager(conan_api, printer)
    remotes_manager.add_remotes_to_conan()
    default_username = os.getenv("CONAN_USERNAME")
    auth_manager = AuthManager(conan_api, printer, default_username=default_username)

    upload_retry = os.getenv("CPT_UPLOAD_RETRY")
    upload_only_recipe = os.getenv("CPT_UPLOAD_ONLY_RECIPE")
    uploader = Uploader(conan_api, remotes_manager, auth_manager, printer, upload_retry)
    build_policy = unscape_env(os.getenv("CPT_BUILD_POLICY"))
    test_folder = unscape_env(os.getenv("CPT_TEST_FOLDER"))
    reference = ConanFileReference.loads(os.getenv("CONAN_REFERENCE"))

    profile_text = unscape_env(os.getenv("CPT_PROFILE"))
    abs_profile_path = save_profile_to_tmp(profile_text)
    base_profile_text = unscape_env(os.getenv("CPT_BASE_PROFILE"))
    config_url = unscape_env(os.getenv("CPT_CONFIG_URL"))
    upload_dependencies = unscape_env(os.getenv("CPT_UPLOAD_DEPENDENCIES"))
    conanfile = unscape_env(os.getenv("CPT_CONANFILE"))
    if base_profile_text:
        base_profile_name = unscape_env(os.getenv("CPT_BASE_PROFILE_NAME"))
        tools.save(os.path.join(client_cache.profiles_path, base_profile_name),
                   base_profile_text)

    upload = os.getenv("CPT_UPLOAD_ENABLED")
    runner = CreateRunner(abs_profile_path, reference, conan_api, uploader,
                          build_policy=build_policy, printer=printer, upload=upload,
                          upload_only_recipe=upload_only_recipe,
                          test_folder=test_folder, config_url=config_url,
                          upload_dependencies=upload_dependencies, conanfile=conanfile)
    runner.run()
Ejemplo n.º 11
0
 def get_conan_api_v1(self):
     user_io = MockedUserIO(self.users)
     conan = Conan(cache_folder=self.cache_folder,
                   user_io=user_io,
                   http_requester=self._http_requester,
                   runner=self.runner)
     return conan
Ejemplo n.º 12
0
    def _init_collaborators(self, user_io=None):

        output = TestBufferConanOutput()
        self.user_io = user_io or MockedUserIO(self.users, out=output)

        self.runner = TestRunner(output, runner=self.conan_runner)

        # Check if servers are real
        real_servers = False
        for server in self.servers.values():
            if isinstance(server, str):  # Just URI
                real_servers = True

        with tools.environment_append(self.client_cache.conan_config.env_vars):
            if real_servers:
                requester = requests.Session()
            else:
                if self.requester_class:
                    requester = self.requester_class(self.servers)
                else:
                    requester = TestRequester(self.servers)

            self.requester = ConanRequester(requester, self.client_cache,
                                            get_request_timeout())

            self.plugin_manager = PluginManager(
                self.client_cache.plugins_path,
                get_env("CONAN_PLUGINS", list()), self.user_io.out)

            self.localdb, self.rest_api_client, self.remote_manager = Conan.instance_remote_manager(
                self.requester, self.client_cache, self.user_io,
                self.client_version, self.min_server_compatible_version,
                self.plugin_manager)
            set_global_instances(output, self.requester)
Ejemplo n.º 13
0
def get_patched_multipackager(tc, *args, **kwargs):
    tc.init_dynamic_vars()

    extra_init_kwargs = {}
    if Version(client_version) >= Version("1.11"):
        extra_init_kwargs.update({'requester': tc.requester})

    if Version(conan_version) < Version("1.12.0"):
        cache = tc.client_cache
    else:
        cache = tc.cache

    conan_api = Conan(cache, tc.user_io, tc.runner, tc.remote_manager, tc.hook_manager,
                      interactive=False, **extra_init_kwargs)

    class Printer(object):

        def __init__(self, tc):
            self.tc = tc

        def __call__(self, contents):
            if six.PY2:
                contents = unicode(contents)
            self.tc.user_io.out._buffer.write(contents)

    kwargs["out"] = Printer(tc)
    kwargs["conan_api"] = conan_api
    kwargs["cwd"] = tc.current_folder

    mp = ConanMultiPackager(*args, **kwargs)
    return mp
Ejemplo n.º 14
0
def get_patched_multipackager(tc, *args, **kwargs):
    client_version = get_client_version()
    extra_init_kwargs = {}
    if Version("1.11") < Version(client_version) < Version("1.18"):
        extra_init_kwargs.update({'requester': tc.requester})
    elif Version(client_version) >= Version("1.18"):
        extra_init_kwargs.update({'http_requester': tc.requester})

    if Version(client_version) < Version("1.12.0"):
        cache = tc.client_cache
    else:
        cache = tc.cache

    conan_api = Conan(cache_folder=cache.cache_folder,
                      output=tc.out,
                      **extra_init_kwargs)

    class Printer(object):
        def __init__(self, tc):
            self.tc = tc

        def __call__(self, contents):
            if six.PY2:
                contents = unicode(contents)
            self.tc.out.write(contents)

    kwargs["out"] = Printer(tc)
    kwargs["conan_api"] = conan_api
    kwargs["cwd"] = tc.current_folder

    mp = ConanMultiPackager(*args, **kwargs)
    return mp
Ejemplo n.º 15
0
    def _init_collaborators(self, user_io=None):

        output = TestBufferConanOutput()
        self.user_io = user_io or MockedUserIO(self.users, out=output)
        self.cache = ClientCache(self.base_folder, self.storage_folder, output)
        self.runner = TestRunner(output, runner=self.conan_runner)

        # Check if servers are real
        real_servers = False
        for server in self.servers.values():
            if isinstance(server, str) or isinstance(
                    server, ArtifactoryServer):  # Just URI
                real_servers = True
                break

        with tools.environment_append(self.cache.config.env_vars):
            if real_servers:
                requester = requests.Session()
            else:
                if self.requester_class:
                    requester = self.requester_class(self.servers)
                else:
                    requester = TestRequester(self.servers)

            self.requester = ConanRequester(requester, self.cache,
                                            get_request_timeout())

            self.hook_manager = HookManager(self.cache.hooks_path,
                                            get_env("CONAN_HOOKS", list()),
                                            self.user_io.out)

            self.localdb, self.rest_api_client, self.remote_manager = \
                Conan.instance_remote_manager(self.requester, self.cache,
                                              self.user_io, self.hook_manager)
            return output, self.requester
Ejemplo n.º 16
0
    def _init_collaborators(self, user_io=None):

        output = TestBufferConanOutput()
        self.user_io = user_io or MockedUserIO(self.users, out=output)

        self.runner = TestRunner(output, runner=self.conan_runner)

        # Check if servers are real
        real_servers = False
        for server in self.servers.values():
            if isinstance(server, str):  # Just URI
                real_servers = True

        if real_servers:
            requester = requests.Session()
        else:
            if self.requester_class:
                requester = self.requester_class(self.servers)
            else:
                requester = TestRequester(self.servers)

        self.requester = ConanRequester(requester, self.client_cache)

        self.localdb, self.rest_api_client, self.remote_manager = Conan.instance_remote_manager(
            self.requester, self.client_cache, self.user_io,
            self.client_version, self.min_server_compatible_version)

        set_global_instances(output, self.requester)
Ejemplo n.º 17
0
    def run(self, command_line, user_io=None, ignore_error=False):
        """ run a single command as in the command line.
            If user or password is filled, user_io will be mocked to return this
            tuple if required
        """
        self.init_dynamic_vars(user_io)
        conan = Conan(self.client_cache, self.user_io, self.runner,
                      self.remote_manager, self.search_manager)
        outputer = CommandOutputer(self.user_io, self.client_cache)
        command = Command(conan, self.client_cache, self.user_io, outputer)
        args = shlex.split(command_line)
        current_dir = os.getcwd()
        os.chdir(self.current_folder)

        old_modules = list(sys.modules.keys())
        try:
            error = command.run(args)
        finally:
            os.chdir(current_dir)
            # Reset sys.modules to its prev state. A .copy() DOES NOT WORK
            added_modules = set(sys.modules).difference(old_modules)
            for added in added_modules:
                sys.modules.pop(added, None)

        if not ignore_error and error:
            logger.error(self.user_io.out)
            raise Exception("Command failed:\n%s" % command_line)

        self.all_output += str(self.user_io.out)
        return error
Ejemplo n.º 18
0
 def get_conan_api_v1(self, user_io=None):
     if user_io:
         self.out = user_io.out
     else:
         self.out = TestBufferConanOutput()
     user_io = user_io or MockedUserIO(self.users, out=self.out)
     conan = Conan(cache_folder=self.cache_folder, output=self.out, user_io=user_io,
                   http_requester=self._http_requester, runner=self.runner)
     return conan
Ejemplo n.º 19
0
    def run(self,
            command_line,
            user_io=None,
            ignore_error=False,
            should_error=False):
        """ run a single command as in the command line.
            If user or password is filled, user_io will be mocked to return this
            tuple if required
        """
        output, requester = self.init_dynamic_vars(user_io)
        with tools.environment_append(self.client_cache.conan_config.env_vars):
            # Settings preprocessor
            interactive = not get_env("CONAN_NON_INTERACTIVE", False)
            conan = Conan(self.client_cache,
                          self.user_io,
                          self.runner,
                          self.remote_manager,
                          self.hook_manager,
                          interactive=interactive)
        outputer = CommandOutputer(self.user_io, self.client_cache)
        command = Command(conan, self.client_cache, self.user_io, outputer)
        args = shlex.split(command_line)
        current_dir = os.getcwd()
        os.chdir(self.current_folder)
        old_path = sys.path[:]
        sys.path.append(os.path.join(self.client_cache.conan_folder, "python"))
        old_modules = list(sys.modules.keys())

        old_output, old_requester = set_global_instances(output, requester)
        try:
            error = command.run(args)
        finally:
            set_global_instances(old_output, old_requester)
            sys.path = old_path
            os.chdir(current_dir)
            # Reset sys.modules to its prev state. A .copy() DOES NOT WORK
            added_modules = set(sys.modules).difference(old_modules)
            for added in added_modules:
                sys.modules.pop(added, None)

        if not ignore_error and error and not should_error:
            exc_message = "\n{command_header}\n{command}\n{output_header}\n{output}\n{output_footer}\n".format(
                command_header='{:-^80}'.format(" Command failed: "),
                output_header='{:-^80}'.format(" Output: "),
                output_footer='-' * 80,
                command=command_line,
                output=self.user_io.out)
            raise Exception(exc_message)

        if should_error and not error:
            raise Exception("This command should have failed: %s" %
                            command_line)

        self.all_output += str(self.user_io.out)
        return error
Ejemplo n.º 20
0
class ConanClient:
    USER = '******'

    @property
    def password(self):
        return f0cal.core.CORE.config["api"]["api_key"]
    @classmethod
    def set_conan_env(cls):
        if sys.prefix == sys.base_prefix:
            LOG.warning('NOT USING F0CAL INSIDE ENV, SETTING CONAN CACHE TO USER HOME DIR INSTEAD OF VENV')
            return
        os.environ["CONAN_USER_HOME"] = VENV_HOME
    def _initialize_conan(self):
        remotes = self.conan.remote_list()
        if CONAN_REMOTE_NAME not in {x.name for x in remotes}:
            api_url = f0cal.core.CORE.config["api"]["api_url"]
            conan_url = f'{api_url}{CONAN_PATH}'
            self.conan.remote_add(remote_name=CONAN_REMOTE_NAME, url=conan_url)
        self._authenticate(self.USER, self.PASSWORD, CONAN_REMOTE_NAME)
    def __init__(self, f0cal_base_url):
        self.set_conan_env()
        self.conan = Conan()
        self._initialize_conan()

    def _authenticate(self, username, password, remote_name):
        self.conan.authenticate(name=username, password=password, remote_name=remote_name)



    def image_pull(self, name):
        ref = ConanFileReference.loads(name)
        self.conan.install_reference(ref, remote_name=CONAN_REMOTE_NAME)

    def image_push(self, name):
        self.conan.upload(name, remote_name=CONAN_REMOTE_NAME, all_packages=True)
Ejemplo n.º 21
0
def run_conan(reference, reference_fallback):
    # New API in Conan 0.28
    c, _, _ = Conan.factory()

    print(reference)
    print(reference_fallback)

    try:
        # c.remote_add(remote, url, verify_ssl, args.insert)
        c.remote_add('bitprim',
                     'https://api.bintray.com/conan/bitprim/bitprim')
    except:
        print("Conan Remote exists, ignoring exception")

    try:
        # c.install(reference, verify=None, manifests=None)
        c.install(reference,
                  verify=None,
                  manifests_interactive=None,
                  manifests=None)
        print(
            '11 876128376128371263876128376128371263876128376128371263876128376128371263876128376128371263'
        )
        pepe = find('nodecint.h', os.getcwd())
        print(pepe)
        print(
            '11 876128376128371263876128376128371263876128376128371263876128376128371263876128376128371263'
        )

    except:
        print('EXCEPTION --------------------------')

        c.install(reference_fallback,
                  verify=None,
                  manifests_interactive=None,
                  manifests=None)
        print(
            '22 876128376128371263876128376128371263876128376128371263876128376128371263876128376128371263'
        )
        pepe = find('nodecint.h', os.getcwd())
        print(pepe)
        shutil.move('./deps/', '..')
        pepe = find('nodecint.h', os.getcwd())
        print(pepe)
        print(
            '22 876128376128371263876128376128371263876128376128371263876128376128371263876128376128371263'
        )

    print('run_conan - END')
    replace_boost_lib_names_on_windows('../deps/lib')
Ejemplo n.º 22
0
    def __init__(self,
                 profile_text,
                 username,
                 channel,
                 reference,
                 mingw_installer_reference=None,
                 runner=None,
                 args=None,
                 conan_pip_package=None,
                 exclude_vcvars_precommand=False,
                 conan_vars=None,
                 build_policy=None):

        self._conan_vars = conan_vars or {}
        self._profile_text = profile_text
        self._mingw_installer_reference = mingw_installer_reference
        self._args = args
        self._args += " --build=%s" % build_policy if build_policy else ""
        self._username = username
        self._channel = channel
        self._reference = reference
        self._conan_pip_package = conan_pip_package
        self._runner = runner or os.system
        self.runner = runner
        self.conan_api, self.client_cache, self.user_io = Conan.factory()
        self.conan_home = os.path.realpath(self.client_cache.conan_folder)
        self.data_home = os.path.realpath(self.client_cache.store)
        self._exclude_vcvars_precommand = exclude_vcvars_precommand

        if "default" in self._profile_text:  # User didn't specified a custom profile
            default_profile_name = os.path.basename(
                self.client_cache.default_profile_path)
            if not os.path.exists(self.client_cache.default_profile_path):
                self.conan_api.create_profile(default_profile_name,
                                              detect=True)

            if default_profile_name != "default":  # User have a different default profile name
                # https://github.com/conan-io/conan-package-tools/issues/121
                self._profile_text = self._profile_text.replace(
                    "include(default)", "include(%s)" % default_profile_name)

        # Save the profile in a tmp file
        tmp = os.path.join(
            tempfile.mkdtemp(suffix='conan_package_tools_profiles'), "profile")
        self.abs_profile_path = os.path.abspath(tmp)
        save(self.abs_profile_path, self._profile_text)

        self.profile, _ = _load_profile(self._profile_text,
                                        os.path.dirname(self.abs_profile_path),
                                        self.client_cache.profiles_path)
Ejemplo n.º 23
0
def main(args):
    """ main entry point of the conan application, using a Command to
    parse parameters
    """
    conan_api = Conan.factory()
    command = Command(conan_api, conan_api._client_cache, conan_api._user_io)
    current_dir = os.getcwd()
    try:
        import signal

        def sigint_handler(signal, frame):  # @UnusedVariable
            print('You pressed Ctrl+C!')
            sys.exit(0)

        signal.signal(signal.SIGINT, sigint_handler)
        error = command.run(args)
    finally:
        os.chdir(current_dir)
    sys.exit(error)
Ejemplo n.º 24
0
def do_conan_stuff(microarch=None, currency=None):

    # if not microarch:
    #     microarch = 'x86_64'

    print('do_conan_stuff microarch currency')
    print(microarch)

    # New API in Conan 0.28
    c, _, _ = Conan.factory()

    try:
        # c.remote_add(remote, url, verify_ssl, args.insert)
        c.remote_add('bitprim',
                     'https://api.bintray.com/conan/bitprim/bitprim')
    except:
        print("Conan Remote exists, ignoring exception")

    refe = "."

    opts = None

    # if microarch:
    #     # c.install(refe, verify=None, manifests=None)
    #     opts = ['*:microarchitecture=%s' % (microarch,)]
    #     c.install(refe, verify=None, manifests_interactive=None, manifests=None, options=opts)
    # else:
    #     c.install(refe, verify=None, manifests_interactive=None, manifests=None)

    if microarch:
        opts = ['*:microarchitecture=%s' % (microarch, )]

    if currency:
        if opts:
            opts.append('*:currency=%s' % (currency, ))
        else:
            opts = ['*:currency=%s' % (currency, )]

    c.install(refe,
              verify=None,
              manifests_interactive=None,
              manifests=None,
              options=opts)
Ejemplo n.º 25
0
def build_release(deps, build_folder, config):
    name = config['meta_package']['name']
    version = config['meta_package']['version']
    user = config['meta_package']['user']
    channel = config['meta_package']['channel']

    profile_name = global_config['profile_name']

    package_repo_folder = os.path.join(build_folder, "meta")

    deps_build_filter = global_config.get('deps_build_filter', '*')

    build_modes = [
        name,
    ] + [d for d in deps if fnmatch(d, deps_build_filter)]

    options = config.get('options', [])

    conan_api, client_cache, user_io = Conan.factory()

    kw = {
        "name": name,
        "version": version,
        "user": user,
        "channel": channel,
        "build_modes": build_modes,
        "options": options
    }
    kw["profile_names"] = [
        profile_name,
    ] if profile_name is not None else []

    result = conan_api.create(package_repo_folder, **kw)

    packages = []
    for info in result['installed']:
        packages.append({
            "reference": info['recipe']['id'],
            "timestamp": info['recipe']['time'].isoformat(),
            "package_ids": [p['id'] for p in info['packages']],
        })
    return {'packages': packages}
Ejemplo n.º 26
0
    def run(self, command_line, user_io=None, ignore_error=False):
        """ run a single command as in the command line.
            If user or password is filled, user_io will be mocked to return this
            tuple if required
        """
        self.init_dynamic_vars(user_io)
        with tools.environment_append(self.client_cache.conan_config.env_vars):
            # Settings preprocessor
            interactive = not get_env("CONAN_NON_INTERACTIVE", False)
            conan = Conan(self.client_cache,
                          self.user_io,
                          self.runner,
                          self.remote_manager,
                          self.search_manager,
                          settings_preprocessor,
                          interactive=interactive)
        outputer = CommandOutputer(self.user_io, self.client_cache)
        command = Command(conan, self.client_cache, self.user_io, outputer)
        args = shlex.split(command_line)
        current_dir = os.getcwd()
        os.chdir(self.current_folder)
        old_path = sys.path[:]
        sys.path.append(os.path.join(self.client_cache.conan_folder, "python"))
        old_modules = list(sys.modules.keys())
        try:
            error = command.run(args)
        finally:
            sys.path = old_path
            os.chdir(current_dir)
            # Reset sys.modules to its prev state. A .copy() DOES NOT WORK
            added_modules = set(sys.modules).difference(old_modules)
            for added in added_modules:
                sys.modules.pop(added, None)

        if not ignore_error and error:
            logger.error(self.user_io.out)
            print(self.user_io.out)
            raise Exception("Command failed:\n%s" % command_line)

        self.all_output += str(self.user_io.out)
        return error
Ejemplo n.º 27
0
def get_patched_multipackager(tc, *args, **kwargs):
    tc.init_dynamic_vars()
    conan_api = Conan(tc.client_cache,
                      tc.user_io,
                      tc.runner,
                      tc.remote_manager,
                      tc.hook_manager,
                      interactive=False)

    class Printer(object):
        def __init__(self, tc):
            self.tc = tc

        def __call__(self, contents):
            if six.PY2:
                contents = unicode(contents)
            self.tc.user_io.out._buffer.write(contents)

    kwargs["out"] = Printer(tc)
    kwargs["conan_api"] = conan_api
    kwargs["cwd"] = tc.current_folder

    mp = ConanMultiPackager(*args, **kwargs)
    return mp
Ejemplo n.º 28
0
    def __init__(self,
                 username=None,
                 channel=None,
                 runner=None,
                 gcc_versions=None,
                 visual_versions=None,
                 visual_runtimes=None,
                 visual_toolsets=None,
                 apple_clang_versions=None,
                 archs=None,
                 options=None,
                 use_docker=None,
                 curpage=None,
                 total_pages=None,
                 docker_image=None,
                 reference=None,
                 password=None,
                 remotes=None,
                 upload=None,
                 stable_branch_pattern=None,
                 vs10_x86_64_enabled=False,
                 mingw_configurations=None,
                 stable_channel=None,
                 platform_info=None,
                 upload_retry=None,
                 clang_versions=None,
                 login_username=None,
                 upload_only_when_stable=None,
                 upload_only_when_tag=None,
                 upload_only_recipe=None,
                 build_types=None,
                 cppstds=None,
                 skip_check_credentials=False,
                 allow_gcc_minors=False,
                 exclude_vcvars_precommand=False,
                 docker_run_options=None,
                 docker_image_skip_update=False,
                 docker_image_skip_pull=False,
                 docker_entry_script=None,
                 docker_32_images=None,
                 docker_conan_home=None,
                 docker_shell=None,
                 pip_install=None,
                 build_policy=None,
                 always_update_conan_in_docker=False,
                 conan_api=None,
                 client_cache=None,
                 conanfile=None,
                 ci_manager=None,
                 out=None,
                 test_folder=None,
                 cwd=None,
                 config_url=None,
                 config_args=None,
                 upload_dependencies=None,
                 force_selinux=None,
                 skip_recipe_export=False,
                 update_dependencies=None,
                 lockfile=None):

        conan_version = get_client_version()

        self.printer = Printer(out)
        self.printer.print_rule()
        self.printer.print_ascci_art()

        self.cwd = cwd or os.getcwd()

        if not conan_api:
            self.conan_api, _, _ = Conan.factory()
            self.conan_api.create_app()
            self.client_cache = self.conan_api.app.cache
        else:
            self.conan_api = conan_api
            self.client_cache = client_cache

        self.ci_manager = ci_manager or CIManager(self.printer)
        self.remotes_manager = RemotesManager(self.conan_api, self.printer,
                                              remotes, upload)
        self.username = username or os.getenv("CONAN_USERNAME", None)

        self.skip_check_credentials = skip_check_credentials or get_bool_from_env(
            "CONAN_SKIP_CHECK_CREDENTIALS")

        self.auth_manager = AuthManager(
            self.conan_api,
            self.printer,
            login_username,
            password,
            default_username=self.username,
            skip_check_credentials=self.skip_check_credentials)

        # Upload related variables
        self.upload_retry = upload_retry or os.getenv("CONAN_UPLOAD_RETRY", 3)

        if upload_only_when_stable is not None:
            self.upload_only_when_stable = upload_only_when_stable
        else:
            self.upload_only_when_stable = get_bool_from_env(
                "CONAN_UPLOAD_ONLY_WHEN_STABLE")

        if upload_only_when_tag is not None:
            self.upload_only_when_tag = upload_only_when_tag
        else:
            self.upload_only_when_tag = get_bool_from_env(
                "CONAN_UPLOAD_ONLY_WHEN_TAG")

        self.upload_only_recipe = upload_only_recipe or get_bool_from_env(
            "CONAN_UPLOAD_ONLY_RECIPE")

        self.remotes_manager.add_remotes_to_conan()
        self.uploader = Uploader(self.conan_api, self.remotes_manager,
                                 self.auth_manager, self.printer,
                                 self.upload_retry)

        self._builds = []
        self._named_builds = {}
        self._packages_summary = []

        self._update_conan_in_docker = always_update_conan_in_docker or get_bool_from_env(
            "CONAN_ALWAYS_UPDATE_CONAN_DOCKER")

        self._platform_info = platform_info or PlatformInfo()

        self.stable_branch_pattern = stable_branch_pattern or \
                                     os.getenv("CONAN_STABLE_BRANCH_PATTERN", None)

        self.stable_channel = stable_channel or os.getenv(
            "CONAN_STABLE_CHANNEL", "stable")
        self.stable_channel = self.stable_channel.rstrip()
        self.partial_reference = reference or os.getenv(
            "CONAN_REFERENCE", None)
        self.channel = self._get_specified_channel(channel, reference)
        self.conanfile = conanfile or os.getenv("CONAN_CONANFILE",
                                                "conanfile.py")

        if self.partial_reference:
            if "@" in self.partial_reference:
                self.reference = ConanFileReference.loads(
                    self.partial_reference)
            else:
                name, version = self.partial_reference.split("/")
                self.reference = ConanFileReference(name, version,
                                                    self.username,
                                                    self.channel)
        else:
            if not os.path.exists(os.path.join(self.cwd, self.conanfile)):
                raise Exception("Conanfile not found, specify a 'reference' "
                                "parameter with name and version")

            conanfile = load_cf_class(os.path.join(self.cwd, self.conanfile),
                                      self.conan_api)
            name, version = conanfile.name, conanfile.version
            if name and version:
                self.reference = ConanFileReference(name, version,
                                                    self.username,
                                                    self.channel)
            else:
                self.reference = None

        self._docker_image = docker_image or os.getenv("CONAN_DOCKER_IMAGE",
                                                       None)

        # If CONAN_DOCKER_IMAGE is specified, then use docker is True
        self.use_docker = (use_docker or os.getenv("CONAN_USE_DOCKER", False)
                           or self._docker_image is not None)

        self.docker_conan_home = docker_conan_home or os.getenv(
            "CONAN_DOCKER_HOME", None)

        os_name = self._platform_info.system(
        ) if not self.use_docker else "Linux"
        self.build_generator = BuildGenerator(
            reference, os_name, gcc_versions, apple_clang_versions,
            clang_versions, visual_versions, visual_runtimes, visual_toolsets,
            vs10_x86_64_enabled, mingw_configurations, archs, allow_gcc_minors,
            build_types, options, cppstds)

        self.build_policy = (build_policy
                             or self.ci_manager.get_commit_build_policy()
                             or split_colon_env("CONAN_BUILD_POLICY"))
        if isinstance(self.build_policy, list):
            self.build_policy = ",".join(self.build_policy)

        self.sudo_docker_command = ""
        if "CONAN_DOCKER_USE_SUDO" in os.environ:
            self.sudo_docker_command = "sudo -E" if get_bool_from_env(
                "CONAN_DOCKER_USE_SUDO") else ""
        elif platform.system() != "Windows":
            self.sudo_docker_command = "sudo -E"

        self.sudo_pip_command = ""
        if "CONAN_PIP_USE_SUDO" in os.environ:
            self.sudo_pip_command = "sudo -E" if get_bool_from_env(
                "CONAN_PIP_USE_SUDO") else ""
        elif platform.system(
        ) != "Windows" and self._docker_image and 'conanio/' not in str(
                self._docker_image):
            self.sudo_pip_command = "sudo -E"
        self.pip_command = os.getenv("CONAN_PIP_COMMAND", "pip")
        pip_found = True if tools.os_info.is_windows else tools.which(
            self.pip_command)
        if not pip_found or not "pip" in self.pip_command:
            raise Exception(
                "CONAN_PIP_COMMAND: '{}' is not a valid pip command.".format(
                    self.pip_command))
        self.docker_pip_command = os.getenv("CONAN_DOCKER_PIP_COMMAND", "pip")

        self.docker_shell = docker_shell or os.getenv("CONAN_DOCKER_SHELL")

        if self.is_wcow:
            if self.docker_conan_home is None:
                self.docker_conan_home = "C:/Users/ContainerAdministrator"
                self.docker_shell = docker_shell or "cmd /C"
        else:
            if self.docker_conan_home is None:
                self.docker_conan_home = "/home/conan"
                self.docker_shell = docker_shell or "/bin/sh -c"

        self.docker_platform_param = ""
        self.lcow_user_workaround = ""

        if self.is_lcow:
            self.docker_platform_param = "--platform=linux"
            # With LCOW, Docker doesn't respect USER directive in dockerfile yet
            self.lcow_user_workaround = "sudo su conan && "

        self.exclude_vcvars_precommand = exclude_vcvars_precommand or \
                                          get_bool_from_env("CONAN_EXCLUDE_VCVARS_PRECOMMAND")
        self._docker_image_skip_update = docker_image_skip_update or \
                                          get_bool_from_env("CONAN_DOCKER_IMAGE_SKIP_UPDATE")
        self._docker_image_skip_pull = docker_image_skip_pull or \
                                        get_bool_from_env("CONAN_DOCKER_IMAGE_SKIP_PULL")

        self.runner = runner or os.system
        self.output_runner = ConanOutputRunner()

        self.docker_run_options = docker_run_options or split_colon_env(
            "CONAN_DOCKER_RUN_OPTIONS")
        if isinstance(self.docker_run_options, list):
            self.docker_run_options = " ".join(self.docker_run_options)

        self.docker_entry_script = docker_entry_script or os.getenv(
            "CONAN_DOCKER_ENTRY_SCRIPT")

        self.pip_install = pip_install or split_colon_env("CONAN_PIP_INSTALL")

        self.upload_dependencies = upload_dependencies or split_colon_env(
            "CONAN_UPLOAD_DEPENDENCIES") or ""
        if isinstance(self.upload_dependencies, list):
            self.upload_dependencies = ",".join(self.upload_dependencies)
        if "all" in self.upload_dependencies and self.upload_dependencies != "all":
            raise Exception(
                "Upload dependencies only accepts or 'all' or package references. Do not mix both!"
            )

        self.update_dependencies = update_dependencies or get_bool_from_env(
            "CONAN_UPDATE_DEPENDENCIES")

        if self.channel:
            os.environ["CONAN_CHANNEL"] = self.channel

        if docker_32_images is not None:
            self.docker_32_images = docker_32_images
        else:
            self.docker_32_images = os.getenv("CONAN_DOCKER_32_IMAGES", False)

        self.force_selinux = force_selinux or get_bool_from_env(
            "CONAN_FORCE_SELINUX")
        self.curpage = curpage or os.getenv("CONAN_CURRENT_PAGE", 1)
        self.total_pages = total_pages or os.getenv("CONAN_TOTAL_PAGES", 1)

        self.conan_pip_package = os.getenv("CONAN_PIP_PACKAGE",
                                           "conan==%s" % conan_version)
        if self.conan_pip_package in ("0", "False"):
            self.conan_pip_package = ""
        self.vs10_x86_64_enabled = vs10_x86_64_enabled

        self.builds_in_current_page = []

        self.test_folder = test_folder or os.getenv("CPT_TEST_FOLDER")

        self.config_url = config_url or os.getenv("CONAN_CONFIG_URL")

        self.skip_recipe_export = skip_recipe_export or \
                                     get_bool_from_env("CONAN_SKIP_RECIPE_EXPORT")
        self.config_args = config_args or os.getenv("CONAN_CONFIG_ARGS")

        self.lockfile = lockfile or os.getenv("CONAN_LOCKFILE")

        def valid_pair(var, value):
            return (isinstance(value, six.string_types)
                    or isinstance(value, bool) or isinstance(value, list)
                    ) and not var.startswith("_") and "password" not in var

        with self.printer.foldable_output("local_vars"):
            self.printer.print_dict({
                var: value
                for var, value in self.__dict__.items()
                if valid_pair(var, value)
            })

        self._newest_supported_conan_version = Version(
            NEWEST_CONAN_SUPPORTED).minor(fill=False)
        self._client_conan_version = conan_version
Ejemplo n.º 29
0
from conans.client.conan_api import Conan
import platform
import os

conan_api, _, _ = Conan.factory()

conan_api.config_set("general.cmake_generator", "Xcode")
conan_api.update_profile("./profile/ios", "settings.os", "iOS")
conan_api.update_profile("./profile/ios", "settings.compiler", "apple-clang")
conan_api.update_profile("./profile/ios", "settings.compiler.version", "11.0")
conan_api.update_profile("./profile/ios", "settings.compiler.libcxx", "libc++")
conan_api.update_profile("./profile/ios", "settings.os.version", "9.0")
### just install pip every time?
CONAN_LOGIN_USERNAME = os.getenv('CONAN_LOGIN_USERNAME')
CONAN_PASSWORD = os.getenv('CONAN_PASSWORD')

conan_api.remote_add(
    "bintray", f"https://api.bintray.com/conan/{CONAN_LOGIN_USERNAME}/test")
conan_api.authenticate(CONAN_LOGIN_USERNAME, CONAN_PASSWORD, "bintray")

conan_api.export("./ios_recipe", "dlib", "19.21", CONAN_LOGIN_USERNAME,
                 "github_action")

conan_api.install("./build",
                  build=["outdated"],
                  profile_names=["./profile/ios"])
conan_api.upload("dlib",
                 all_packages=True,
                 confirm=True,
                 remote_name="bintray")
Ejemplo n.º 30
0
#             dest_file = os.path.join(self.install_dir, 'bitprim', filename)

#             log.info("dest_file: %s" % (dest_file, ))
#             log.debug("dest_file: %s" % (dest_file, ))
#             print("dest_file: %s" % (dest_file, ))

#             # file_util.copy_file(lib_file, bitprim_install_dir)
#             file_util.copy_file(lib_file, dest_file)

# class MyDist(Distribution):
#      def has_ext_modules(self):
#          return True

# ------------------------------------------------

c = Conan.factory()

try:
    # c.remote_add(remote, url, verify_ssl, args.insert)
    c.remote_add('bitprim', 'https://api.bintray.com/conan/bitprim/bitprim')
except:
    print("Conan Remote exists, ignoring exception")

refe = "."

# c.install(refe, verify=None, manifests=None)
c.install(refe, verify=None, manifests_interactive=None, manifests=None)

print(
    '-----------------------------------------------------------------------------------'
)
Ejemplo n.º 31
0
    def __init__(self,
                 args=None,
                 username=None,
                 channel=None,
                 runner=None,
                 gcc_versions=None,
                 visual_versions=None,
                 visual_runtimes=None,
                 apple_clang_versions=None,
                 archs=None,
                 use_docker=None,
                 curpage=None,
                 total_pages=None,
                 docker_image=None,
                 reference=None,
                 password=None,
                 remotes=None,
                 upload=None,
                 stable_branch_pattern=None,
                 vs10_x86_64_enabled=False,
                 mingw_configurations=None,
                 stable_channel=None,
                 platform_info=None,
                 upload_retry=None,
                 clang_versions=None,
                 login_username=None,
                 upload_only_when_stable=None,
                 build_types=None,
                 skip_check_credentials=False,
                 allow_gcc_minors=False,
                 exclude_vcvars_precommand=False,
                 docker_image_skip_update=False,
                 docker_image_skip_pull=False,
                 docker_entry_script=None,
                 docker_32_images=None,
                 build_policy=None,
                 always_update_conan_in_docker=False,
                 conan_api=None,
                 client_cache=None,
                 ci_manager=None,
                 out=None,
                 test_folder=None):

        self.printer = Printer(out)
        self.printer.print_rule()
        self.printer.print_ascci_art()

        if not conan_api:
            self.conan_api, self.client_cache, _ = Conan.factory()
        else:
            self.conan_api = conan_api
            self.client_cache = client_cache

        self.ci_manager = ci_manager or CIManager(self.printer)
        self.remotes_manager = RemotesManager(self.conan_api, self.printer,
                                              remotes, upload)
        self.username = username or os.getenv("CONAN_USERNAME", None)

        if not self.username:
            raise Exception(
                "Instance ConanMultiPackage with 'username' parameter or use "
                "CONAN_USERNAME env variable")
        self.skip_check_credentials = skip_check_credentials or \
                                      os.getenv("CONAN_SKIP_CHECK_CREDENTIALS", False)

        self.auth_manager = AuthManager(
            self.conan_api,
            self.printer,
            login_username,
            password,
            default_username=self.username,
            skip_check_credentials=self.skip_check_credentials)
        self.uploader = Uploader(self.conan_api, self.remotes_manager,
                                 self.auth_manager, self.printer)

        self._builds = []
        self._named_builds = {}

        self._update_conan_in_docker = (
            always_update_conan_in_docker
            or os.getenv("CONAN_ALWAYS_UPDATE_CONAN_DOCKER", False))

        self._platform_info = platform_info or PlatformInfo()

        self.stable_branch_pattern = stable_branch_pattern or \
                                     os.getenv("CONAN_STABLE_BRANCH_PATTERN", None)
        self.specified_channel = channel or os.getenv("CONAN_CHANNEL",
                                                      "testing")
        self.specified_channel = self.specified_channel.rstrip()
        self.stable_channel = stable_channel or os.getenv(
            "CONAN_STABLE_CHANNEL", "stable")
        self.stable_channel = self.stable_channel.rstrip()
        self.channel = self._get_channel(self.specified_channel,
                                         self.stable_channel)
        self.partial_reference = reference or os.getenv(
            "CONAN_REFERENCE", None)

        if self.partial_reference:
            if "@" in self.partial_reference:
                self.reference = ConanFileReference.loads(
                    self.partial_reference)
            else:
                name, version = self.partial_reference.split("/")
                self.reference = ConanFileReference(name, version,
                                                    self.username,
                                                    self.channel)
        else:
            if not os.path.exists("conanfile.py"):
                raise Exception(
                    "Conanfile not found, specify a 'reference' parameter with name and version"
                )
            conanfile = load_conanfile_class("./conanfile.py")
            name, version = conanfile.name, conanfile.version
            if name and version:
                self.reference = ConanFileReference(name, version,
                                                    self.username,
                                                    self.channel)
            else:
                self.reference = None

        # If CONAN_DOCKER_IMAGE is speified, then use docker is True
        self.use_docker = (use_docker or os.getenv("CONAN_USE_DOCKER", False)
                           or os.getenv("CONAN_DOCKER_IMAGE",
                                        None) is not None)

        os_name = self._platform_info.system(
        ) if not self.use_docker else "Linux"
        self.build_generator = BuildGenerator(
            reference, os_name, gcc_versions, apple_clang_versions,
            clang_versions, visual_versions, visual_runtimes,
            vs10_x86_64_enabled, mingw_configurations, archs, allow_gcc_minors,
            build_types)

        build_policy = (build_policy
                        or self.ci_manager.get_commit_build_policy()
                        or os.getenv("CONAN_BUILD_POLICY", None))

        if build_policy:
            if build_policy.lower() not in ("never", "outdated", "missing"):
                raise Exception(
                    "Invalid build policy, valid values: never, outdated, missing"
                )

        self.build_policy = build_policy

        self.sudo_docker_command = ""
        if "CONAN_DOCKER_USE_SUDO" in os.environ:
            self.sudo_docker_command = "sudo -E" if get_bool_from_env(
                "CONAN_DOCKER_USE_SUDO") else ""
        elif platform.system() != "Windows":
            self.sudo_docker_command = "sudo -E"

        self.sudo_pip_command = ""
        if "CONAN_PIP_USE_SUDO" in os.environ:
            self.sudo_pip_command = "sudo -E" if get_bool_from_env(
                "CONAN_PIP_USE_SUDO") else ""
        elif platform.system() != "Windows":
            self.sudo_pip_command = "sudo -E"

        self.docker_shell = ""
        self.docker_conan_home = ""

        if self.is_wcow:
            self.docker_conan_home = "C:/Users/ContainerAdministrator"
            self.docker_shell = "cmd /C"
        else:
            self.docker_conan_home = "/home/conan"
            self.docker_shell = "/bin/sh -c"

        self.docker_platform_param = ""
        self.lcow_user_workaround = ""

        if self.is_lcow:
            self.docker_platform_param = "--platform=linux"
            # With LCOW, Docker doesn't respect USER directive in dockerfile yet
            self.lcow_user_workaround = "sudo su conan && "

        self.exclude_vcvars_precommand = (
            exclude_vcvars_precommand
            or os.getenv("CONAN_EXCLUDE_VCVARS_PRECOMMAND", False))
        self._docker_image_skip_update = (
            docker_image_skip_update
            or os.getenv("CONAN_DOCKER_IMAGE_SKIP_UPDATE", False))
        self._docker_image_skip_pull = (docker_image_skip_pull or os.getenv(
            "CONAN_DOCKER_IMAGE_SKIP_PULL", False))

        self.runner = runner or os.system
        self.output_runner = ConanOutputRunner()
        self.args = " ".join(args) if args else " ".join(sys.argv[1:])

        # Upload related variables
        self.upload_retry = upload_retry or os.getenv("CONAN_UPLOAD_RETRY", 3)

        if upload_only_when_stable is not None:
            self.upload_only_when_stable = upload_only_when_stable
        else:
            self.upload_only_when_stable = get_bool_from_env(
                "CONAN_UPLOAD_ONLY_WHEN_STABLE")

        self.docker_entry_script = docker_entry_script or os.getenv(
            "CONAN_DOCKER_ENTRY_SCRIPT")

        os.environ["CONAN_CHANNEL"] = self.channel

        # If CONAN_DOCKER_IMAGE is speified, then use docker is True
        self.use_docker = use_docker or os.getenv("CONAN_USE_DOCKER", False) or \
                          (os.getenv("CONAN_DOCKER_IMAGE", None) is not None)

        if docker_32_images is not None:
            self.docker_32_images = docker_32_images
        else:
            self.docker_32_images = os.getenv("CONAN_DOCKER_32_IMAGES", False)

        self.curpage = curpage or os.getenv("CONAN_CURRENT_PAGE", 1)
        self.total_pages = total_pages or os.getenv("CONAN_TOTAL_PAGES", 1)
        self._docker_image = docker_image or os.getenv("CONAN_DOCKER_IMAGE",
                                                       None)

        self.conan_pip_package = os.getenv("CONAN_PIP_PACKAGE",
                                           "conan==%s" % client_version)
        if self.conan_pip_package in ("0", "False"):
            self.conan_pip_package = False
        self.vs10_x86_64_enabled = vs10_x86_64_enabled

        self.builds_in_current_page = []

        self.test_folder = test_folder or os.getenv("CPT_TEST_FOLDER", None)

        def valid_pair(var, value):
            return (isinstance(value, six.string_types)
                    or isinstance(value, bool) or isinstance(value, list)
                    ) and not var.startswith("_") and "password" not in var

        with self.printer.foldable_output("local_vars"):
            self.printer.print_dict({
                var: value
                for var, value in self.__dict__.items()
                if valid_pair(var, value)
            })