Skip to content

Commit

Permalink
Merge branch 'develop2' into feature/lock_upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
perseoGI authored Jan 15, 2025
2 parents b9fade5 + 13d4c3d commit c3936d7
Show file tree
Hide file tree
Showing 223 changed files with 490 additions and 479 deletions.
6 changes: 3 additions & 3 deletions conan/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from conans.model.conan_file import ConanFile
from conan.tools.scm import Version as _Version
from conan.internal.model.conan_file import ConanFile
from conan.internal.model.version import Version

__version__ = '2.12.0-dev'
conan_version = _Version(__version__)
conan_version = Version(__version__)
8 changes: 4 additions & 4 deletions conan/api/conan_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from conans.client.migrations import ClientMigrator
from conan.errors import ConanException
from conan.internal.paths import get_conan_user_home
from conans.model.version_range import validate_conan_version
from conan.internal.model.version_range import validate_conan_version


class ConanAPI:
Expand All @@ -41,9 +41,10 @@ def __init__(self, cache_folder=None):
migrator = ClientMigrator(self.cache_folder, conan_version)
migrator.migrate()

self.command = CommandAPI(self)
self.config = ConfigAPI(self)
self.remotes = RemotesAPI(self)
# Search recipes by wildcard and packages filtering by configuracion
self.command = CommandAPI(self)
# Search recipes by wildcard and packages filtering by configuration
self.search = SearchAPI(self)
# Get latest refs and list refs of recipes and packages
self.list = ListAPI(self)
Expand All @@ -52,7 +53,6 @@ def __init__(self, cache_folder=None):
self.graph = GraphAPI(self)
self.export = ExportAPI(self)
self.remove = RemoveAPI(self)
self.config = ConfigAPI(self)
self.new = NewAPI(self)
self.upload = UploadAPI(self)
self.download = DownloadAPI(self)
Expand Down
6 changes: 3 additions & 3 deletions conan/api/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
RECIPE_VIRTUAL, BINARY_SKIP, BINARY_MISSING, BINARY_INVALID
from conan.internal.errors import NotFoundException
from conan.errors import ConanException
from conans.model.package_ref import PkgReference
from conans.model.recipe_ref import RecipeReference
from conan.internal.model.package_ref import PkgReference
from conan.internal.model.recipe_ref import RecipeReference
from conans.util.files import load
from conans.model.version_range import VersionRange
from conan.internal.model.version_range import VersionRange

LOCAL_RECIPES_INDEX = "local-recipes-index"

Expand Down
4 changes: 2 additions & 2 deletions conan/api/subapi/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
from conan.internal.cache.integrity_check import IntegrityChecker
from conans.client.downloaders.download_cache import DownloadCache
from conan.errors import ConanException
from conans.model.package_ref import PkgReference
from conans.model.recipe_ref import RecipeReference
from conan.internal.model.package_ref import PkgReference
from conan.internal.model.recipe_ref import RecipeReference
from conans.util.dates import revision_timestamp_now
from conans.util.files import rmdir, gzopen_without_timestamps, mkdir, remove

Expand Down
17 changes: 10 additions & 7 deletions conan/api/subapi/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
from conans.client.graph.graph_builder import DepsGraphBuilder
from conans.client.graph.profile_node_definer import consumer_definer
from conan.errors import ConanException
from conans.model.conf import ConfDefinition, BUILT_IN_CONFS
from conans.model.pkg_type import PackageType
from conans.model.recipe_ref import RecipeReference
from conans.model.settings import Settings
from conan.internal.model.conf import ConfDefinition, BUILT_IN_CONFS
from conan.internal.model.pkg_type import PackageType
from conan.internal.model.recipe_ref import RecipeReference
from conan.internal.model.settings import Settings
from conans.util.files import load, save


Expand All @@ -36,8 +36,9 @@ def install(self, path_or_url, verify_ssl, config_type=None, args=None,
source_folder=None, target_folder=None):
# TODO: We probably want to split this into git-folder-http cases?
from conan.internal.api.config.config_installer import configuration_install
app = ConanApp(self.conan_api)
configuration_install(app, path_or_url, verify_ssl, config_type=config_type, args=args,
cache_folder = self.conan_api.cache_folder
requester = self.conan_api.remotes.requester
configuration_install(cache_folder, requester, path_or_url, verify_ssl, config_type=config_type, args=args,
source_folder=source_folder, target_folder=target_folder)

def install_pkg(self, ref, lockfile=None, force=False, remotes=None, profile=None):
Expand Down Expand Up @@ -90,7 +91,9 @@ def install_pkg(self, ref, lockfile=None, force=False, remotes=None, profile=Non
return pkg.pref # Already installed, we can skip repeating the install

from conan.internal.api.config.config_installer import configuration_install
configuration_install(app, uri=pkg.conanfile.package_folder, verify_ssl=False,
cache_folder = self.conan_api.cache_folder
requester = self.conan_api.remotes.requester
configuration_install(cache_folder, requester, uri=pkg.conanfile.package_folder, verify_ssl=False,
config_type="dir", ignore=["conaninfo.txt", "conanmanifest.txt"])
# We save the current package full reference in the file for future
# And for ``package_id`` computation
Expand Down
4 changes: 2 additions & 2 deletions conan/api/subapi/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from conan.api.output import ConanOutput
from conan.internal.conan_app import ConanBasicApp
from conan.errors import ConanException
from conans.model.package_ref import PkgReference
from conans.model.recipe_ref import RecipeReference
from conan.internal.model.package_ref import PkgReference
from conan.internal.model.recipe_ref import RecipeReference


class DownloadAPI:
Expand Down
2 changes: 1 addition & 1 deletion conan/api/subapi/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from conan.internal.methods import run_package_method
from conans.client.graph.graph import BINARY_BUILD, RECIPE_INCACHE
from conans.client.hook_manager import HookManager
from conans.model.package_ref import PkgReference
from conan.internal.model.package_ref import PkgReference
from conans.util.files import mkdir


Expand Down
6 changes: 3 additions & 3 deletions conan/api/subapi/graph.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from conan.api.output import ConanOutput
from conan.internal.conan_app import ConanApp
from conan.internal.conan_app import ConanApp, ConanBasicApp
from conans.client.graph.graph import Node, RECIPE_CONSUMER, CONTEXT_HOST, RECIPE_VIRTUAL, \
CONTEXT_BUILD
from conans.client.graph.graph_binaries import GraphBinariesAnalyzer
from conans.client.graph.graph_builder import DepsGraphBuilder
from conans.client.graph.profile_node_definer import initialize_conanfile_profile, consumer_definer
from conan.errors import ConanException
from conans.model.recipe_ref import RecipeReference
from conan.internal.model.recipe_ref import RecipeReference


class GraphAPI:
Expand Down Expand Up @@ -196,7 +196,7 @@ def analyze_binaries(self, graph, build_mode=None, remotes=None, update=None, lo
:param tested_graph: In case of a "test_package", the graph being tested
"""
ConanOutput().title("Computing necessary packages")
conan_app = ConanApp(self.conan_api)
conan_app = ConanBasicApp(self.conan_api)
binaries_analyzer = GraphBinariesAnalyzer(conan_app, self.conan_api.config.global_conf)
binaries_analyzer.evaluate_graph(graph, build_mode, lockfile, remotes, update,
build_modes_test, tested_graph)
6 changes: 3 additions & 3 deletions conan/api/subapi/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
from conan.internal.paths import CONANINFO
from conan.internal.errors import NotFoundException
from conan.errors import ConanException
from conans.model.info import load_binary_info
from conans.model.package_ref import PkgReference
from conans.model.recipe_ref import RecipeReference, ref_matches
from conan.internal.model.info import load_binary_info
from conan.internal.model.package_ref import PkgReference
from conan.internal.model.recipe_ref import RecipeReference, ref_matches
from conans.util.dates import timelimit
from conans.util.files import load

Expand Down
2 changes: 1 addition & 1 deletion conan/api/subapi/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from conan.internal.errors import conanfile_exception_formatter
from conan.errors import ConanException
from conans.client.hook_manager import HookManager
from conans.model.recipe_ref import RecipeReference
from conan.internal.model.recipe_ref import RecipeReference
from conans.util.files import chdir


Expand Down
2 changes: 1 addition & 1 deletion conan/api/subapi/lockfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from conan.cli import make_abs_path
from conans.client.graph.graph import Overrides
from conan.errors import ConanException
from conans.model.graph_lock import Lockfile, LOCKFILE
from conan.internal.model.lockfile import Lockfile, LOCKFILE


class LockfileAPI:
Expand Down
2 changes: 1 addition & 1 deletion conan/api/subapi/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from conan.internal.api.profile.profile_loader import ProfileLoader
from conan.internal.errors import scoped_traceback
from conan.errors import ConanException
from conans.model.profile import Profile
from conan.internal.model.profile import Profile

DEFAULT_PROFILE_NAME = "default"

Expand Down
13 changes: 10 additions & 3 deletions conan/api/subapi/remotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
from conan.api.model import Remote, LOCAL_RECIPES_INDEX
from conan.api.output import ConanOutput
from conan.internal.cache.home_paths import HomePaths
from conan.internal.conan_app import ConanApp
from conan.internal.conan_app import ConanBasicApp
from conans.client.rest.conan_requester import ConanRequester
from conans.client.rest_client_local_recipe_index import add_local_recipes_index_remote, \
remove_local_recipes_index_remote
from conan.internal.api.remotes.localdb import LocalDB
Expand All @@ -31,6 +32,8 @@ def __init__(self, conan_api):
self.conan_api = conan_api
self._home_folder = conan_api.home_folder
self._remotes_file = HomePaths(self._home_folder).remotes_path
# Wraps an http_requester to inject proxies, certs, etc
self._requester = ConanRequester(self.conan_api.config.global_conf, self.conan_api.cache_folder)

def list(self, pattern=None, only_enabled=True):
"""
Expand Down Expand Up @@ -218,7 +221,7 @@ def user_login(self, remote: Remote, username: str, password: str):
:param username: the user login as ``str``
:param password: password ``str``
"""
app = ConanApp(self.conan_api)
app = ConanBasicApp(self.conan_api)
app.remote_manager.authenticate(remote, username, password)

def user_logout(self, remote: Remote):
Expand All @@ -241,7 +244,7 @@ def user_set(self, remote: Remote, username):
def user_auth(self, remote: Remote, with_user=False, force=False):
# TODO: Review
localdb = LocalDB(self._home_folder)
app = ConanApp(self.conan_api)
app = ConanBasicApp(self.conan_api)
if with_user:
user, token, _ = localdb.get_login(remote.url)
if not user:
Expand All @@ -253,6 +256,10 @@ def user_auth(self, remote: Remote, with_user=False, force=False):
user, token, _ = localdb.get_login(remote.url)
return user

@property
def requester(self):
return self._requester


def _load(remotes_file):
if not os.path.exists(remotes_file):
Expand Down
20 changes: 11 additions & 9 deletions conan/api/subapi/remove.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
from typing import Optional

from conan.api.model import Remote
from conan.internal.conan_app import ConanApp
from conans.model.package_ref import PkgReference
from conans.model.recipe_ref import RecipeReference
from conan.internal.conan_app import ConanBasicApp
from conan.internal.model.package_ref import PkgReference
from conan.internal.model.recipe_ref import RecipeReference


class RemoveAPI:

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

def recipe(self, ref: RecipeReference, remote: Remote=None):
def recipe(self, ref: RecipeReference, remote: Optional[Remote] = None):
assert ref.revision, "Recipe revision cannot be None to remove a recipe"
"""Removes the recipe (or recipe revision if present) and all the packages (with all prev)"""
app = ConanApp(self.conan_api)
app = ConanBasicApp(self.conan_api)
if remote:
app.remote_manager.remove_recipe(ref, remote)
else:
self.all_recipe_packages(ref)
recipe_layout = app.cache.recipe_layout(ref)
app.cache.remove_recipe_layout(recipe_layout)

def all_recipe_packages(self, ref: RecipeReference, remote: Remote = None):
def all_recipe_packages(self, ref: RecipeReference, remote: Optional[Remote] = None):
assert ref.revision, "Recipe revision cannot be None to remove a recipe"
"""Removes all the packages from the provided reference"""
app = ConanApp(self.conan_api)
app = ConanBasicApp(self.conan_api)
if remote:
app.remote_manager.remove_all_packages(ref, remote)
else:
Expand All @@ -38,11 +40,11 @@ def _remove_all_local_packages(app, ref):
package_layout = app.cache.pkg_layout(pref)
app.cache.remove_package_layout(package_layout)

def package(self, pref: PkgReference, remote: Remote):
def package(self, pref: PkgReference, remote: Optional[Remote]):
assert pref.ref.revision, "Recipe revision cannot be None to remove a package"
assert pref.revision, "Package revision cannot be None to remove a package"

app = ConanApp(self.conan_api)
app = ConanBasicApp(self.conan_api)
if remote:
# FIXME: Create a "packages" method to optimize remote remove?
app.remote_manager.remove_packages([pref], remote)
Expand Down
4 changes: 2 additions & 2 deletions conan/api/subapi/search.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from conan.internal.conan_app import ConanApp
from conan.internal.conan_app import ConanBasicApp


class SearchAPI:
Expand All @@ -12,7 +12,7 @@ def recipes(self, query: str, remote=None):
only_none_user_channel = True
query = query[:-1]

app = ConanApp(self.conan_api)
app = ConanBasicApp(self.conan_api)
if remote:
refs = app.remote_manager.search_recipes(remote, query)
else:
Expand Down
5 changes: 2 additions & 3 deletions conan/api/subapi/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,8 @@ def upload_backup_sources(self, files):
output.info("No backup sources files to upload")
return files

app = ConanApp(self.conan_api)
# TODO: verify might need a config to force it to False
uploader = FileUploader(app.requester, verify=True, config=config, source_credentials=True)
requester = self.conan_api.remotes.requester
uploader = FileUploader(requester, verify=True, config=config, source_credentials=True)
# TODO: For Artifactory, we can list all files once and check from there instead
# of 1 request per file, but this is more general
for file in files:
Expand Down
2 changes: 1 addition & 1 deletion conan/api/subapi/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from conan.errors import ConanException
from conans.client.graph.graph import RECIPE_EDITABLE
from conans.client.source import retrieve_exports_sources
from conans.model.recipe_ref import RecipeReference
from conan.internal.model.recipe_ref import RecipeReference
from conans.util.files import merge_directories


Expand Down
4 changes: 2 additions & 2 deletions conan/cli/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from conan.api.output import ConanOutput
from conan.errors import ConanException
from conans.model.conf import CORE_CONF_PATTERN
from conan.internal.model.conf import CORE_CONF_PATTERN


class OnceArgument(argparse.Action):
Expand Down Expand Up @@ -126,7 +126,7 @@ def parse_args(self, args=None, namespace=None):
ConanOutput().error("The --lockfile-packages arg is private and shouldn't be used")
global_conf = self._conan_api.config.global_conf
if args.core_conf:
from conans.model.conf import ConfDefinition
from conan.internal.model.conf import ConfDefinition
confs = ConfDefinition()
for c in args.core_conf:
if not CORE_CONF_PATTERN.match(c):
Expand Down
4 changes: 2 additions & 2 deletions conan/cli/commands/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from conan.cli.command import conan_command, conan_subcommand, OnceArgument
from conan.cli.commands.list import print_list_text, print_list_json
from conan.errors import ConanException
from conans.model.package_ref import PkgReference
from conans.model.recipe_ref import RecipeReference
from conan.internal.model.package_ref import PkgReference
from conan.internal.model.recipe_ref import RecipeReference


def json_export(data):
Expand Down
2 changes: 1 addition & 1 deletion conan/cli/commands/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from conans.client.graph.graph import BINARY_MISSING
from conans.client.graph.install_graph import InstallGraph, ProfileArgs
from conan.internal.errors import NotFoundException
from conans.model.recipe_ref import ref_matches, RecipeReference
from conan.internal.model.recipe_ref import ref_matches, RecipeReference


def explain_formatter_text(data):
Expand Down
4 changes: 2 additions & 2 deletions conan/cli/commands/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from conan.cli.args import common_graph_args, validate_common_graph_args
from conan.cli.printers.graph import print_graph_packages, print_graph_basic
from conan.errors import ConanException
from conans.model.graph_lock import Lockfile, LOCKFILE
from conans.model.recipe_ref import RecipeReference
from conan.internal.model.lockfile import Lockfile, LOCKFILE
from conan.internal.model.recipe_ref import RecipeReference


@conan_command(group="Consumer")
Expand Down
2 changes: 1 addition & 1 deletion conan/cli/commands/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from conan.cli.formatters.graph import format_graph_json
from conan.cli.printers import print_profiles
from conan.cli.printers.graph import print_graph_basic, print_graph_packages
from conans.model.recipe_ref import RecipeReference
from conan.internal.model.recipe_ref import RecipeReference


@conan_command(group="Creator", formatters={"json": format_graph_json})
Expand Down
2 changes: 1 addition & 1 deletion conan/cli/formatters/list/binary_html_table.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from collections import OrderedDict, defaultdict

from conans.model.package_ref import PkgReference
from conan.internal.model.package_ref import PkgReference


class RowResult(object):
Expand Down
2 changes: 1 addition & 1 deletion conan/cps/cps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
from enum import Enum

from conans.model.build_info import CppInfo
from conan.internal.model.cpp_info import CppInfo
from conans.util.files import save, load


Expand Down
Loading

0 comments on commit c3936d7

Please sign in to comment.