diff --git a/conans/client/cmd/export_pkg.py b/conans/client/cmd/export_pkg.py
index ec493de6e..ca7146db2 100644
--- a/conans/client/cmd/export_pkg.py
+++ b/conans/client/cmd/export_pkg.py
@@ -6,6 +6,7 @@ from conans.errors import ConanException
 from conans.model.manifest import FileTreeManifest
 from conans.model.ref import PackageReference
 from conans.util.files import rmdir
+from conans.model.conan_file import get_env_context_manager
 
 
 def export_pkg(cache, graph_manager, hook_manager, recorder, output,
@@ -20,7 +21,8 @@ def export_pkg(cache, graph_manager, hook_manager, recorder, output,
     # to be downloaded from remotes
     deps_graph, _ = graph_manager.load_graph(ref, None, graph_info=graph_info, build_mode=[ref.name],
                                              check_updates=False, update=False,
-                                             remote_name=None, recorder=recorder)
+                                             remote_name=None, recorder=recorder,
+                                             apply_build_requires=False)
     # this is a bit tricky, but works. The root (virtual), has only 1 neighbor,
     # which is the exported pkg
     nodes = deps_graph.root.neighbors()
@@ -47,9 +49,10 @@ def export_pkg(cache, graph_manager, hook_manager, recorder, output,
         packager.export_pkg(conanfile, package_id, package_folder, dest_package_folder,
                             hook_manager, conan_file_path, ref)
     else:
-        packager.create_package(conanfile, package_id, source_folder, build_folder,
-                                dest_package_folder, install_folder, hook_manager, conan_file_path,
-                                ref, local=True)
+        with get_env_context_manager(conanfile):
+            packager.create_package(conanfile, package_id, source_folder, build_folder,
+                                    dest_package_folder, install_folder, hook_manager,
+                                    conan_file_path, ref, local=True)
     with cache.package_layout(ref).update_metadata() as metadata:
         readed_manifest = FileTreeManifest.load(dest_package_folder)
         metadata.packages[package_id].revision = readed_manifest.summary_hash
diff --git a/conans/client/graph/graph_manager.py b/conans/client/graph/graph_manager.py
index 645e30027..64c39fc98 100644
--- a/conans/client/graph/graph_manager.py
+++ b/conans/client/graph/graph_manager.py
@@ -90,7 +90,7 @@ class GraphManager(object):
         return conanfile
 
     def load_graph(self, reference, create_reference, graph_info, build_mode, check_updates, update,
-                   remote_name, recorder):
+                   remote_name, recorder, apply_build_requires=True):
 
         def _inject_require(conanfile, ref):
             """ test_package functionality requires injecting the tested package as requirement
@@ -145,7 +145,8 @@ class GraphManager(object):
                                       build_mode=build_mode, remote_name=remote_name,
                                       profile_build_requires=profile.build_requires,
                                       recorder=recorder,
-                                      processed_profile=processed_profile)
+                                      processed_profile=processed_profile,
+                                      apply_build_requires=apply_build_requires)
 
         # THIS IS NECESSARY to store dependencies options in profile, for consumer
         # FIXME: This is a hack. Might dissapear if the graph for local commands is always recomputed
@@ -172,11 +173,12 @@ class GraphManager(object):
         return conanfile.build_requires
 
     def _recurse_build_requires(self, graph, builder, binaries_analyzer, check_updates, update,
-                                build_mode, remote_name,
-                                profile_build_requires, recorder, processed_profile):
+                                build_mode, remote_name, profile_build_requires, recorder,
+                                processed_profile, apply_build_requires=True):
 
         binaries_analyzer.evaluate_graph(graph, build_mode, update, remote_name)
-
+        if not apply_build_requires:
+            return
         for node in graph.ordered_iterate():
             # Virtual conanfiles doesn't have output, but conanfile.py and conanfile.txt do
             # FIXME: To be improved and build a explicit model for this
@@ -224,7 +226,7 @@ class GraphManager(object):
                 graph.nodes.update(subgraph.nodes)
 
     def _load_graph(self, root_node, check_updates, update, build_mode, remote_name,
-                    profile_build_requires, recorder, processed_profile):
+                    profile_build_requires, recorder, processed_profile, apply_build_requires):
 
         assert isinstance(build_mode, BuildMode)
         builder = DepsGraphBuilder(self._proxy, self._output, self._loader, self._resolver,
@@ -235,7 +237,8 @@ class GraphManager(object):
 
         self._recurse_build_requires(graph, builder, binaries_analyzer, check_updates, update,
                                      build_mode, remote_name,
-                                     profile_build_requires, recorder, processed_profile)
+                                     profile_build_requires, recorder, processed_profile,
+                                     apply_build_requires=apply_build_requires)
 
         # Sort of closures, for linking order
         inverse_levels = {n: i for i, level in enumerate(graph.inverse_levels()) for n in level}

[Bug] conan export-pkg has seemingly all values from profile propagated with the exception of CONAN_CMAKE_GENERATOR
When I want to export to local cache from a local source dir, I first run the setup commands and build my project
```
conan install . -if=build -pr=myprofile
conan build . -sf=. -bf=build
```
then when I run *either* of these commands the wrong generator is used
```
conan export-pkg . user/channel -sf=. -bf=build -f
conan export-pkg . user/channel -sf=. -bf=build -pr=myprofile -f
```
Looking at the `command` variable at line 195 in the cmake.py cmake helper class, the command given to cmake is exactly the same for both versions of `export-pkg` above. The cmake command value is how I expect it to be with the exception of that the generator given in the profile is not respected, but uses the default given in conan.conf. If no default in conan.conf is given it defaults back to MinGW Makefiles.  

A workaround is to set the correct generator as default in conan.conf. But this can only be temporary as projects sometimes includes C# so a mix of generators is to be used.
diff --git a/conans/test/functional/command/export_pkg_test.py b/conans/test/functional/command/export_pkg_test.py
index dbde9c941..32654bd50 100644
--- a/conans/test/functional/command/export_pkg_test.py
+++ b/conans/test/functional/command/export_pkg_test.py
@@ -8,31 +8,36 @@ from parameterized import parameterized
 from conans.model.ref import ConanFileReference, PackageReference
 from conans.paths import CONANFILE
 from conans.test.utils.conanfile import TestConanFile
-from conans.test.utils.tools import NO_SETTINGS_PACKAGE_ID, TestClient, TestServer
+from conans.test.utils.tools import NO_SETTINGS_PACKAGE_ID, TestClient
 from conans.util.env_reader import get_env
 from conans.util.files import load, mkdir
+from textwrap import dedent
 
 
 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,
+        client = TestClient(servers={"default": None},
+                            requester_class=None,
                             users={"default": [("lasote", "mypass")]})
-        conanfile = """from conans import ConanFile
-class Pkg(ConanFile):
-    pass
-"""
-        client.save({"conanfile.py": conanfile})
+
+        client.save({"conanfile.py": str(TestConanFile("Pkg", "0.1"))})
         client.run("install .")
         client.run("export-pkg . Pkg/0.1@user/testing")
 
+    def test_dont_touch_server_build_require(self):
+        client = TestClient(servers={"default": None},
+                            requester_class=None,
+                            users={"default": [("lasote", "mypass")]})
+        profile = dedent("""
+            [build_requires]
+            some/other@pkg/notexists
+            """)
+        client.save({"conanfile.py": str(TestConanFile("Pkg", "0.1")),
+                     "myprofile": profile})
+        client.run("export-pkg . Pkg/0.1@user/testing -pr=myprofile")
+
     def test_transitive_without_settings(self):
         # https://github.com/conan-io/conan/issues/3367
         conanfile = """from conans import ConanFile
@@ -151,6 +156,25 @@ class HelloPythonConan(ConanFile):
         self.assertIn("optionOne: False", client.out)
         self.assertIn("optionOne: 123", client.out)
 
+    def test_profile_environment(self):
+        # https://github.com/conan-io/conan/issues/4832
+        conanfile = dedent("""
+            import os
+            from conans import ConanFile
+            class HelloPythonConan(ConanFile):
+                def package(self):
+                    self.output.info("ENV-VALUE: %s!!!" % os.getenv("MYCUSTOMVAR"))
+            """)
+        profile = dedent("""
+            [env]
+            MYCUSTOMVAR=MYCUSTOMVALUE
+            """)
+        client = TestClient()
+        client.save({CONANFILE: conanfile,
+                     "myprofile": profile})
+        client.run("export-pkg . Hello/0.1@lasote/stable -pr=myprofile")
+        self.assertIn("Hello/0.1@lasote/stable: ENV-VALUE: MYCUSTOMVALUE!!!", client.out)
+
     def test_options_install(self):
         # https://github.com/conan-io/conan/issues/2242
         conanfile = """from conans import ConanFile
@@ -385,7 +409,8 @@ class TestConan(ConanFile):
         # Partial reference is ok
         client.save({CONANFILE: conanfile, "file.txt": "txt contents"})
         client.run("export-pkg . conan/stable")
-        self.assertIn("Hello/0.1@conan/stable package(): Packaged 1 '.txt' file: file.txt", client.out)
+        self.assertIn("Hello/0.1@conan/stable package(): Packaged 1 '.txt' file: file.txt",
+                      client.out)
 
         # Specify different name or version is not working
         client.run("export-pkg . lib/1.0@conan/stable -f", assert_error=True)
diff --git a/conans/test/functional/generators/cmake_paths_test.py b/conans/test/functional/generators/cmake_paths_test.py
index dcd9f25dc..4b90a7036 100644
--- a/conans/test/functional/generators/cmake_paths_test.py
+++ b/conans/test/functional/generators/cmake_paths_test.py
@@ -28,7 +28,7 @@ class CMakePathsGeneratorTest(unittest.TestCase):
                    '${{CMAKE_PREFIX_PATH}} ${{CMAKE_CURRENT_LIST_DIR}})'
         if platform.system() != "Windows":
             expected = expected.replace("\r", "")
-        self.assertEquals(expected.format(pfolder1=pfolder1, pfolder2=pfolder2), contents)
+        self.assertEqual(expected.format(pfolder1=pfolder1, pfolder2=pfolder2), contents)
 
     def cmake_paths_integration_test(self):
         """First package with own findHello0.cmake file"""

pip install -e .[dev]
parse_log_pytest
requirements.txt
nose nose-cov pytest
apt-get update apt-get install -y gcc g++-multilib
3.6
conans/requirements.txt conans/requirements_server.txt conans/requirements_dev.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
astroid==2.11.7
attrs==22.2.0
beautifulsoup4==4.12.3
bottle==0.12.25
certifi==2021.5.30
charset-normalizer==2.0.12
codecov==2.1.13
colorama==0.4.5
-e git+https://github.com/conan-io/conan.git@676609575971b354d97359314f5fd7c33d06f815#egg=conan
cov-core==1.15.0
coverage==4.2
deprecation==2.0.7
dill==0.3.4
distro==1.1.0
fasteners==0.19
future==0.16.0
idna==3.10
importlib-metadata==4.8.3
importlib-resources==5.4.0
iniconfig==1.1.1
isort==5.10.1
Jinja2==2.11.3
lazy-object-proxy==1.7.1
MarkupSafe==2.0.1
mccabe==0.7.0
mock==1.3.0
node-semver==0.6.1
nose==1.3.7
nose-cov==1.6
packaging==21.3
parameterized==0.8.1
patch==1.16
pbr==6.1.1
platformdirs==2.4.0
pluggy==1.0.0
pluginbase==0.7
py==1.11.0
Pygments==2.14.0
PyJWT==1.7.1
pylint==2.13.9
pyparsing==3.1.4
pytest==7.0.1
PyYAML==3.13
requests==2.27.1
six==1.17.0
soupsieve==2.3.2.post1
tomli==1.2.3
tqdm==4.64.1
typed-ast==1.5.5
typing_extensions==4.1.1
urllib3==1.26.20
waitress==2.0.0
WebOb==1.8.9
WebTest==2.0.35
wrapt==1.16.0
zipp==3.6.0

name: conan
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - astroid==2.11.7
      - attrs==22.2.0
      - beautifulsoup4==4.12.3
      - bottle==0.12.25
      - charset-normalizer==2.0.12
      - codecov==2.1.13
      - colorama==0.4.5
      - cov-core==1.15.0
      - coverage==4.2
      - deprecation==2.0.7
      - dill==0.3.4
      - distro==1.1.0
      - fasteners==0.19
      - future==0.16.0
      - idna==3.10
      - importlib-metadata==4.8.3
      - importlib-resources==5.4.0
      - iniconfig==1.1.1
      - isort==5.10.1
      - jinja2==2.11.3
      - lazy-object-proxy==1.7.1
      - markupsafe==2.0.1
      - mccabe==0.7.0
      - mock==1.3.0
      - node-semver==0.6.1
      - nose==1.3.7
      - nose-cov==1.6
      - packaging==21.3
      - parameterized==0.8.1
      - patch==1.16
      - pbr==6.1.1
      - platformdirs==2.4.0
      - pluggy==1.0.0
      - pluginbase==0.7
      - py==1.11.0
      - pygments==2.14.0
      - pyjwt==1.7.1
      - pylint==2.13.9
      - pyparsing==3.1.4
      - pytest==7.0.1
      - pyyaml==3.13
      - requests==2.27.1
      - six==1.17.0
      - soupsieve==2.3.2.post1
      - tomli==1.2.3
      - tqdm==4.64.1
      - typed-ast==1.5.5
      - typing-extensions==4.1.1
      - urllib3==1.26.20
      - waitress==2.0.0
      - webob==1.8.9
      - webtest==2.0.35
      - wrapt==1.16.0
      - zipp==3.6.0
prefix: /opt/conda/envs/conan

conans/test/functional/command/export_pkg_test.py::ExportPkgTest::test_dont_touch_server_build_require conans/test/functional/command/export_pkg_test.py::ExportPkgTest::test_profile_environment
conans/test/functional/command/export_pkg_test.py::ExportPkgTest::test_basic_0 conans/test/functional/command/export_pkg_test.py::ExportPkgTest::test_basic_1 conans/test/functional/command/export_pkg_test.py::ExportPkgTest::test_build_folders conans/test/functional/command/export_pkg_test.py::ExportPkgTest::test_build_source_folders conans/test/functional/command/export_pkg_test.py::ExportPkgTest::test_default_source_folder conans/test/functional/command/export_pkg_test.py::ExportPkgTest::test_develop conans/test/functional/command/export_pkg_test.py::ExportPkgTest::test_dont_touch_server conans/test/functional/command/export_pkg_test.py::ExportPkgTest::test_options conans/test/functional/command/export_pkg_test.py::ExportPkgTest::test_options_install conans/test/functional/command/export_pkg_test.py::ExportPkgTest::test_package_folder_errors conans/test/functional/command/export_pkg_test.py::ExportPkgTest::test_partial_references conans/test/functional/command/export_pkg_test.py::ExportPkgTest::test_transitive_without_settings conans/test/functional/command/export_pkg_test.py::ExportPkgTest::test_with_deps
conans/test/functional/command/export_pkg_test.py::ExportPkgTest::test_new conans/test/functional/command/export_pkg_test.py::ExportPkgTest::test_package_folder
conans/client/graph/graph_manager.py conans/client/cmd/export_pkg.py
conans/client/graph/graph_manager.py conans/client/cmd/export_pkg.py