Skip to content

Breaking Change: Removed obsolete/duplicate setup.py from Python.#15708

Merged
zhangskz merged 1 commit into26.xfrom
cp-setuppy
Feb 5, 2024
Merged

Breaking Change: Removed obsolete/duplicate setup.py from Python.#15708
zhangskz merged 1 commit into26.xfrom
cp-setuppy

Conversation

@zhangskz
Copy link
Member

@zhangskz zhangskz commented Feb 2, 2024

This copy of setup.py is obsolete, as it builds the old C++ backend for Protobuf, which has been deprecated and unused since 4.21.0 when
the backend was switch to upb.

The setup.py that we actually distribute in our source packages is located in python/dist/setup.py. It is not possible to build this setup.py directly from the GitHub repo or GitHub release tarball, because it depends on the file layout of our Python source package (as distributed on PyPI). The Python source package uses a layout that pulls together all of the things Python needs:

|Python Source Package Path|GitHub Repo Path|Description| |-----|-----|-----|
|setup.py|python/dist/setup.py|
|google/protobuf/*|python/google/protobuf/*|pure Python sources| |python/*|python/*|C extension sources|
|utf8_range/*|third_party/utf8_range|C UTF-8 Validation Library| |upb/*|upb/upb/*|C Protobuf Library|

Users who want to build their own Python packages should build from our source package on PyPI, not from our GitHub repo or our GitHub release tarball.

It is also possible to build our source package from GitHub using the following command (this requires Bazel):

$ bazel build //python/dist:source_wheel

PiperOrigin-RevId: 603162788

This copy of `setup.py` is obsolete, as it builds the old C++ backend for Protobuf, which has been deprecated and
unused since 4.21.0 when
[the backend was switch to upb](https://protobuf.dev/news/2022-05-06/#python-updates).

The `setup.py` that we actually distribute in our source packages is located in [`python/dist/setup.py`](https://github.com/protocolbuffers/protobuf/blob/main/python/dist/setup.py).  It is not possible to build this `setup.py` directly from the GitHub repo or GitHub release tarball, because it depends on the file layout of our Python source package ([as distributed on PyPI](https://pypi.org/project/protobuf/#files)).  The Python source package uses a layout that pulls together all of the things Python needs:

|Python Source Package Path|GitHub Repo Path|Description|
|-----|-----|-----|
|`setup.py`|`python/dist/setup.py`|
|`google/protobuf/*`|`python/google/protobuf/*`|pure Python sources|
|`python/*`|`python/*`|C extension sources|
|`utf8_range/*`|`third_party/utf8_range`|C UTF-8 Validation Library|
|`upb/*`|`upb/upb/*`|C Protobuf Library|

Users who want to build their own Python packages should build from our source package on PyPI, not from our GitHub repo or our GitHub release tarball.

It is also possible to build our source package from GitHub using the following command (this requires Bazel):

```
$ bazel build //python/dist:source_wheel
```

PiperOrigin-RevId: 603162788
@zhangskz zhangskz requested a review from a team as a code owner February 2, 2024 23:33
@zhangskz zhangskz requested review from ericsalo and haberman and removed request for a team and ericsalo February 2, 2024 23:33
@zhangskz zhangskz merged commit 5722aef into 26.x Feb 5, 2024
@zhangskz zhangskz deleted the cp-setuppy branch February 5, 2024 17:14
knedlsepp added a commit to knedlsepp/nixpkgs that referenced this pull request May 19, 2024
In order to enable bumping the default protobuf version from protobuf_24
to protobuf_25, we address the build failure of pythonPackages.protobuf
against that version.
Protobuf's python package is moving away from cpp backend in favor of a
µpb backend.
(See: https://github.com/protocolbuffers/protobuf/tree/main/upb)
The work on that seems to have lead to the introduction of a broken test
in "minimal_test.py":
protocolbuffers/protobuf@501ecec
I suspect that this is not an issue on the nixpkgs packaging end but
rather that this file is uncovered code upstream. I don't know enough
about Bazel to be sure, but it looks like that file is not part of their
protobuf/python/BUILD.bazel file.
(I wanted to prove that in
protocolbuffers/protobuf#16888 but couldn't
trigger upstream's CI)
So for now let's just skip that file.
Note that protobuf_26.tests.pythonProtobuf is still broken. This is due
to the fact that upstream removed support for building the library
directly from the GitHub repo. (See:
protocolbuffers/protobuf#15708)
Conda packaging is also currently struggling with this:
conda-forge/protobuf-feedstock#215

Related: NixOS#264902
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants