Skip to content

Commit a9d8018

Browse files
committed
merged develop2
2 parents 1f05fb2 + 2830cb5 commit a9d8018

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1967
-1279
lines changed

.github/workflows/osx-tests.yml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,6 @@ jobs:
2020
with:
2121
python-version: '3.10'
2222

23-
- name: Cache pip packages
24-
id: cache-pip
25-
uses: actions/cache@v4
26-
with:
27-
path: ~/.cache/pip
28-
key: ${{ runner.os }}-pip-${{ hashFiles('conans/requirements*.txt') }}
29-
3023
- name: Install Python requirements
3124
run: |
3225
pip install --upgrade pip
@@ -133,12 +126,6 @@ jobs:
133126
- name: Checkout code
134127
uses: actions/checkout@v4
135128

136-
- name: Restore pip cache
137-
uses: actions/cache@v4
138-
with:
139-
path: ~/.cache/pip
140-
key: ${{ runner.os }}-pip-${{ hashFiles('conans/requirements*.txt') }}
141-
142129
- name: Restore tools cache
143130
uses: actions/cache@v4
144131
with:

conan/api/conan_api.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,3 @@ def settings_yml(self):
150150
@property
151151
def requester(self):
152152
return self._requester
153-

conan/api/input.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def request_boolean(self, msg, default_option=None):
7878
"""Request user to input a boolean"""
7979
ret = None
8080
while ret is None:
81-
if default_option is True:
81+
if default_option:
8282
s = self.request_string("%s (YES/no)" % msg)
8383
elif default_option is False:
8484
s = self.request_string("%s (NO/yes)" % msg)

conan/api/output.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,14 @@ def define_silence_warnings(cls, warnings):
124124
def set_warnings_as_errors(cls, value):
125125
cls._warnings_as_errors = value
126126

127+
@classmethod
128+
def get_output_level(cls):
129+
return cls._conan_output_level
130+
131+
@classmethod
132+
def set_output_level(cls, level):
133+
cls._conan_output_level = level
134+
127135
@classmethod
128136
def valid_log_levels(cls):
129137
return {"quiet": LEVEL_QUIET, # -vquiet 80
@@ -151,7 +159,7 @@ def define_log_level(cls, v):
151159
vals = "quiet, error, warning, notice, status, verbose, debug(v), trace(vv)"
152160
raise ConanException(f"Invalid argument '-v{v}'{msg}.\nAllowed values: {vals}")
153161
else:
154-
cls._conan_output_level = level
162+
cls.set_output_level(level)
155163

156164
@classmethod
157165
def level_allowed(cls, level):
@@ -270,13 +278,13 @@ def verbose(self, msg: str, fg: str = None, bg: str = None):
270278
self._write_message(msg, fg=fg, bg=bg)
271279
return self
272280

273-
def status(self, msg: str, fg: str = None, bg: str = None):
281+
def status(self, msg: str, fg: str = None, bg: str = None, newline: bool = True):
274282
""" Provides general information about the system or ongoing operations.
275283
276284
Info messages are basic and used to inform about common events,
277285
like the start or completion of processes, without implying specific problems or achievements."""
278286
if self._conan_output_level <= LEVEL_STATUS:
279-
self._write_message(msg, fg=fg, bg=bg)
287+
self._write_message(msg, fg=fg, bg=bg, newline=newline)
280288
return self
281289

282290
info = status

conan/api/subapi/audit.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ def get_provider(self, provider_name):
6868
)
6969

7070
raise ConanException(
71-
f"Provider '{provider_name}' not found. Please specify a valid provider name or add it using: "
72-
f"'conan audit provider add {provider_name} {add_arguments} --token=<token>'\n"
73-
f"{register_message}"
71+
f"Provider '{provider_name}' not found. Please specify a valid provider name or add "
72+
f"it using: 'conan audit provider add {provider_name} {add_arguments} "
73+
f"--token=<token>'\n{register_message}"
7474
)
7575

7676
provider_data = providers[provider_name]
@@ -82,9 +82,11 @@ def get_provider(self, provider_name):
8282
provider_data["token"] = env_token
8383
elif "token" in provider_data:
8484
try:
85-
provider_data["token"] = decode(base64.standard_b64decode(provider_data["token"]).decode(), CYPHER_KEY)
86-
except binascii.Error as e:
87-
raise ConanException(f"Invalid token format for provider '{provider_name}'. The token might be corrupt.")
85+
enc_token = base64.standard_b64decode(provider_data["token"]).decode()
86+
provider_data["token"] = decode(enc_token, CYPHER_KEY)
87+
except binascii.Error:
88+
raise ConanException(f"Invalid token format for provider '{provider_name}'. "
89+
f"The token might be corrupt.")
8890

8991
provider_cls = self._provider_cls.get(provider_data["type"])
9092

@@ -142,7 +144,8 @@ def auth_provider(self, provider, token):
142144
providers = _load_providers(self._providers_path)
143145

144146
assert provider.name in providers
145-
providers[provider.name]["token"] = base64.standard_b64encode(encode(token, CYPHER_KEY).encode()).decode()
147+
encode_token = encode(token, CYPHER_KEY).encode()
148+
providers[provider.name]["token"] = base64.standard_b64encode(encode_token).decode()
146149
setattr(provider, "token", token)
147150
_save_providers(self._providers_path, providers)
148151

conan/api/subapi/cache.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
from conan.api.output import ConanOutput
99
from conan.internal.api.uploader import compress_files
1010
from conan.internal.cache.cache import PkgCache
11-
from conan.internal.cache.conan_reference_layout import EXPORT_SRC_FOLDER, EXPORT_FOLDER, SRC_FOLDER, \
12-
METADATA, DOWNLOAD_EXPORT_FOLDER
11+
from conan.internal.cache.conan_reference_layout import (EXPORT_SRC_FOLDER, EXPORT_FOLDER,
12+
SRC_FOLDER, METADATA,
13+
DOWNLOAD_EXPORT_FOLDER)
1314
from conan.internal.cache.home_paths import HomePaths
1415
from conan.internal.cache.integrity_check import IntegrityChecker
1516
from conan.internal.rest.download_cache import DownloadCache
@@ -104,7 +105,8 @@ def clean(self, package_list, source=True, build=True, download=True, temp=True,
104105
if not os.path.exists(manifest) or not os.path.exists(info):
105106
rmdir(folder)
106107
if backup_sources:
107-
backup_files = self._conan_api.cache.get_backup_sources(package_list, exclude=False, only_upload=False)
108+
backup_files = self._conan_api.cache.get_backup_sources(package_list, exclude=False,
109+
only_upload=False)
108110
ConanOutput().verbose(f"Cleaning {len(backup_files)} backup sources")
109111
for f in backup_files:
110112
remove(f)
@@ -175,7 +177,8 @@ def save(self, package_list, tgz_path, no_source=False):
175177
pkglist_path = os.path.join(tempfile.gettempdir(), "pkglist.json")
176178
save(pkglist_path, serialized)
177179
tar_files["pkglist.json"] = pkglist_path
178-
compress_files(tar_files, os.path.basename(tgz_path), os.path.dirname(tgz_path), compresslevel, recursive=True)
180+
compress_files(tar_files, os.path.basename(tgz_path), os.path.dirname(tgz_path),
181+
compresslevel, recursive=True)
179182
remove(pkglist_path)
180183

181184
def restore(self, path):
@@ -260,7 +263,8 @@ def get_backup_sources(self, package_list=None, exclude=True, only_upload=True):
260263
download_cache_path = config.get("core.sources:download_cache")
261264
download_cache_path = download_cache_path or HomePaths(
262265
self._conan_api.cache_folder).default_sources_backup_folder
263-
excluded_urls = config.get("core.sources:exclude_urls", check_type=list, default=[]) if exclude else []
266+
excluded_urls = config.get("core.sources:exclude_urls",
267+
check_type=list, default=[]) if exclude else []
264268
download_cache = DownloadCache(download_cache_path)
265269
return download_cache.get_backup_sources_files(excluded_urls, package_list, only_upload)
266270

conan/api/subapi/graph.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ def load_root_test_conanfile(self, path, tested_reference, profile_host, profile
8888
return root_node
8989

9090
def _load_root_virtual_conanfile(self, profile_host, profile_build, requires, tool_requires,
91-
lockfile, remotes, update, check_updates=False, python_requires=None):
91+
lockfile, remotes, update, check_updates=False,
92+
python_requires=None):
9293
if not python_requires and not requires and not tool_requires:
9394
raise ConanException("Provide requires or tool_requires")
9495
app = ConanApp(self._conan_api)
@@ -164,8 +165,8 @@ def load_graph(self, root_node, profile_host, profile_build, lockfile=None, remo
164165
""" Compute the dependency graph, starting from a root package, evaluation the graph with
165166
the provided configuration in profile_build, and profile_host. The resulting graph is a
166167
graph of recipes, but packages are not computed yet (package_ids) will be empty in the
167-
result. The result might have errors, like version or configuration conflicts, but it is still
168-
possible to inspect it. Only trying to install such graph will fail
168+
result. The result might have errors, like version or configuration conflicts, but it is
169+
still possible to inspect it. Only trying to install such graph will fail
169170
170171
:param root_node: the starting point, an already initialized Node structure, as
171172
returned by the "load_root_node" api
@@ -189,8 +190,8 @@ def load_graph(self, root_node, profile_host, profile_build, lockfile=None, remo
189190
deps_graph = builder.load_graph(root_node, profile_host, profile_build, lockfile)
190191
return deps_graph
191192

192-
def analyze_binaries(self, graph, build_mode=None, remotes=None, update=None, lockfile=None,
193-
build_modes_test=None, tested_graph=None):
193+
def analyze_binaries(self, graph, build_mode=None, remotes=None, update=None,
194+
lockfile=None, build_modes_test=None, tested_graph=None):
194195
""" Given a dependency graph, will compute the package_ids of all recipes in the graph, and
195196
evaluate if they should be built from sources, downloaded from a remote server, of if the
196197
packages are already in the local Conan cache
@@ -199,8 +200,12 @@ def analyze_binaries(self, graph, build_mode=None, remotes=None, update=None, lo
199200
:param graph: a Conan dependency graph, as returned by "load_graph()"
200201
:param build_mode: TODO: Discuss if this should be a BuildMode object or list of arguments
201202
:param remotes: list of remotes
202-
:param update: (False by default), if Conan should look for newer versions or
203-
revisions for already existing recipes in the Conan cache
203+
:param update: (``False`` by default), if Conan should look for newer versions or
204+
revisions for already existing recipes in the Conan cache. It also accepts an array of
205+
reference patterns to limit the update to those references if any of the items match.
206+
Eg. ``False``, ``None`` or ``[]`` *means no update*,
207+
``True`` or ``["*"]`` *means update all*,
208+
and ``["pkgA/*", "pkgB/1.0@user/channel"]`` *means to update only specific packages*.
204209
:param build_modes_test: the --build-test argument
205210
:param tested_graph: In case of a "test_package", the graph being tested
206211
"""

conan/api/subapi/install.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ def install_sources(self, graph, remotes):
6060

6161
# TODO: Look for a better name
6262
def install_consumer(self, deps_graph, generators=None, source_folder=None, output_folder=None,
63-
deploy=False, deploy_package=None, deploy_folder=None, envs_generation=None):
63+
deploy=False, deploy_package=None, deploy_folder=None,
64+
envs_generation=None):
6465
""" Once a dependency graph has been installed, there are things to be done, like invoking
6566
generators for the root consumer.
6667
This is necessary for example for conanfile.txt/py, or for "conan install <ref> -g
@@ -101,5 +102,5 @@ def install_consumer(self, deps_graph, generators=None, source_folder=None, outp
101102
envs_generation=envs_generation)
102103

103104
def deploy(self, graph, deployer, deploy_package=None, deploy_folder=None):
104-
return do_deploys(self._conan_api.home_folder, graph, deployer, deploy_package=deploy_package,
105-
deploy_folder=deploy_folder)
105+
return do_deploys(self._conan_api.home_folder, graph, deployer,
106+
deploy_package=deploy_package, deploy_folder=deploy_folder)

conan/api/subapi/remotes.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ def disable(self, pattern):
5858
5959
:param pattern: single ``str`` or list of ``str``. If the pattern is an exact name without
6060
wildcards like "*" and no remote is found matching that exact name, it will raise an error.
61-
:return: the list of disabled :ref:`Remote <conan.api.model.Remote>` objects (even if they were already disabled)
61+
:return: the list of disabled :ref:`Remote <conan.api.model.Remote>` objects (even if they
62+
were already disabled)
6263
"""
6364
remotes = _load(self._remotes_file)
6465
disabled = _filter(remotes, pattern, only_enabled=False)
@@ -76,7 +77,8 @@ def enable(self, pattern):
7677
7778
:param pattern: single ``str`` or list of ``str``. If the pattern is an exact name without
7879
wildcards like "*" and no remote is found matching that exact name, it will raise an error.
79-
:return: the list of enabled :ref:`Remote <conan.api.model.Remote>` objects (even if they were already enabled)
80+
:return: the list of enabled :ref:`Remote <conan.api.model.Remote>` objects (even if they
81+
were already enabled)
8082
"""
8183
remotes = _load(self._remotes_file)
8284
enabled = _filter(remotes, pattern, only_enabled=False)
@@ -93,7 +95,8 @@ def get(self, remote_name):
9395
Obtain a :ref:`Remote <conan.api.model.Remote>` object
9496
9597
:param remote_name: the exact name of the remote to be returned
96-
:return: the :ref:`Remote <conan.api.model.Remote>` object, or raise an Exception if the remote does not exist.
98+
:return: the :ref:`Remote <conan.api.model.Remote>` object, or raise an Exception if the
99+
remote does not exist.
97100
"""
98101
remotes = _load(self._remotes_file)
99102
try:

conan/api/subapi/report.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ def _source(path_to_conanfile, reference):
7878
"dst_prefix": dst_prefix,
7979
}
8080

81+
8182
def _configure_source(conan_api, hook_manager, conanfile_path, ref, remotes):
8283
app = ConanApp(conan_api)
8384
conanfile = app.loader.load_consumer(conanfile_path, name=ref.name, version=str(ref.version),
@@ -100,6 +101,7 @@ def _configure_source(conan_api, hook_manager, conanfile_path, ref, remotes):
100101
conanfile.folders.set_base_recipe_metadata(recipe_layout.metadata())
101102
config_source(export_source_folder, conanfile, hook_manager)
102103

104+
103105
def _get_ref_from_cache_or_remote(conan_api, reference, enabled_remotes):
104106
ref = RecipeReference.loads(reference)
105107
full_ref, matching_remote = None, False

0 commit comments

Comments
 (0)