[build] modernize build-backend: setuptools.build_meta:__legacy__ -> setuptools.build_meta#155998
[build] modernize build-backend: setuptools.build_meta:__legacy__ -> setuptools.build_meta#155998XuehaiPan wants to merge 45 commits intogh/XuehaiPan/279/basefrom
setuptools.build_meta:__legacy__ -> setuptools.build_meta#155998Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/155998
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit fc23e9c with merge base a6fab82 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
MANIFEST.in
Outdated
| include WORKSPACE | ||
| include requirements.txt | ||
| include version.txt | ||
| include .gitmodules |
There was a problem hiding this comment.
Buillding from sdist works with only .gitmodules?
There was a problem hiding this comment.
I guess .gitmodules is not required because we will need to build under a git clone anyway.
One solution is to ship .gitmodules in the SDist and initialize an empty git folder to allow submodule cloning:
# in setup.py
if not os.path.exists(os.path.join(cwd, '.git')):
subprocesses.check_call(['git', 'init'], cwd=cwd)
subprocesses.check_call(['git', 'add', '.'], cwd=cwd)
subprocesses.check_call(['git', 'commit', '-m', 'init for building from sdist'], cwd=cwd)
subprocesses.check_call(['git', 'submodule', 'update', '--init', '--recursive'], cwd=cwd)There was a problem hiding this comment.
The sdist should include all submodules. It looks to me like this is already included (since third_party is explicitly included) in gh-152098. .gitmodules should then not be required.
| graft torchgen | ||
| # FIXME: torch-xla codegen build failure if include this file in wheel | ||
| exclude torchgen/BUILD.bazel |
There was a problem hiding this comment.
torch_xla/csrc/BUILD genrule command (from target //torch_xla/csrc:gen_lazy_tensor) cannot import torchgen if this file is present in site-packages/torchgen/BUILD.bazel. cc @qihqi
The following fix will not resolve the import issue.
CI failure before pytorch/xla#9310: https://hud.pytorch.org/pr/pytorch/pytorch/153538#43672158222
CI failure after pytorch/xla#9310: https://hud.pytorch.org/pr/pytorch/pytorch/153538#44066727613
…> `setuptools.build_meta` Change `build-system.build-backend`: `setuptools.build_meta:__legacy__` -> `setuptools.build_meta`. Also, move static package info from `setup.py` to `pyproject.toml`. Now the repo can be installed from source via `pip` command instead of `python setup.py develop`: ```bash python -m pip install --verbose --editable . python -m pip install --verbose --no-build-isolation --editable . ``` In addition, the SDist is also buildable: ```bash python -m build --sdist python -m install dist/torch-*.tar.gz # build from source using SDist ``` ghstack-source-id: 6dbd393 Pull-Request: pytorch#155998
|
@XuehaiPan We are sure this doesn't break s3cache, right (with the temporary build dir)? |
|
uv also support --no-build-isolation flag in pyproject.toml (unlike pip). Maybe we should add an entry for it. |
| ] | ||
| # Use legacy backend to import local packages in setup.py | ||
| build-backend = "setuptools.build_meta:__legacy__" | ||
| build-backend = "setuptools.build_meta" |
There was a problem hiding this comment.
Ultimately, this still builds under build isolation which is a big gotcha for the CI. Can we migrate to legacy scikit-build? That at least does a lot of stuff to effectively disable build isolation by default.
There was a problem hiding this comment.
I'm not sure I understand this comment. It doesn't seem like a good idea to migrate to another legacy tool. Build isolation can be confusing for users when they're not that experienced, but for better or worse it is how Python packaging works. I don't see a reason to try hard to subvert that.
There was a problem hiding this comment.
Scikit-build-core works too, but I'm not sure how stable the setup tools shim is for it.
| BUILD_LIBTORCH_WHL = os.getenv("BUILD_LIBTORCH_WHL", "0") == "1" | ||
| BUILD_PYTHON_ONLY = os.getenv("BUILD_PYTHON_ONLY", "0") == "1" | ||
|
|
||
| # Also update `project.requires-python` in pyproject.toml when changing this |
There was a problem hiding this comment.
It would be great if we could detect build isolation and raise a warning
There was a problem hiding this comment.
I don't think it's possible, nor is it desirable - it's perfectly valid for example for a packager to build with python -m build --wheel.
|
@rgommers Main reason to subvert build isolation is the multi-hour build times of pytorch when building from src. |
I'm not sure I understand what you mean. Yes building PyTorch is quite slow, but whether or not one uses build isolation or not has no impact on build time. |
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Merge failedReason: 1 mandatory check(s) failed. The first few are: Dig deeper by viewing the failures on hud |
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
|
The merge job was canceled or timed out. This most often happen if two merge requests were issued for the same PR, or if merge job was waiting for more than 6 hours for tests to finish. In later case, please do not hesitate to reissue the merge command |
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
|
@pytorchbot revert -m "Broke inductor_cpp, wrapper see https://hud.pytorch.org/hud/pytorch/pytorch/e472daa80963aae389089f9dc324b04261e2a5ef/1?per_page=50&name_filter=inductor_cpp_" -c nosignal |
|
@pytorchbot successfully started a revert job. Check the current status here. |
|
@XuehaiPan your PR has been successfully reverted. |
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Stack from ghstack (oldest at bottom):
setuptools<80.0#156049python setup.py develop/install->[uv ]pip install --no-build-isolation [-e ].#156027setuptools.build_meta:__legacy__->setuptools.build_meta#155998Change
build-system.build-backend:setuptools.build_meta:__legacy__->setuptools.build_meta. Also, move static package info fromsetup.pytopyproject.toml.Now the repo can be installed from source via
pipcommand instead ofpython setup.py develop:In addition, the SDist is also buildable:
Note that we should build the SDist with a fresh git clone if we will upload the output to PyPI. Because all files under
third_partywill be included in the SDist. The SDist file will be huge if the git submodules are initialized.cc @seemethere @malfet @osalpekar @atalman