-
Notifications
You must be signed in to change notification settings - Fork 24.9k
[build] modernize build-backend: setuptools.build_meta:__legacy__
-> setuptools.build_meta
#155998
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/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. |
…> `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
MANIFEST.in
Outdated
include WORKSPACE | ||
include requirements.txt | ||
include version.txt | ||
include .gitmodules |
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.
Buillding from sdist works with only .gitmodules
?
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
MANIFEST.in
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
@@ -38,9 +16,56 @@ requires = [ | |||
"typing-extensions>=4.10.0", | |||
"requests", | |||
] | |||
# 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be great if we could detect build isolation and raise a warning
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.
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
.
@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. |
…acy__` -> `setuptools.build_meta` (#155998)" This reverts commit 404008e. Reverted #155998 on behalf of https://github.com/malfet due to Broke inductor_cpp, wrapper see https://hud.pytorch.org/hud/pytorch/pytorch/e472daa80963aae389089f9dc324b04261e2a5ef/1?per_page=50&name_filter=inductor_cpp_ ([comment](#155998 (comment)))
@XuehaiPan your PR has been successfully reverted. |
…> `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: f0c9fda Pull-Request: pytorch#155998
…> `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: f0c9fda Pull-Request: pytorch#155998
…> `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: 9a2a960 Pull-Request: pytorch#155998
…> `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: 58b5296 Pull-Request: pytorch#155998
…> `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: 58b5296 Pull-Request: pytorch#155998
…> `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: 3f1f3b1 Pull-Request: pytorch#155998
…> `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: 2e61e35 Pull-Request: pytorch#155998
@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.py
topyproject.toml
.Now the repo can be installed from source via
pip
command 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_party
will be included in the SDist. The SDist file will be huge if the git submodules are initialized.cc @seemethere @malfet @osalpekar @atalman