From b951d2b241bf7f60f977e1c70fd14a4f3cb55145 Mon Sep 17 00:00:00 2001 From: vmoens Date: Thu, 8 Jan 2026 10:01:01 +0000 Subject: [PATCH 1/3] Update [ghstack-poisoned] --- setup.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index f0e4408bbcd..424fd093db9 100644 --- a/setup.py +++ b/setup.py @@ -18,6 +18,20 @@ logger = logging.getLogger(__name__) ROOT_DIR = Path(__file__).parent.resolve() + + +def _check_pybind11(): + """Check that pybind11 is installed and provide a clear error message if not.""" + if importlib.util.find_spec("pybind11") is None: + raise RuntimeError( + "pybind11 is required to build TorchRL's C++ extensions but was not found.\n" + "Please install it with:\n" + " pip install 'pybind11[global]'\n" + "Then re-run the installation." + ) + + +_check_pybind11() _RELEASE_BRANCH_RE = re.compile(r"^release/v(?P.+)$") _BUILD_INFO_FILE = ROOT_DIR / "build" / ".torchrl_build_info.json" @@ -47,13 +61,14 @@ def _check_and_clean_stale_builds(): f"Python {old_python} -> {current_python_version}. " f"Cleaning stale build artifacts..." ) - # Clean stale .so files for current Python version - so_pattern = ( + # Clean stale extension files for current Python version + ext = ".pyd" if sys.platform == "win32" else ".so" + ext_pattern = ( ROOT_DIR / "torchrl" - / f"_torchrl.cpython-{sys.version_info.major}{sys.version_info.minor}*.so" + / f"_torchrl.cpython-{sys.version_info.major}{sys.version_info.minor}*{ext}" ) - for so_file in glob.glob(str(so_pattern)): + for so_file in glob.glob(str(ext_pattern)): logger.warning(f"Removing stale: {so_file}") os.remove(so_file) # Clean build directory From 0483926198ef61b49317f35ad06cf33fae533ac5 Mon Sep 17 00:00:00 2001 From: vmoens Date: Thu, 8 Jan 2026 10:19:18 +0000 Subject: [PATCH 2/3] Update [ghstack-poisoned] --- .../linux_olddeps/scripts_gym_0_13/environment.yml | 1 + setup.py | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/unittest/linux_olddeps/scripts_gym_0_13/environment.yml b/.github/unittest/linux_olddeps/scripts_gym_0_13/environment.yml index 84cce31cfe6..7b8216d3828 100644 --- a/.github/unittest/linux_olddeps/scripts_gym_0_13/environment.yml +++ b/.github/unittest/linux_olddeps/scripts_gym_0_13/environment.yml @@ -28,3 +28,4 @@ dependencies: - av - h5py - numpy<2.0.0 + - pybind11[global] diff --git a/setup.py b/setup.py index 424fd093db9..6381cc57600 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,14 @@ def _check_pybind11(): - """Check that pybind11 is installed and provide a clear error message if not.""" + """Check that pybind11 is installed and provide a clear error message if not. + + Only checks when actually building extensions, not for commands like 'clean'. + """ + # Commands that don't require building C++ extensions + skip_commands = {"clean", "egg_info", "sdist", "--version", "--help", "-h"} + if skip_commands.intersection(sys.argv): + return if importlib.util.find_spec("pybind11") is None: raise RuntimeError( "pybind11 is required to build TorchRL's C++ extensions but was not found.\n" From d91e2c2c5de1afd1fd1fdffd9483d38487a267a1 Mon Sep 17 00:00:00 2001 From: vmoens Date: Thu, 8 Jan 2026 14:12:19 +0000 Subject: [PATCH 3/3] Update [ghstack-poisoned] --- test/compile/{test_collectors.py => test_compile_collectors.py} | 0 test/compile/{test_objectives.py => test_compile_objectives.py} | 0 test/compile/{test_utils.py => test_compile_utils.py} | 0 test/compile/{test_value.py => test_compile_value.py} | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename test/compile/{test_collectors.py => test_compile_collectors.py} (100%) rename test/compile/{test_objectives.py => test_compile_objectives.py} (100%) rename test/compile/{test_utils.py => test_compile_utils.py} (100%) rename test/compile/{test_value.py => test_compile_value.py} (100%) diff --git a/test/compile/test_collectors.py b/test/compile/test_compile_collectors.py similarity index 100% rename from test/compile/test_collectors.py rename to test/compile/test_compile_collectors.py diff --git a/test/compile/test_objectives.py b/test/compile/test_compile_objectives.py similarity index 100% rename from test/compile/test_objectives.py rename to test/compile/test_compile_objectives.py diff --git a/test/compile/test_utils.py b/test/compile/test_compile_utils.py similarity index 100% rename from test/compile/test_utils.py rename to test/compile/test_compile_utils.py diff --git a/test/compile/test_value.py b/test/compile/test_compile_value.py similarity index 100% rename from test/compile/test_value.py rename to test/compile/test_compile_value.py