Skip to content

Optionally move setup.py/pip cmake-out to repo_root/cmake-out #7720

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .ci/scripts/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ install_executorch() {
# Install executorch, this assumes that Executorch is checked out in the
# current directory.
if [[ "${1:-}" == "use-pt-pinned-commit" ]]; then
./install_executorch.sh --pybind xnnpack --use-pt-pinned-commit
EXECUTORCH_USE_SHARED_CMAKE_OUT_FOR_SETUP=1 ./install_executorch.sh --pybind xnnpack --use-pt-pinned-commit
else
./install_executorch.sh --pybind xnnpack
EXECUTORCH_USE_SHARED_CMAKE_OUT_FOR_SETUP=1 ./install_executorch.sh --pybind xnnpack
fi
# Just print out the list of packages for debugging
pip list
Expand Down
15 changes: 0 additions & 15 deletions .github/workflows/pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,6 @@ jobs:

PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "cmake"

# install pybind
bash install_executorch.sh --pybind xnnpack --use-pt-pinned-commit

# install Llava requirements
bash examples/models/llama/install_requirements.sh
bash examples/models/llava/install_requirements.sh
Expand Down Expand Up @@ -483,9 +480,6 @@ jobs:

PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "cmake"

# install pybind
bash install_executorch.sh --pybind xnnpack --use-pt-pinned-commit

# install phi-3-mini requirements
bash examples/models/phi-3-mini/install_requirements.sh

Expand Down Expand Up @@ -513,9 +507,6 @@ jobs:

PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "cmake"

# install pybind
bash install_executorch.sh --pybind xnnpack --use-pt-pinned-commit

# install llama requirements
bash examples/models/llama/install_requirements.sh

Expand Down Expand Up @@ -543,9 +534,6 @@ jobs:

PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "cmake"

# install pybind
bash install_executorch.sh --pybind xnnpack --use-pt-pinned-commit

# install llama requirements
bash examples/models/llama/install_requirements.sh

Expand Down Expand Up @@ -573,9 +561,6 @@ jobs:

PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "cmake"

# install pybind
bash install_executorch.sh --pybind xnnpack --use-pt-pinned-commit

# install llama requirements
bash examples/models/llama/install_requirements.sh

Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/trunk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,9 @@ jobs:
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
conda activate "${CONDA_ENV}"

source .ci/scripts/utils.sh
install_executorch "use-pt-pinned-commit"
# Intentionally avoiding utils.sh install_executorch because
# it opts into shared cmake-out, which breaks these builds.
./install_executorch.py --pybind xnnpack --use-pt-pinned-commit

.ci/scripts/setup-arm-baremetal-tools.sh

Expand Down Expand Up @@ -179,8 +180,9 @@ jobs:
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
conda activate "${CONDA_ENV}"

source .ci/scripts/utils.sh
install_executorch "use-pt-pinned-commit"
# Intentionally avoiding utils.sh install_executorch because
# it opts into shared cmake-out, which breaks these builds.
./install_executorch.py --pybind xnnpack --use-pt-pinned-commit

.ci/scripts/setup-arm-baremetal-tools.sh

Expand Down
20 changes: 15 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,11 @@ def src_path(self, installer: "InstallerBuildExt") -> Path:
srcs = tuple(cmake_cache_dir.glob(self.src))
if len(srcs) != 1:
raise ValueError(
f"""Expected exactly one file matching '{self.src}'; found {repr(srcs)}.
f"""Expected exactly one file matching '{self.src}'; found {repr(srcs)}.

If that file is a CMake-built extension module file, and we are installing in editable mode, please disable the corresponding build option since it's not supported yet.

Try:
Try:

EXECUTORCH_BUILD_FLATC=OFF EXECUTORCH_BUILD_KERNELS_CUSTOM_AOT=OFF pip install -e .
"""
Expand Down Expand Up @@ -611,9 +611,19 @@ def run(self):
# for multi-config generators.
build_args += ["--config", cfg]

# Put the cmake cache under the temp directory, like
# "pip-out/temp.<plat>/cmake-out".
cmake_cache_dir = os.path.join(repo_root, self.build_temp, "cmake-out")
if ShouldBuild._is_env_enabled("EXECUTORCH_USE_SHARED_CMAKE_OUT_FOR_SETUP"):
# Share the cmake-out directory with any other cmake builds the
# user/developer might do, rather than hiding it under build_temp.
#
# Opt-in because there is a risk of accidentally mixing built artifacts from
# different build configurations, which could lead to painful debugging
# sessions. The upside is faster incremental cmake builds after running
# install_executorch.sh.
cmake_cache_dir = os.path.join(repo_root, "cmake-out")
else:
# Put the cmake cache under the temp directory, like
# "pip-out/temp.<plat>/cmake-out".
cmake_cache_dir = os.path.join(repo_root, self.build_temp, "cmake-out")
self.mkpath(cmake_cache_dir)

# Generate the cmake cache from scratch to ensure that the cache state
Expand Down
Loading