🚀 The feature, motivation and pitch
Blocking #2871
Context:
The current pattern of setup.py in ExecuTorch:
- Build extensions in
CustomBuild class (extending build). Run CMake build commands to build pybind extensions. Triggered from cmdclass["build"]
- After extensions are built, run
InstallerBuildExt class to install the extension artifacts (.so etc). The class takes a list of ext_modules to learn what is the source path (normally .so files in cmake-out/) and what is the destination path in the package. ext_modules list is also controlled by the same CMake flags for custom build. This step is triggered from cmdclass["build_ext"]
- Lastly,
setup.py runsbuild_pyto copy python files to package directories. This step is triggered from cmdclass["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=ON
Problem:
The current pattern doesn’t work for editable mode. Here are the reasons:
- The
build step doesn’t even run when editable mode is on. This is causing build_ext to error out because it’s expecting the .so files to be present in the build directory but they are missing.
- We don’t want to diverge the installation behavior between editable mode on and off as much as possible. This means we don’t want to do if editable mode on do A otherwise do B.
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
🚀 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