-
Notifications
You must be signed in to change notification settings - Fork 608
Define CMake args and environment variables simultaneously in install script #9494
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
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/9494
Note: Links to docs will display an error until the docs builds have been completed. ❌ 2 New FailuresAs of commit 553bbba with merge base e22b21a ( NEW FAILURES - The following jobs have failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem right to me. CMake pays attention to both environment variables and defined flags. We shouldn't have to set both. Can you give a specific motivating example?
The environment variable is not for CMake, it is used by the |
9d441a8
to
553bbba
Compare
OK, then I think the redundant part is putting the flags in CMAKE_ARGS? setup.py is already responsible for that, right? |
Unfortunately, setup.py doesn't fully commit to that. For example, the reason it expects some some of these flags to be defined as an env var, is so it can easily infer if it is turned on then add additional logic like putting together pybinging. In this case, it does set the cmake flag again. It wouldn't know what environment variable should be defined as a cmake arg — we would need to make that explicit mapping. Which can just be difficult to maintain. So we should continue to let CMAKE_ARGS get set. I guess we can remove the duplicate definition by splitting apart the # Before
$ EXECUTORCH_BUILD_PYBIND=ON python setup.py bdist_wheel
# After
$ CMAKE_ARGS="-DEXECUTORCH_BUILD_PYBIND=ON" python setup.py bdist_wheel I was hesitant to change this since it might break people's current usage, and might require wider CI changes. Note that technically this diff should be neutral change because it maintains the same API — is just forces consistency of the two places of definition instead of doing it manually as it is being done now. Thinking about it more, if we are okay with breaking people's current workflow of building wheels — I think I'd prefer to get rid of defining environment variables and just relying on CMAKE_ARGS. Thoughts? |
### Summary We seem to be using a combination of CMAKE_ARGS and environment variables when creating wheels. Ultimately, CMake only uses the cmake args, however we redefine some of these flags as env vars to help `setup.py` determine if a certain feature is turned on. Specifically, it looks for pybinding vars to bundle pybindings. Let's remove this redundancy and just use the CMAKE_ARGS as the single source of truth. For more details and other considerations, see #9494 (abandoned). Note that even in the wheel building jobs, we use cmake args instead of environment variables to control features: https://github.com/pytorch/executorch/blob/644b7ddf14180d97e348faa627f576e13d367d69/.ci/scripts/wheel/envvar_base.sh#L20 https://github.com/pytorch/executorch/blob/644b7ddf14180d97e348faa627f576e13d367d69/.ci/scripts/wheel/envvar_macos.sh#L14-L15 ### Test plan build + check CMakeCache.txt to ensure flags are set ```bash # Expected: EXECUTORCH_BUILD_PYBIND=OFF EXECUTORCH_BUILD_XNNPACK=OFF EXECUTORCH_BUILD_COREML=OFF $ rm -rf pip-out dist && ./install_executorch.sh --pybind off # Expected: EXECUTORCH_BUILD_PYBIND=ON EXECUTORCH_BUILD_XNNPACK=ON EXECUTORCH_BUILD_COREML=OFF $ rm -rf pip-out dist && ./install_executorch.sh # Expected: EXECUTORCH_BUILD_PYBIND=ON EXECUTORCH_BUILD_XNNPACK=OFF EXECUTORCH_BUILD_COREML=ON $ rm -rf pip-out dist && ./install_executorch.sh --pybind coreml # Expected: EXECUTORCH_BUILD_PYBIND=ON EXECUTORCH_BUILD_XNNPACK=ON EXECUTORCH_BUILD_COREML=ON $ rm -rf pip-out dist && ./install_executorch.sh --pybind xnnpack coreml # Throws an error $ rm -rf pip-out dist && ./install_executorch.sh --pybind coreml off ``` cc @larryliu0820 @lucylq
### Summary We seem to be using a combination of CMAKE_ARGS and environment variables when creating wheels. Ultimately, CMake only uses the cmake args, however we redefine some of these flags as env vars to help `setup.py` determine if a certain feature is turned on. Specifically, it looks for pybinding vars to bundle pybindings. Let's remove this redundancy and just use the CMAKE_ARGS as the single source of truth. For more details and other considerations, see #9494 (abandoned). Note that even in the wheel building jobs, we use cmake args instead of environment variables to control features: https://github.com/pytorch/executorch/blob/644b7ddf14180d97e348faa627f576e13d367d69/.ci/scripts/wheel/envvar_base.sh#L20 https://github.com/pytorch/executorch/blob/644b7ddf14180d97e348faa627f576e13d367d69/.ci/scripts/wheel/envvar_macos.sh#L14-L15 ### Test plan build + check CMakeCache.txt to ensure flags are set ```bash # Expected: EXECUTORCH_BUILD_PYBIND=OFF EXECUTORCH_BUILD_XNNPACK=OFF EXECUTORCH_BUILD_COREML=OFF $ rm -rf pip-out dist && ./install_executorch.sh --pybind off # Expected: EXECUTORCH_BUILD_PYBIND=ON EXECUTORCH_BUILD_XNNPACK=ON EXECUTORCH_BUILD_COREML=OFF $ rm -rf pip-out dist && ./install_executorch.sh # Expected: EXECUTORCH_BUILD_PYBIND=ON EXECUTORCH_BUILD_XNNPACK=OFF EXECUTORCH_BUILD_COREML=ON $ rm -rf pip-out dist && ./install_executorch.sh --pybind coreml # Expected: EXECUTORCH_BUILD_PYBIND=ON EXECUTORCH_BUILD_XNNPACK=ON EXECUTORCH_BUILD_COREML=ON $ rm -rf pip-out dist && ./install_executorch.sh --pybind xnnpack coreml # Throws an error $ rm -rf pip-out dist && ./install_executorch.sh --pybind coreml off ``` cc @larryliu0820 @lucylq
Summary
This script currently configures CMAKE_ARGS, that is eventually propagated to the underlying cmake build (via pip install). However, notice how for some args, we also define an equivalent envvar. This is primarily for the pip setup script:
executorch/setup.py
Lines 72 to 98 in 78ee0e6
So there is an implicit expectation that if you want to access these definitions in the setup script, you need to make sure to also define the envvar along with the cmake args. Well, it took me more than an hour to figure out why my cmake args wasn't being recognized in the setup script 🤦 . So, to make sure consistency — let's force setting args and envvars simultaneously.
Test plan
build + check CMakeCache.txt to ensure flags are set
cc @larryliu0820 @lucylq