Skip to content

Commit c3936d7

Browse files
authored
Merge branch 'develop2' into feature/lock_upgrade
2 parents b9fade5 + 13d4c3d commit c3936d7

File tree

223 files changed

+490
-479
lines changed

Some content is hidden

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

223 files changed

+490
-479
lines changed

conan/__init__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from conans.model.conan_file import ConanFile
2-
from conan.tools.scm import Version as _Version
1+
from conan.internal.model.conan_file import ConanFile
2+
from conan.internal.model.version import Version
33

44
__version__ = '2.12.0-dev'
5-
conan_version = _Version(__version__)
5+
conan_version = Version(__version__)

conan/api/conan_api.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from conans.client.migrations import ClientMigrator
2323
from conan.errors import ConanException
2424
from conan.internal.paths import get_conan_user_home
25-
from conans.model.version_range import validate_conan_version
25+
from conan.internal.model.version_range import validate_conan_version
2626

2727

2828
class ConanAPI:
@@ -41,9 +41,10 @@ def __init__(self, cache_folder=None):
4141
migrator = ClientMigrator(self.cache_folder, conan_version)
4242
migrator.migrate()
4343

44-
self.command = CommandAPI(self)
44+
self.config = ConfigAPI(self)
4545
self.remotes = RemotesAPI(self)
46-
# Search recipes by wildcard and packages filtering by configuracion
46+
self.command = CommandAPI(self)
47+
# Search recipes by wildcard and packages filtering by configuration
4748
self.search = SearchAPI(self)
4849
# Get latest refs and list refs of recipes and packages
4950
self.list = ListAPI(self)
@@ -52,7 +53,6 @@ def __init__(self, cache_folder=None):
5253
self.graph = GraphAPI(self)
5354
self.export = ExportAPI(self)
5455
self.remove = RemoveAPI(self)
55-
self.config = ConfigAPI(self)
5656
self.new = NewAPI(self)
5757
self.upload = UploadAPI(self)
5858
self.download = DownloadAPI(self)

conan/api/model.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
RECIPE_VIRTUAL, BINARY_SKIP, BINARY_MISSING, BINARY_INVALID
88
from conan.internal.errors import NotFoundException
99
from conan.errors import ConanException
10-
from conans.model.package_ref import PkgReference
11-
from conans.model.recipe_ref import RecipeReference
10+
from conan.internal.model.package_ref import PkgReference
11+
from conan.internal.model.recipe_ref import RecipeReference
1212
from conans.util.files import load
13-
from conans.model.version_range import VersionRange
13+
from conan.internal.model.version_range import VersionRange
1414

1515
LOCAL_RECIPES_INDEX = "local-recipes-index"
1616

conan/api/subapi/cache.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
from conan.internal.cache.integrity_check import IntegrityChecker
1212
from conans.client.downloaders.download_cache import DownloadCache
1313
from conan.errors import ConanException
14-
from conans.model.package_ref import PkgReference
15-
from conans.model.recipe_ref import RecipeReference
14+
from conan.internal.model.package_ref import PkgReference
15+
from conan.internal.model.recipe_ref import RecipeReference
1616
from conans.util.dates import revision_timestamp_now
1717
from conans.util.files import rmdir, gzopen_without_timestamps, mkdir, remove
1818

conan/api/subapi/config.py

+10-7
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
from conans.client.graph.graph_builder import DepsGraphBuilder
1717
from conans.client.graph.profile_node_definer import consumer_definer
1818
from conan.errors import ConanException
19-
from conans.model.conf import ConfDefinition, BUILT_IN_CONFS
20-
from conans.model.pkg_type import PackageType
21-
from conans.model.recipe_ref import RecipeReference
22-
from conans.model.settings import Settings
19+
from conan.internal.model.conf import ConfDefinition, BUILT_IN_CONFS
20+
from conan.internal.model.pkg_type import PackageType
21+
from conan.internal.model.recipe_ref import RecipeReference
22+
from conan.internal.model.settings import Settings
2323
from conans.util.files import load, save
2424

2525

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

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

9293
from conan.internal.api.config.config_installer import configuration_install
93-
configuration_install(app, uri=pkg.conanfile.package_folder, verify_ssl=False,
94+
cache_folder = self.conan_api.cache_folder
95+
requester = self.conan_api.remotes.requester
96+
configuration_install(cache_folder, requester, uri=pkg.conanfile.package_folder, verify_ssl=False,
9497
config_type="dir", ignore=["conaninfo.txt", "conanmanifest.txt"])
9598
# We save the current package full reference in the file for future
9699
# And for ``package_id`` computation

conan/api/subapi/download.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
from conan.api.output import ConanOutput
77
from conan.internal.conan_app import ConanBasicApp
88
from conan.errors import ConanException
9-
from conans.model.package_ref import PkgReference
10-
from conans.model.recipe_ref import RecipeReference
9+
from conan.internal.model.package_ref import PkgReference
10+
from conan.internal.model.recipe_ref import RecipeReference
1111

1212

1313
class DownloadAPI:

conan/api/subapi/export.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from conan.internal.methods import run_package_method
77
from conans.client.graph.graph import BINARY_BUILD, RECIPE_INCACHE
88
from conans.client.hook_manager import HookManager
9-
from conans.model.package_ref import PkgReference
9+
from conan.internal.model.package_ref import PkgReference
1010
from conans.util.files import mkdir
1111

1212

conan/api/subapi/graph.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
from conan.api.output import ConanOutput
2-
from conan.internal.conan_app import ConanApp
2+
from conan.internal.conan_app import ConanApp, ConanBasicApp
33
from conans.client.graph.graph import Node, RECIPE_CONSUMER, CONTEXT_HOST, RECIPE_VIRTUAL, \
44
CONTEXT_BUILD
55
from conans.client.graph.graph_binaries import GraphBinariesAnalyzer
66
from conans.client.graph.graph_builder import DepsGraphBuilder
77
from conans.client.graph.profile_node_definer import initialize_conanfile_profile, consumer_definer
88
from conan.errors import ConanException
9-
from conans.model.recipe_ref import RecipeReference
9+
from conan.internal.model.recipe_ref import RecipeReference
1010

1111

1212
class GraphAPI:
@@ -196,7 +196,7 @@ def analyze_binaries(self, graph, build_mode=None, remotes=None, update=None, lo
196196
:param tested_graph: In case of a "test_package", the graph being tested
197197
"""
198198
ConanOutput().title("Computing necessary packages")
199-
conan_app = ConanApp(self.conan_api)
199+
conan_app = ConanBasicApp(self.conan_api)
200200
binaries_analyzer = GraphBinariesAnalyzer(conan_app, self.conan_api.config.global_conf)
201201
binaries_analyzer.evaluate_graph(graph, build_mode, lockfile, remotes, update,
202202
build_modes_test, tested_graph)

conan/api/subapi/list.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
from conan.internal.paths import CONANINFO
1010
from conan.internal.errors import NotFoundException
1111
from conan.errors import ConanException
12-
from conans.model.info import load_binary_info
13-
from conans.model.package_ref import PkgReference
14-
from conans.model.recipe_ref import RecipeReference, ref_matches
12+
from conan.internal.model.info import load_binary_info
13+
from conan.internal.model.package_ref import PkgReference
14+
from conan.internal.model.recipe_ref import RecipeReference, ref_matches
1515
from conans.util.dates import timelimit
1616
from conans.util.files import load
1717

conan/api/subapi/local.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from conan.internal.errors import conanfile_exception_formatter
1111
from conan.errors import ConanException
1212
from conans.client.hook_manager import HookManager
13-
from conans.model.recipe_ref import RecipeReference
13+
from conan.internal.model.recipe_ref import RecipeReference
1414
from conans.util.files import chdir
1515

1616

conan/api/subapi/lockfile.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from conan.cli import make_abs_path
55
from conans.client.graph.graph import Overrides
66
from conan.errors import ConanException
7-
from conans.model.graph_lock import Lockfile, LOCKFILE
7+
from conan.internal.model.lockfile import Lockfile, LOCKFILE
88

99

1010
class LockfileAPI:

conan/api/subapi/profiles.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from conan.internal.api.profile.profile_loader import ProfileLoader
88
from conan.internal.errors import scoped_traceback
99
from conan.errors import ConanException
10-
from conans.model.profile import Profile
10+
from conan.internal.model.profile import Profile
1111

1212
DEFAULT_PROFILE_NAME = "default"
1313

conan/api/subapi/remotes.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
from conan.api.model import Remote, LOCAL_RECIPES_INDEX
77
from conan.api.output import ConanOutput
88
from conan.internal.cache.home_paths import HomePaths
9-
from conan.internal.conan_app import ConanApp
9+
from conan.internal.conan_app import ConanBasicApp
10+
from conans.client.rest.conan_requester import ConanRequester
1011
from conans.client.rest_client_local_recipe_index import add_local_recipes_index_remote, \
1112
remove_local_recipes_index_remote
1213
from conan.internal.api.remotes.localdb import LocalDB
@@ -31,6 +32,8 @@ def __init__(self, conan_api):
3132
self.conan_api = conan_api
3233
self._home_folder = conan_api.home_folder
3334
self._remotes_file = HomePaths(self._home_folder).remotes_path
35+
# Wraps an http_requester to inject proxies, certs, etc
36+
self._requester = ConanRequester(self.conan_api.config.global_conf, self.conan_api.cache_folder)
3437

3538
def list(self, pattern=None, only_enabled=True):
3639
"""
@@ -218,7 +221,7 @@ def user_login(self, remote: Remote, username: str, password: str):
218221
:param username: the user login as ``str``
219222
:param password: password ``str``
220223
"""
221-
app = ConanApp(self.conan_api)
224+
app = ConanBasicApp(self.conan_api)
222225
app.remote_manager.authenticate(remote, username, password)
223226

224227
def user_logout(self, remote: Remote):
@@ -241,7 +244,7 @@ def user_set(self, remote: Remote, username):
241244
def user_auth(self, remote: Remote, with_user=False, force=False):
242245
# TODO: Review
243246
localdb = LocalDB(self._home_folder)
244-
app = ConanApp(self.conan_api)
247+
app = ConanBasicApp(self.conan_api)
245248
if with_user:
246249
user, token, _ = localdb.get_login(remote.url)
247250
if not user:
@@ -253,6 +256,10 @@ def user_auth(self, remote: Remote, with_user=False, force=False):
253256
user, token, _ = localdb.get_login(remote.url)
254257
return user
255258

259+
@property
260+
def requester(self):
261+
return self._requester
262+
256263

257264
def _load(remotes_file):
258265
if not os.path.exists(remotes_file):

conan/api/subapi/remove.py

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
1+
from typing import Optional
2+
13
from conan.api.model import Remote
2-
from conan.internal.conan_app import ConanApp
3-
from conans.model.package_ref import PkgReference
4-
from conans.model.recipe_ref import RecipeReference
4+
from conan.internal.conan_app import ConanBasicApp
5+
from conan.internal.model.package_ref import PkgReference
6+
from conan.internal.model.recipe_ref import RecipeReference
57

68

79
class RemoveAPI:
810

911
def __init__(self, conan_api):
1012
self.conan_api = conan_api
1113

12-
def recipe(self, ref: RecipeReference, remote: Remote=None):
14+
def recipe(self, ref: RecipeReference, remote: Optional[Remote] = None):
1315
assert ref.revision, "Recipe revision cannot be None to remove a recipe"
1416
"""Removes the recipe (or recipe revision if present) and all the packages (with all prev)"""
15-
app = ConanApp(self.conan_api)
17+
app = ConanBasicApp(self.conan_api)
1618
if remote:
1719
app.remote_manager.remove_recipe(ref, remote)
1820
else:
1921
self.all_recipe_packages(ref)
2022
recipe_layout = app.cache.recipe_layout(ref)
2123
app.cache.remove_recipe_layout(recipe_layout)
2224

23-
def all_recipe_packages(self, ref: RecipeReference, remote: Remote = None):
25+
def all_recipe_packages(self, ref: RecipeReference, remote: Optional[Remote] = None):
2426
assert ref.revision, "Recipe revision cannot be None to remove a recipe"
2527
"""Removes all the packages from the provided reference"""
26-
app = ConanApp(self.conan_api)
28+
app = ConanBasicApp(self.conan_api)
2729
if remote:
2830
app.remote_manager.remove_all_packages(ref, remote)
2931
else:
@@ -38,11 +40,11 @@ def _remove_all_local_packages(app, ref):
3840
package_layout = app.cache.pkg_layout(pref)
3941
app.cache.remove_package_layout(package_layout)
4042

41-
def package(self, pref: PkgReference, remote: Remote):
43+
def package(self, pref: PkgReference, remote: Optional[Remote]):
4244
assert pref.ref.revision, "Recipe revision cannot be None to remove a package"
4345
assert pref.revision, "Package revision cannot be None to remove a package"
4446

45-
app = ConanApp(self.conan_api)
47+
app = ConanBasicApp(self.conan_api)
4648
if remote:
4749
# FIXME: Create a "packages" method to optimize remote remove?
4850
app.remote_manager.remove_packages([pref], remote)

conan/api/subapi/search.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from conan.internal.conan_app import ConanApp
1+
from conan.internal.conan_app import ConanBasicApp
22

33

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

15-
app = ConanApp(self.conan_api)
15+
app = ConanBasicApp(self.conan_api)
1616
if remote:
1717
refs = app.remote_manager.search_recipes(remote, query)
1818
else:

conan/api/subapi/upload.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,8 @@ def upload_backup_sources(self, files):
113113
output.info("No backup sources files to upload")
114114
return files
115115

116-
app = ConanApp(self.conan_api)
117-
# TODO: verify might need a config to force it to False
118-
uploader = FileUploader(app.requester, verify=True, config=config, source_credentials=True)
116+
requester = self.conan_api.remotes.requester
117+
uploader = FileUploader(requester, verify=True, config=config, source_credentials=True)
119118
# TODO: For Artifactory, we can list all files once and check from there instead
120119
# of 1 request per file, but this is more general
121120
for file in files:

conan/api/subapi/workspace.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from conan.errors import ConanException
99
from conans.client.graph.graph import RECIPE_EDITABLE
1010
from conans.client.source import retrieve_exports_sources
11-
from conans.model.recipe_ref import RecipeReference
11+
from conan.internal.model.recipe_ref import RecipeReference
1212
from conans.util.files import merge_directories
1313

1414

conan/cli/command.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from conan.api.output import ConanOutput
66
from conan.errors import ConanException
7-
from conans.model.conf import CORE_CONF_PATTERN
7+
from conan.internal.model.conf import CORE_CONF_PATTERN
88

99

1010
class OnceArgument(argparse.Action):
@@ -126,7 +126,7 @@ def parse_args(self, args=None, namespace=None):
126126
ConanOutput().error("The --lockfile-packages arg is private and shouldn't be used")
127127
global_conf = self._conan_api.config.global_conf
128128
if args.core_conf:
129-
from conans.model.conf import ConfDefinition
129+
from conan.internal.model.conf import ConfDefinition
130130
confs = ConfDefinition()
131131
for c in args.core_conf:
132132
if not CORE_CONF_PATTERN.match(c):

conan/cli/commands/cache.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
from conan.cli.command import conan_command, conan_subcommand, OnceArgument
88
from conan.cli.commands.list import print_list_text, print_list_json
99
from conan.errors import ConanException
10-
from conans.model.package_ref import PkgReference
11-
from conans.model.recipe_ref import RecipeReference
10+
from conan.internal.model.package_ref import PkgReference
11+
from conan.internal.model.recipe_ref import RecipeReference
1212

1313

1414
def json_export(data):

conan/cli/commands/graph.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from conans.client.graph.graph import BINARY_MISSING
1818
from conans.client.graph.install_graph import InstallGraph, ProfileArgs
1919
from conan.internal.errors import NotFoundException
20-
from conans.model.recipe_ref import ref_matches, RecipeReference
20+
from conan.internal.model.recipe_ref import ref_matches, RecipeReference
2121

2222

2323
def explain_formatter_text(data):

conan/cli/commands/lock.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
from conan.cli.args import common_graph_args, validate_common_graph_args
88
from conan.cli.printers.graph import print_graph_packages, print_graph_basic
99
from conan.errors import ConanException
10-
from conans.model.graph_lock import Lockfile, LOCKFILE
11-
from conans.model.recipe_ref import RecipeReference
10+
from conan.internal.model.lockfile import Lockfile, LOCKFILE
11+
from conan.internal.model.recipe_ref import RecipeReference
1212

1313

1414
@conan_command(group="Consumer")

conan/cli/commands/test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from conan.cli.formatters.graph import format_graph_json
88
from conan.cli.printers import print_profiles
99
from conan.cli.printers.graph import print_graph_basic, print_graph_packages
10-
from conans.model.recipe_ref import RecipeReference
10+
from conan.internal.model.recipe_ref import RecipeReference
1111

1212

1313
@conan_command(group="Creator", formatters={"json": format_graph_json})

conan/cli/formatters/list/binary_html_table.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from collections import OrderedDict, defaultdict
22

3-
from conans.model.package_ref import PkgReference
3+
from conan.internal.model.package_ref import PkgReference
44

55

66
class RowResult(object):

conan/cps/cps.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import os
33
from enum import Enum
44

5-
from conans.model.build_info import CppInfo
5+
from conan.internal.model.cpp_info import CppInfo
66
from conans.util.files import save, load
77

88

0 commit comments

Comments
 (0)