|
18 | 18 | logger = logging.getLogger(__name__) |
19 | 19 |
|
20 | 20 | ROOT_DIR = Path(__file__).parent.resolve() |
21 | | - |
22 | | - |
23 | | -def _check_pybind11(): |
24 | | - """Check that pybind11 is installed and provide a clear error message if not. |
25 | | -
|
26 | | - Only checks when actually building extensions, not for commands like 'clean'. |
27 | | - """ |
28 | | - # Commands that don't require building C++ extensions |
29 | | - skip_commands = {"clean", "egg_info", "sdist", "--version", "--help", "-h"} |
30 | | - if skip_commands.intersection(sys.argv): |
31 | | - return |
32 | | - if importlib.util.find_spec("pybind11") is None: |
33 | | - raise RuntimeError( |
34 | | - "pybind11 is required to build TorchRL's C++ extensions but was not found.\n" |
35 | | - "Please install it with:\n" |
36 | | - " pip install 'pybind11[global]'\n" |
37 | | - "Then re-run the installation." |
38 | | - ) |
39 | | - |
40 | | - |
41 | | -_check_pybind11() |
42 | 21 | _RELEASE_BRANCH_RE = re.compile(r"^release/v(?P<release_id>.+)$") |
43 | 22 | _BUILD_INFO_FILE = ROOT_DIR / "build" / ".torchrl_build_info.json" |
44 | 23 |
|
@@ -68,14 +47,13 @@ def _check_and_clean_stale_builds(): |
68 | 47 | f"Python {old_python} -> {current_python_version}. " |
69 | 48 | f"Cleaning stale build artifacts..." |
70 | 49 | ) |
71 | | - # Clean stale extension files for current Python version |
72 | | - ext = ".pyd" if sys.platform == "win32" else ".so" |
73 | | - ext_pattern = ( |
| 50 | + # Clean stale .so files for current Python version |
| 51 | + so_pattern = ( |
74 | 52 | ROOT_DIR |
75 | 53 | / "torchrl" |
76 | | - / f"_torchrl.cpython-{sys.version_info.major}{sys.version_info.minor}*{ext}" |
| 54 | + / f"_torchrl.cpython-{sys.version_info.major}{sys.version_info.minor}*.so" |
77 | 55 | ) |
78 | | - for so_file in glob.glob(str(ext_pattern)): |
| 56 | + for so_file in glob.glob(str(so_pattern)): |
79 | 57 | logger.warning(f"Removing stale: {so_file}") |
80 | 58 | os.remove(so_file) |
81 | 59 | # Clean build directory |
|
0 commit comments