Skip to content

Commit 5722aef

Browse files
zhangskzhaberman
andauthored
Breaking Change: Removed obsolete/duplicate setup.py from Python. (#15708)
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 Co-authored-by: Joshua Haberman <[email protected]>
1 parent 096e127 commit 5722aef

4 files changed

Lines changed: 15 additions & 444 deletions

File tree

python/README.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
This directory contains the Protobuf library for Python.
44

5+
For user documentation about how to use Protobuf Python, see
6+
https://protobuf.dev/getting-started/pythontutorial/
7+
8+
# Installation
9+
510
In most cases you should install the library using `pip` or another package
611
manager:
712

@@ -12,10 +17,7 @@ $ pip install protobuf
1217
The packages released on https://pypi.org/project/protobuf/#files include both a
1318
source distribution and binary wheels.
1419

15-
For user documentation about how to use Protobuf Python, see
16-
https://protobuf.dev/getting-started/pythontutorial/
17-
18-
# Building packages from this repo
20+
## Building packages from this repo
1921

2022
If for some reason you wish to build the packages directly from this repo, you
2123
can use the following Bazel commands:
@@ -29,6 +31,15 @@ The binary wheel will build against whatever version of Python is installed on
2931
your system. The source package is always the same and does not depend on a
3032
local version of Python.
3133

34+
## Building from `setup.py`
35+
36+
We support building from `setup.py`, but only from a Python source package.
37+
You cannot build from `setup.py` using the GitHub repo or the GitHub source
38+
tarball.
39+
40+
To build a source package from this repo, see the instructions in the previous
41+
section.
42+
3243
# Implementation backends
3344

3445
There are three separate implementations of Python Protobuf. All of them offer

python/build_targets.bzl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,6 @@ def build_targets(name):
461461
":python_src_files",
462462
"README.md",
463463
"google/__init__.py",
464-
"setup.cfg",
465464
],
466465
strip_prefix = "",
467466
visibility = ["//python/dist:__pkg__"],
@@ -485,8 +484,6 @@ def build_targets(name):
485484
"google/protobuf/python_protobuf.h",
486485
"internal.bzl",
487486
"python_version_test.py",
488-
"setup.cfg",
489-
"setup.py",
490487
],
491488
strip_prefix = strip_prefix.from_root(""),
492489
visibility = ["//pkg:__pkg__"],

python/setup.cfg

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)