-
Notifications
You must be signed in to change notification settings - Fork 960
Refactor setup.py to support editable mode #8379
Copy link
Copy link
Closed
Labels
module: build/installIssues related to the cmake and buck2 builds, and to installing ExecuTorchIssues related to the cmake and buck2 builds, and to installing ExecuTorchmodule: user experienceIssues related to reducing friction for usersIssues related to reducing friction for userstriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module
Milestone
Metadata
Metadata
Assignees
Labels
module: build/installIssues related to the cmake and buck2 builds, and to installing ExecuTorchIssues related to the cmake and buck2 builds, and to installing ExecuTorchmodule: user experienceIssues related to reducing friction for usersIssues related to reducing friction for userstriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module
Type
Projects
Status
Done
Status
Done
🚀 The feature, motivation and pitch
Blocking #2871
Context:
The current pattern of setup.py in ExecuTorch:
CustomBuildclass (extendingbuild). Run CMake build commands to build pybind extensions. Triggered fromcmdclass["build"]InstallerBuildExtclass to install the extension artifacts (.so etc). The class takes a list ofext_modulesto learn what is the source path (normally .so files in cmake-out/) and what is the destination path in the package.ext_moduleslist is also controlled by the same CMake flags for custom build. This step is triggered fromcmdclass["build_ext"]setup.pyrunsbuild_pyto copy python files to package directories. This step is triggered fromcmdclass["build_py"].This pattern is different from the common pattern, but it works without issue.
Assumption:
We want to support editable mode (
pip install -e .). In editable installation we should perform the exact same installation steps as normal mode, respecting the same options as normal mode.For example, the plain command
Should install portable_lib extension because by default
EXECUTORCH_BUILD_PYBIND=ONProblem:
The current pattern doesn’t work for editable mode. Here are the reasons:
buildstep doesn’t even run when editable mode is on. This is causingbuild_extto error out because it’s expecting the .so files to be present in the build directory but they are missing.Proposal:
Move the python extension installation step (CMake commands) into one of
ext_modules.Alternatives
No response
Additional context
No response
RFC (Optional)
No response
cc @mergennachin @byjlw @SS-JIA @manuelcandales