Skip to content

Commit

Permalink
Breaking Change: Removed obsolete/duplicate setup.py from Python.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
haberman authored and Copybara-Service committed Jan 31, 2024
1 parent 6f6d9b0 commit 8135fca
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 444 deletions.
19 changes: 15 additions & 4 deletions python/README.md
Expand Up @@ -2,6 +2,11 @@

This directory contains the Protobuf library for Python.

For user documentation about how to use Protobuf Python, see
https://protobuf.dev/getting-started/pythontutorial/

# Installation

In most cases you should install the library using `pip` or another package
manager:

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

For user documentation about how to use Protobuf Python, see
https://protobuf.dev/getting-started/pythontutorial/

# Building packages from this repo
## Building packages from this repo

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

## Building from `setup.py`

We support building from `setup.py`, but only from a Python source package.
You cannot build from `setup.py` using the GitHub repo or the GitHub source
tarball.

To build a source package from this repo, see the instructions in the previous
section.

# Implementation backends

There are three separate implementations of Python Protobuf. All of them offer
Expand Down
3 changes: 0 additions & 3 deletions python/build_targets.bzl
Expand Up @@ -461,7 +461,6 @@ def build_targets(name):
":python_src_files",
"README.md",
"google/__init__.py",
"setup.cfg",
],
strip_prefix = "",
visibility = ["//python/dist:__pkg__"],
Expand All @@ -485,8 +484,6 @@ def build_targets(name):
"google/protobuf/python_protobuf.h",
"internal.bzl",
"python_version_test.py",
"setup.cfg",
"setup.py",
],
strip_prefix = strip_prefix.from_root(""),
visibility = ["//pkg:__pkg__"],
Expand Down
2 changes: 0 additions & 2 deletions python/setup.cfg

This file was deleted.

0 comments on commit 8135fca

Please sign in to comment.