Repository: conan-io/conan

Issue:
conan export-pkg touches remotes in 1.7.0
1.6.0 doesn't appear to have this behavior, but if you call "conan export-pkg" with a build_requires and a package override? it appears that conan will make a connection to available remotes.  Here's the TB where I added an assert in _call_remote()

This "broke" us because the box couldn't connect to bintray.  Not a huge deal (as I can just remove the remote), but I wouldn't expect a remote to be touched with export-pkg if the package is already installed.

```
$ conan export-pkg . brian/test
Exporting package recipe
blah/0.7@brian/test: The stored package has not changed
Traceback (most recent call last):
  File "/home/brian/.local/lib/python2.7/site-packages/conans/client/command.py", line 1251, in run
    method(args[0][1:])
  File "/home/brian/.local/lib/python2.7/site-packages/conans/client/command.py", line 694, in export_pkg
    channel=channel)
  File "/home/brian/.local/lib/python2.7/site-packages/conans/client/conan_api.py", line 82, in wrapper
    return f(*args, **kwargs)
  File "/home/brian/.local/lib/python2.7/site-packages/conans/client/conan_api.py", line 382, in export_pkg
    profile=profile, force=force)
  File "/home/brian/.local/lib/python2.7/site-packages/conans/client/manager.py", line 48, in export_pkg
    remote_name=None, recorder=self._recorder, workspace=None)
  File "/home/brian/.local/lib/python2.7/site-packages/conans/client/graph/graph_manager.py", line 115, in load_graph
    processed_profile=processed_profile)
  File "/home/brian/.local/lib/python2.7/site-packages/conans/client/graph/graph_manager.py", line 181, in _load_graph
    binaries_analyzer.evaluate_graph(graph, build_mode, update, remote_name)
  File "/home/brian/.local/lib/python2.7/site-packages/conans/client/graph/graph_binaries.py", line 148, in evaluate_graph
    self._evaluate_node(node, build_mode, update, evaluated_references, remote_name)
  File "/home/brian/.local/lib/python2.7/site-packages/conans/client/graph/graph_binaries.py", line 106, in _evaluate_node
    remote_info = self._get_package_info(package_ref, r)
  File "/home/brian/.local/lib/python2.7/site-packages/conans/client/graph/graph_binaries.py", line 24, in _get_package_info
    remote_info = self._remote_manager.get_package_info(package_ref, remote)
  File "/home/brian/.local/lib/python2.7/site-packages/conans/client/remote_manager.py", line 171, in get_package_info
    return self._call_remote(remote, "get_package_info", package_reference)
  File "/home/brian/.local/lib/python2.7/site-packages/conans/client/remote_manager.py", line 276, in _call_remote
    assert(0)
AssertionError
```


Discussion:
Yes, we need to check it. Where are you defining the build_requires, in the recipe itself? And you ran first the ``conan install`` and the build_requires was installed locally? Please give a bit more of details, so we can investigate. If a bug, we will try to release a fix asap, in 1.7.1
Yeah, conan install was run, package was built, then export-pkg was called and a connection is made to the remotes.  Remote was hit if package had a build_requires, which makes sense.

If you're expecting to hit the remote here that's fine.

$ git clone git@github.com:conan-community/conan-openssl.git
$ cd conan-openssl
$ conan install .
$ conan export-pkg . brian/test <--will hit remotes again
Thanks for the feedback, I have identified the issue, and I think it can be improved, will try to submit a fix for 1.7.1

Resolving patch:
diff --git a/conans/client/graph/graph_manager.py b/conans/client/graph/graph_manager.py
--- a/conans/client/graph/graph_manager.py
+++ b/conans/client/graph/graph_manager.py
@@ -73,6 +73,21 @@ def load_consumer_conanfile(self, conanfile_path, info_folder, output,
 
         return conanfile
 
+    def load_simple_graph(self, reference, profile, recorder):
+        # Loads a graph without computing the binaries. It is necessary for
+        # export-pkg command, not hitting the server
+        # # https://github.com/conan-io/conan/issues/3432
+        builder = DepsGraphBuilder(self._proxy, self._output, self._loader, self._resolver,
+                                   workspace=None, recorder=recorder)
+        cache_settings = self._client_cache.settings.copy()
+        cache_settings.values = profile.settings_values
+        settings_preprocessor.preprocess(cache_settings)
+        processed_profile = ProcessedProfile(cache_settings, profile, create_reference=None)
+        conanfile = self._loader.load_virtual([reference], processed_profile)
+        graph = builder.load_graph(conanfile, check_updates=False, update=False, remote_name=None,
+                                   processed_profile=processed_profile)
+        return graph
+
     def load_graph(self, reference, create_reference, profile, build_mode, check_updates, update, remote_name,
                    recorder, workspace):
 
diff --git a/conans/client/manager.py b/conans/client/manager.py
--- a/conans/client/manager.py
+++ b/conans/client/manager.py
@@ -43,9 +43,7 @@ def export_pkg(self, reference, source_folder, build_folder, package_folder, ins
         if not os.path.exists(conan_file_path):
             raise ConanException("Package recipe '%s' does not exist" % str(reference))
 
-        deps_graph, _, _ = self._graph_manager.load_graph(reference, None, profile,
-                                                          build_mode=None, check_updates=False, update=False,
-                                                          remote_name=None, recorder=self._recorder, workspace=None)
+        deps_graph = self._graph_manager.load_simple_graph(reference, profile, self._recorder)
 
         # this is a bit tricky, but works. The root (virtual), has only 1 neighbor,
         # which is the exported pkg


Test patch:
diff --git a/conans/test/command/export_pkg_test.py b/conans/test/command/export_pkg_test.py
--- a/conans/test/command/export_pkg_test.py
+++ b/conans/test/command/export_pkg_test.py
@@ -3,7 +3,7 @@
 import os
 
 from conans.paths import CONANFILE
-from conans.test.utils.tools import TestClient
+from conans.test.utils.tools import TestClient, TestServer
 from conans.model.ref import ConanFileReference, PackageReference
 from conans.util.files import load, mkdir
 from conans.test.utils.conanfile import TestConanFile
@@ -11,6 +11,23 @@
 
 
 class ExportPkgTest(unittest.TestCase):
+    def test_dont_touch_server(self):
+        # https://github.com/conan-io/conan/issues/3432
+        class RequesterMock(object):
+            def __init__(self, *args, **kwargs):
+                pass
+
+        # https://github.com/conan-io/conan/issues/3432
+        client = TestClient(servers={"default": TestServer()},
+                            requester_class=RequesterMock,
+                            users={"default": [("lasote", "mypass")]})
+        conanfile = """from conans import ConanFile
+class Pkg(ConanFile):
+    pass
+"""
+        client.save({"conanfile.py": conanfile})
+        client.run("install .")
+        client.run("export-pkg . Pkg/0.1@user/testing")
 
     def test_package_folder_errors(self):
         # https://github.com/conan-io/conan/issues/2350