-
Notifications
You must be signed in to change notification settings - Fork 607
New pip build system #2499
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
New pip build system #2499
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/2499
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New Failure, 1 Unrelated FailureAs of commit fddd6c8 with merge base db7c057 ( NEW FAILURE - The following job has failed:
FLAKY - The following job failed but was likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
I still need to clean this up, but now that it's sort of working I'd like to get some eyes on it. There's a lot going on here that's hard to separate, since it's a rewrite of setup.py. Haven't tried it in CI yet so I bet things are broken. |
5b56340
to
b41035e
Compare
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.
Thanks for putting this up! It would be great if you can paste the temp directory tree structure and also things in the wheel so that we know what's inside.
exir/_serialize/scalar_type.fbs | ||
exir/_serialize/program.fbs | ||
sdk/bundled_program/serialize/bundled_program_schema.fbs | ||
sdk/bundled_program/serialize/scalar_type.fbs |
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.
Oh nice finding we probably don't want to ignore all these
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.
We needed to before this, because setup.py copied them directly into the source tree.
CMakeLists.txt
Outdated
@@ -301,10 +301,10 @@ endif() | |||
# ${CMAKE_INSTALL_PREFIX}/ | |||
install( | |||
TARGETS executorch | |||
DESTINATION lib | |||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} |
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.
Does CMake provide a default value for CMAKE_INSTALL_LIBDIR
or we need to always pass in a value
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.
Yeah it defaults to lib
but can be lib64
in some situations, or a big ProgramFiles path on windows. So this is more portable then just saying lib
.
install_requirements.sh
Outdated
echo STOP # @nocommit | ||
exit 1 |
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.
remove this?
pyproject.toml
Outdated
requires = [ | ||
"setuptools", | ||
"wheel", | ||
# @nocommit: insted we're using --no-isolation |
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.
Yeah is there a way to force --no-build-isolation
in pip install?
# | ||
# See build.initialize_options() in | ||
# setuptools/_distutils/command/build.py for the default. | ||
self.build_base = "pip-out" |
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.
so one thing I noticed in the previous pip install experience, is that the build base directory name contains useful information such as python version and os arch. Do we still have that in the new directory name?
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.
Yeah, this just moves the root from build/...
to pip-out/...
so it doesn't sit on top of our existing build/
directory. All of the platform-based directories live under this.
e4a18ec
to
9b5e454
Compare
Here's the listing from the latest version: https://gist.github.com/dbort/4a79eac7e1d1ebe7306f437bb2583482 The
Oh whoops looks like I need to update liboptimized_native_cpu_ops_lib.a to use the proper LIBDIR. (lib64 is the LIBDIR value picked by the GNU Coding Conventions when building on my x86_64 machine) |
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.
Not sure if ci is reliable at this stage..
42282fb
to
64748f5
Compare
d4caf74
to
2dc73ea
Compare
@dbort has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@dbort has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@dbort has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@dbort has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
|
||
# Default build parallelism based on number of cores, but allow | ||
# overriding through the environment. | ||
default_parallel = str(os.cpu_count() - 1) |
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 is nice QOL change. This should speed up builds significantly on higher core count systems.
This looks great. Thanks for taking all of this on. |
ba122bd
to
98a17b3
Compare
@dbort has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Summary: Compatible with `pythom -m build` instead of using the deprecated `python setup.py bdist_wheel`. A new custom build command builds all necessary 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 and installs a wrapper to 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 setup.py bdist_wheel --dist-dir /tmp/wheel-out ``` 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`.
@dbort has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Summary:
Compatible with
python -m build -wheel
instead of using the deprecatedpython 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
andcopy_file
to benefit from setuptools concepts like dry_run, and to get logging for free.Adds
flatc
to the wheel and puts it on the user's PATH. Removes the call toinstall_flatc.sh
ininstall_requirements.sh
; but, leaves the script in place since someone might want to run it on their own.Also:
-fPIC
requirement when building theflatcc
host tools${arg^^}
, which doesn't work with older versions of bashTest Plan:
Iteration command to test wheel building without completely rebuilding the system:
To fully rebuild the system, also
rm -rf pip-out
.The wheel file is written to (e.g.)
Examine it with
unzip -l
, or install it withpip install /tmp/wheel-out/executorch*.whl
.Also tested creating the wheel via
install_requirements.sh
and creating a simple model file.Also tested that it can build pybindings with xnnpack when invoked via
install_requirements.sh
:Builds successfully, but trying to run the test currently fails during xnnpack init() due to T184024365. But it fails in the same way that the main branch does, so this new diff does not regress.
Reviewers:
Subscribers:
Tasks:
Tags: