Repository: conan-io/conan
Pull request #16920 (2024-09-01 23:32:46)

refactor conans->conan
Changelog: Omit
Docs: Omit

Low hanging fruit for the conans->conan refactor


Patch:
diff --git a/conan/api/subapi/config.py b/conan/api/subapi/config.py
index 5b943f16b..3bd34b2ef 100644
--- a/conan/api/subapi/config.py
+++ b/conan/api/subapi/config.py
@@ -34,7 +34,7 @@ class ConfigAPI:
     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 conans.client.conf.config_installer import configuration_install
+        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,
                               source_folder=source_folder, target_folder=target_folder)
@@ -89,7 +89,7 @@ class ConfigAPI:
                                        "skipping configuration install")
                     return pkg.pref  # Already installed, we can skip repeating the install
 
-        from conans.client.conf.config_installer import configuration_install
+        from conan.internal.api.config.config_installer import configuration_install
         configuration_install(app, 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
diff --git a/conan/api/subapi/export.py b/conan/api/subapi/export.py
index ab8d410cd..4eeb0201b 100644
--- a/conan/api/subapi/export.py
+++ b/conan/api/subapi/export.py
@@ -1,6 +1,6 @@
 from conan.api.output import ConanOutput
 from conan.internal.conan_app import ConanApp
-from conans.client.cmd.export import cmd_export
+from conan.internal.api.export import cmd_export
 from conans.client.conanfile.package import run_package_method
 from conans.client.graph.graph import BINARY_BUILD, RECIPE_INCACHE
 from conans.model.package_ref import PkgReference
diff --git a/conan/api/subapi/profiles.py b/conan/api/subapi/profiles.py
index 62d50fd65..d3849525a 100644
--- a/conan/api/subapi/profiles.py
+++ b/conan/api/subapi/profiles.py
@@ -144,7 +144,7 @@ class ProfilesAPI:
         :return: an automatically detected Profile, with a "best guess" of the system settings
         """
         profile = Profile()
-        from conans.client.conf.detect import detect_defaults_settings
+        from conan.internal.api.profile.detect import detect_defaults_settings
         settings = detect_defaults_settings()
         for name, value in settings:
             profile.settings[name] = value
diff --git a/conan/api/subapi/upload.py b/conan/api/subapi/upload.py
index 6113c5463..cc151a761 100644
--- a/conan/api/subapi/upload.py
+++ b/conan/api/subapi/upload.py
@@ -5,7 +5,7 @@ from multiprocessing.pool import ThreadPool
 from conan.api.output import ConanOutput
 from conan.internal.conan_app import ConanApp
 from conan.internal.upload_metadata import gather_metadata
-from conans.client.cmd.uploader import PackagePreparator, UploadExecutor, UploadUpstreamChecker
+from conan.internal.api.uploader import PackagePreparator, UploadExecutor, UploadUpstreamChecker
 from conans.client.pkg_sign import PkgSignaturesPlugin
 from conans.client.rest.file_uploader import FileUploader
 from conans.errors import ConanException, AuthenticationException, ForbiddenException
diff --git a/conans/client/cmd/__init__.py b/conan/internal/api/config/__init__.py
similarity index 100%
rename from conans/client/cmd/__init__.py
rename to conan/internal/api/config/__init__.py
diff --git a/conans/client/conf/config_installer.py b/conan/internal/api/config/config_installer.py
similarity index 100%
rename from conans/client/conf/config_installer.py
rename to conan/internal/api/config/config_installer.py
diff --git a/conans/client/cmd/export.py b/conan/internal/api/export.py
similarity index 100%
rename from conans/client/cmd/export.py
rename to conan/internal/api/export.py
diff --git a/conans/client/conf/detect.py b/conan/internal/api/profile/detect.py
similarity index 100%
rename from conans/client/conf/detect.py
rename to conan/internal/api/profile/detect.py
diff --git a/conans/client/cmd/uploader.py b/conan/internal/api/uploader.py
similarity index 100%
rename from conans/client/cmd/uploader.py
rename to conan/internal/api/uploader.py
diff --git a/conans/client/rest_client_local_recipe_index.py b/conans/client/rest_client_local_recipe_index.py
index e806fe3fe..39de35508 100644
--- a/conans/client/rest_client_local_recipe_index.py
+++ b/conans/client/rest_client_local_recipe_index.py
@@ -9,7 +9,7 @@ import yaml
 from conan.api.model import LOCAL_RECIPES_INDEX
 from conan.api.output import ConanOutput
 from conan.internal.cache.home_paths import HomePaths
-from conans.client.cmd.export import cmd_export
+from conan.internal.api.export import cmd_export
 from conans.client.loader import ConanFileLoader
 from conans.errors import ConanException, PackageNotFoundException, RecipeNotFoundException, \
     ConanReferenceDoesNotExistInDB, NotFoundException


Test patch:
diff --git a/test/functional/command/config_install_test.py b/test/functional/command/config_install_test.py
index 5e5d668c5..ad16aae8d 100644
--- a/test/functional/command/config_install_test.py
+++ b/test/functional/command/config_install_test.py
@@ -8,7 +8,7 @@ import pytest
 from mock import patch
 
 from conan.api.model import Remote
-from conans.client.conf.config_installer import _hide_password
+from conan.internal.api.config.config_installer import _hide_password
 from conans.client.downloaders.file_downloader import FileDownloader
 from conan.internal.paths import DEFAULT_CONAN_HOME
 from conan.test.assets.genconanfile import GenConanfile
diff --git a/test/functional/command/profile_test.py b/test/functional/command/profile_test.py
index f8362416d..8e67b3390 100644
--- a/test/functional/command/profile_test.py
+++ b/test/functional/command/profile_test.py
@@ -5,7 +5,7 @@ import unittest
 
 import pytest
 
-from conans.client.conf.detect import detect_defaults_settings
+from conan.internal.api.profile.detect import detect_defaults_settings
 from conan.test.utils.mocks import RedirectedTestOutput
 from conan.test.utils.tools import TestClient, redirect_output
 from conan.test.utils.env import environment_update
diff --git a/test/integration/command/upload/upload_test.py b/test/integration/command/upload/upload_test.py
index 1e344ae45..a37008435 100644
--- a/test/integration/command/upload/upload_test.py
+++ b/test/integration/command/upload/upload_test.py
@@ -116,7 +116,7 @@ class UploadTest(unittest.TestCase):
 
         def gzopen_patched(name, mode="r", fileobj=None, **kwargs):
             raise ConanException("Error gzopen %s" % name)
-        with patch('conans.client.cmd.uploader.gzopen_without_timestamps', new=gzopen_patched):
+        with patch('conan.internal.api.uploader.gzopen_without_timestamps', new=gzopen_patched):
             client.run("upload * --confirm -r default --only-recipe",
                        assert_error=True)
             self.assertIn("Error gzopen conan_sources.tgz", client.out)
@@ -145,7 +145,7 @@ class UploadTest(unittest.TestCase):
             if name == PACKAGE_TGZ_NAME:
                 raise ConanException("Error gzopen %s" % name)
             return gzopen_without_timestamps(name, mode, fileobj, **kwargs)
-        with patch('conans.client.cmd.uploader.gzopen_without_timestamps', new=gzopen_patched):
+        with patch('conan.internal.api.uploader.gzopen_without_timestamps', new=gzopen_patched):
             client.run("upload * --confirm -r default", assert_error=True)
             self.assertIn("Error gzopen conan_package.tgz", client.out)
 
diff --git a/test/unittests/client/conf/config_installer/test_install_folder.py b/test/unittests/client/conf/config_installer/test_install_folder.py
index f2eecc1f3..1f72d626e 100644
--- a/test/unittests/client/conf/config_installer/test_install_folder.py
+++ b/test/unittests/client/conf/config_installer/test_install_folder.py
@@ -1,7 +1,7 @@
 import unittest
 import os
 
-from conans.client.conf.config_installer import tmp_config_install_folder
+from conan.internal.api.config.config_installer import tmp_config_install_folder
 from conan.test.utils.test_files import temp_folder
 
 
diff --git a/test/unittests/client/remote_manager_test.py b/test/unittests/client/remote_manager_test.py
index e0438bcd8..871cf6097 100644
--- a/test/unittests/client/remote_manager_test.py
+++ b/test/unittests/client/remote_manager_test.py
@@ -1,7 +1,7 @@
 import os
 import unittest
 
-from conans.client.cmd.uploader import compress_files
+from conan.internal.api.uploader import compress_files
 from conan.internal.paths import PACKAGE_TGZ_NAME
 from conan.test.utils.test_files import temp_folder
 from conans.util.files import save
diff --git a/test/unittests/util/detect_test.py b/test/unittests/util/detect_test.py
index c0e3c8b7e..0309715e8 100644
--- a/test/unittests/util/detect_test.py
+++ b/test/unittests/util/detect_test.py
@@ -6,7 +6,7 @@ import pytest
 from parameterized import parameterized
 
 from conan.internal.api.detect_api import _cc_compiler
-from conans.client.conf.detect import detect_defaults_settings
+from conan.internal.api.profile.detect import detect_defaults_settings
 from conans.model.version import Version
 from conan.test.utils.mocks import RedirectedTestOutput
 from conan.test.utils.tools import redirect_output