Skip to content

Commit 65eb28d

Browse files
committed
New pip build system
Summary: Compatible with `pythom -m build` instead of using the deprecated `python setup.py bdist_wheel`. A new custom build command builds all CMake targets, and a new custom build_ext command installs built files into the wheel. A new custom build_py command copies platform-independent files into the wheel instead of copying them into the source tree. Puts all generated files under pip-out instead of mixing with files in the tree. Uses Command methods like `mkpath` and `copy_file` to benefit from setuptools concepts like dry_run, and to get logging for free. Adds `flatc` to the wheel, but doesn't yet make it available on the path. Test Plan: Iteration command to test wheel building without completely rebuilding the system: ``` rm -rf \ /tmp/wheel-out \ pip-out/lib* \ pip-out/bdist.* \ pip-out/temp.*/cmake-out/CMake* \ executorch.egg-info \ third-party/flatcc/{bin,lib} \ ; \ python -m build \ --wheel --outdir /tmp/wheel-out --no-isolation ``` To fully rebuild the system, also `rm -rf pip-out`. The wheel file is written to (e.g.) ``` /tmp/wheel-out/executorch-0.1.0-cp310-cp310-linux_x86_64.whl ``` Examine it with `unzip -l`, or install it with `pip install /tmp/wheel-out/executorch*.whl`. Reviewers: Subscribers: Tasks: Tags:
1 parent 4c99948 commit 65eb28d

File tree

12 files changed

+326
-174
lines changed

12 files changed

+326
-174
lines changed

.gitignore

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,8 @@ cmake-android-out/
55
cmake-ios-out/
66
ethos-u-scratch/
77
executorch.egg-info
8+
pip-out/
89
__pycache__/
9-
build/lib/
10-
exir/_serialize/scalar_type.fbs
11-
exir/_serialize/program.fbs
12-
sdk/bundled_program/serialize/bundled_program_schema.fbs
13-
sdk/bundled_program/serialize/scalar_type.fbs
1410

1511
# Any exported models and profiling outputs
1612
*.pte

CMakeLists.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -326,10 +326,10 @@ endif()
326326
# ${CMAKE_INSTALL_PREFIX}/
327327
install(
328328
TARGETS executorch
329-
DESTINATION lib
329+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
330330
INCLUDES
331331
DESTINATION ${_common_include_directories})
332-
install(FILES build/executorch-config.cmake DESTINATION lib/cmake/ExecuTorch)
332+
install(FILES build/executorch-config.cmake DESTINATION share/cmake/executorch)
333333

334334
#
335335
# executor_runner: Host tool that demonstrates program execution.
@@ -489,9 +489,6 @@ if(EXECUTORCH_BUILD_PYBIND)
489489
${PYBIND_LINK_MPS}
490490
${PYBIND_LINK_XNNPACK}
491491
)
492-
493-
install(TARGETS portable_lib
494-
LIBRARY DESTINATION executorch/extension/pybindings)
495492
endif()
496493

497494
# Print all summary

backends/apple/mps/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,6 @@ target_link_libraries(mpsdelegate
7777

7878
install(
7979
TARGETS mpsdelegate
80-
DESTINATION lib
80+
DESTINATION ${CMAKE_INSTALL_LIBDIR}
8181
INCLUDES
8282
DESTINATION ${_common_include_directories})

backends/qualcomm/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ add_subdirectory(
280280
${QNN_EXECUTORCH_ROOT_DIR}/aot/ir
281281
${CMAKE_CURRENT_BINARY_DIR}/qnn_executorch/ir
282282
)
283-
install(TARGETS qnn_executorch_backend DESTINATION lib)
283+
install(TARGETS qnn_executorch_backend DESTINATION ${CMAKE_INSTALL_LIBDIR})
284284

285285
# QNN pybind
286286
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64")

extension/data_loader/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ target_compile_options(extension_data_loader PUBLIC ${_common_compile_options})
2525
# Install libraries
2626
install(
2727
TARGETS extension_data_loader
28-
DESTINATION ${CMAKE_BINARY_DIR}/lib
28+
DESTINATION ${CMAKE_INSTALL_LIBDIR}
2929
INCLUDES
3030
DESTINATION ${_common_include_directories})

extension/module/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ target_compile_options(extension_module PUBLIC -Wno-deprecated-declarations
3232
# Install libraries
3333
install(
3434
TARGETS extension_module
35-
DESTINATION lib
35+
DESTINATION ${CMAKE_INSTALL_LIBDIR}
3636
INCLUDES
3737
DESTINATION ${_common_include_directories})

extension/runner_util/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ target_compile_options(extension_runner_util PUBLIC ${_common_compile_options})
2727
# Install libraries
2828
install(
2929
TARGETS extension_runner_util
30-
DESTINATION ${CMAKE_BINARY_DIR}/lib
30+
DESTINATION ${CMAKE_INSTALL_LIBDIR}
3131
INCLUDES
3232
DESTINATION ${_common_include_directories})

install_requirements.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ pip install --force-reinstall --pre transformers==${TRANSFORMERS_VERSION}
6969
TORCHSR_VERSION=1.0.4
7070
pip install --pre torchsr==${TORCHSR_VERSION}
7171

72+
echo STOP # @nocommit
73+
exit 1
7274
# Install ExecuTorch after dependencies are installed.
7375
EXECUTORCH_BUILD_PYBIND="$EXECUTORCH_BUILD_PYBIND" \
7476
CMAKE_ARGS="$CMAKE_ARGS" \

kernels/portable/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,5 @@ gen_operators_lib(
6464
KERNEL_LIBS portable_kernels
6565
DEPS executorch)
6666

67-
install(TARGETS portable_kernels portable_ops_lib DESTINATION lib)
67+
install(TARGETS portable_kernels portable_ops_lib
68+
DESTINATION ${CMAKE_INSTALL_LIBDIR})

pyproject.toml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
[build-system]
2-
requires = ["setuptools", "wheel"]
2+
requires = [
3+
"setuptools",
4+
"wheel",
5+
# @nocommit: insted we're using --no-isolation
6+
# "tomli", # Needed by extract_sources.py
7+
# # @nocommit: this will be the wrong torch; it's not the nightly
8+
# "torch", # Provides TorchConfig.cmake
9+
# "ruamel.yaml", # Needed by gen_oplist.py
10+
]
311
build-backend = "setuptools.build_meta"
412

513
[project]
@@ -26,10 +34,13 @@ dependencies=[
2634
]
2735

2836
[tool.setuptools.package-data]
29-
"*" = ["*.fbs", "*.yaml"]
37+
# @nocommit: prune /test[s]/ dirs, /third-party/ dirs
38+
# @nocommit: yaml only for kernels?
39+
"*" = ["*.yaml"]
3040

3141
[tool.setuptools.exclude-package-data]
3242
"*" = ["*.pyc"]
3343

3444
[tool.usort]
45+
# Do not try to put "first-party" imports in their own section.
3546
first_party_detection = false

sdk/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,6 @@ target_include_directories(
173173
# Install libraries
174174
install(
175175
TARGETS bundled_program etdump flatccrt
176-
DESTINATION ${CMAKE_BINARY_DIR}/lib
176+
DESTINATION ${CMAKE_INSTALL_LIBDIR}
177177
INCLUDES
178178
DESTINATION ${_common_include_directories})

0 commit comments

Comments
 (0)