Skip to content

Commit 42f4487

Browse files
authored
Introduced pyproject.toml and moved static metadata from setup.py (#1592)
Introduced pyproject.toml and moved static metadata from setup.py
1 parent e17f6e2 commit 42f4487

37 files changed

+149
-169
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
v2.6.1 is a maintenance release with the following fixes and enhancements:
66

7+
- Migrated build system from `setup.py` to `pyproject.toml` in accordance with `PEP 517` and `PEP 518`, improving project configuration, build system requirements management, and compatibility with modern Python packaging tools like `pip` and `build`.
78
- Added an example for OAUTH OIDC producer with support for confluent cloud (#1769, @sarwarbhuiyan)
89

910
confluent-kafka-python is based on librdkafka v2.6.1, see the

Diff for: DEVELOPER.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ This document provides information useful to developers working on confluent-kaf
55

66
## Build
77

8-
$ python setup.py build
8+
$ python -m build
99

1010
If librdkafka is installed in a non-standard location provide the include and library directories with:
1111

12-
$ C_INCLUDE_PATH=/path/to/include LIBRARY_PATH=/path/to/lib python setup.py ...
12+
$ C_INCLUDE_PATH=/path/to/include LIBRARY_PATH=/path/to/lib python -m build
1313

1414
**Note**: On Windows the variables for Visual Studio are named INCLUDE and LIB
1515

1616
## Generate Documentation
1717

18-
Install sphinx and sphinx_rtd_theme packages:
18+
Install docs dependencies:
1919

20-
$ pip install sphinx sphinx_rtd_theme
20+
$ pip install .[docs]
2121

2222
Build HTML docs:
2323

Diff for: LICENSE.txt renamed to LICENSE

File renamed without changes.

Diff for: MANIFEST.in

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
include README.md
2-
include LICENSE.txt
3-
include test-requirements.txt
42
include src/confluent_kafka/src/*.[ch]
3+
prune tests
4+
prune docs

Diff for: Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ all:
55

66

77
clean:
8-
python setup.py clean
8+
pip cache purge
9+
rm -rf dist
910
make -C docs clean
1011

1112
.PHONY: docs

Diff for: docs/conf.py

-8
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,6 @@
1313
# serve to show the default.
1414

1515
import sphinx_rtd_theme
16-
import sys
17-
import os
18-
from glob import glob
19-
20-
# If extensions (or modules to document with autodoc) are in another directory,
21-
# add these directories to sys.path here. If the directory is relative to the
22-
# documentation root, use os.path.abspath to make it absolute, like shown here.
23-
sys.path[:0] = [os.path.abspath(x) for x in glob('../build/lib.*')]
2416

2517
# -- General configuration ------------------------------------------------
2618

Diff for: examples/README.md

+3-5
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ To setup a venv with the latest release version of confluent-kafka and dependenc
3030
```
3131
$ python3 -m venv venv_examples
3232
$ source venv_examples/bin/activate
33-
$ cd examples
34-
$ pip install -r requirements.txt
33+
$ pip install confluent_kafka
34+
$ pip install -r requirements/requirements-examples.txt
3535
```
3636

3737
To setup a venv that uses the current source tree version of confluent_kafka, you
@@ -42,9 +42,7 @@ need to have a C compiler and librdkafka installed
4242
```
4343
$ python3 -m venv venv_examples
4444
$ source venv_examples/bin/activate
45-
$ python setup.py develop
46-
$ cd examples
47-
$ pip install -r requirements.txt
45+
$ pip install .[examples]
4846
```
4947

5048
When you're finished with the venv:

Diff for: examples/docker/Dockerfile.alpine

+4-3
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,10 @@ RUN \
7373
mkdir -p /usr/src/confluent-kafka-python && \
7474
cd /usr/src/confluent-kafka-python && \
7575
rm -rf build && \
76-
python3 setup.py clean -a && \
77-
python3 setup.py build && \
78-
python3 setup.py install && \
76+
rm -rf dist && \
77+
python3 -m pip install build \
78+
python3 -m build && \
79+
python3 -m pip install dist/confluent_kafka*whl && \
7980
cd / && \
8081
rm -rf /usr/src/confluent-kafka-python
8182

Diff for: pyproject.toml

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
[build-system]
2+
requires = [ "setuptools>=62", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "confluent-kafka"
7+
version = "2.6.0.post1.dev1"
8+
description = "Confluent's Python client for Apache Kafka"
9+
classifiers = [
10+
"Development Status :: 5 - Production/Stable",
11+
"Intended Audience :: Developers",
12+
"License :: OSI Approved :: Apache Software License",
13+
"Programming Language :: Python",
14+
"Programming Language :: Python :: 3",
15+
"Topic :: Software Development :: Libraries :: Python Modules"]
16+
readme = "README.md"
17+
license = { file = "LICENSE" }
18+
requires-python = ">=3.7"
19+
dynamic = ["dependencies", "optional-dependencies"]
20+
21+
[[project.authors]]
22+
name = "Confluent Inc."
23+
24+
25+
[project.urls]
26+
Homepage = "https://github.com/confluentinc/confluent-kafka-python"
27+
28+
[tool.setuptools]
29+
include-package-data = false
30+
31+
[tool.setuptools.dynamic]
32+
dependencies = {file = ["requirements/requirements.txt"]}
33+
optional-dependencies.schemaregistry = { file = ["requirements/requirements-schemaregistry.txt"] }
34+
optional-dependencies.avro = { file = ["requirements/requirements-avro.txt", "requirements/requirements-schemaregistry.txt"] }
35+
optional-dependencies.json = { file = ["requirements/requirements-json.txt", "requirements/requirements-schemaregistry.txt"] }
36+
optional-dependencies.protobuf = { file = ["requirements/requirements-protobuf.txt", "requirements/requirements-schemaregistry.txt"] }
37+
optional-dependencies.dev = { file = [
38+
"requirements/requirements-docs.txt",
39+
"requirements/requirements-examples.txt",
40+
"requirements/requirements-tests.txt",
41+
"requirements/requirements-schemaregistry.txt",
42+
"requirements/requirements-avro.txt",
43+
"requirements/requirements-json.txt",
44+
"requirements/requirements-protobuf.txt"] }
45+
optional-dependencies.docs = { file = [
46+
"requirements/requirements-docs.txt",
47+
"requirements/requirements-schemaregistry.txt",
48+
"requirements/requirements-avro.txt",
49+
"requirements/requirements-json.txt",
50+
"requirements/requirements-protobuf.txt"] }
51+
optional-dependencies.tests = { file = [
52+
"requirements/requirements-tests.txt",
53+
"requirements/requirements-schemaregistry.txt",
54+
"requirements/requirements-avro.txt",
55+
"requirements/requirements-json.txt",
56+
"requirements/requirements-protobuf.txt"] }
57+
optional-dependencies.examples = { file = ["requirements/requirements-examples.txt"] }
58+
optional-dependencies.soaktest = { file = ["requirements/requirements-soaktest.txt"] }
59+
optional-dependencies.all = { file = [
60+
"requirements/requirements-soaktest.txt",
61+
"requirements/requirements-docs.txt",
62+
"requirements/requirements-examples.txt",
63+
"requirements/requirements-tests.txt",
64+
"requirements/requirements-schemaregistry.txt",
65+
"requirements/requirements-avro.txt",
66+
"requirements/requirements-json.txt",
67+
"requirements/requirements-protobuf.txt"] }

Diff for: requirements/requirements-all.txt

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-r requirements.txt
2+
-r requirements-schemaregistry.txt
3+
-r requirements-avro.txt
4+
-r requirements-protobuf.txt
5+
-r requirements-json.txt
6+
-r requirements-examples.txt
7+
-r requirements-tests.txt
8+
-r requirements-docs.txt
9+
-r requirements-soaktest.txt

Diff for: requirements/requirements-avro.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fastavro < 1.8.0; python_version == "3.7"
2+
fastavro < 2; python_version > "3.7"
3+
requests
4+
avro>=1.11.1,<2
File renamed without changes.
File renamed without changes.

Diff for: requirements/requirements-json.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pyrsistent
2+
jsonschema

Diff for: requirements/requirements-protobuf.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
protobuf

Diff for: requirements/requirements-schemaregistry.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
requests
File renamed without changes.

Diff for: requirements/requirements-tests-install.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-r requirements-tests.txt
2+
-r requirements-schemaregistry.txt
3+
-r requirements-avro.txt
4+
-r requirements-protobuf.txt
5+
-r requirements-json.txt

Diff for: requirements/requirements-tests.txt

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# core test requirements
2+
urllib3<2.0.0;python_version<="3.7"
3+
urllib3 >= 2.0.0,<3; python_version > "3.7"
4+
flake8
5+
pytest
6+
pytest-timeout
7+
requests-mock
8+
trivup>=0.8.3

Diff for: requirements/requirements.txt

Whitespace-only changes.

Diff for: setup.py

+2-70
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,14 @@
11
#!/usr/bin/env python
22

33
import os
4-
from setuptools import setup, find_packages
4+
from setuptools import setup
55
from distutils.core import Extension
66
import platform
77

88
work_dir = os.path.dirname(os.path.realpath(__file__))
99
mod_dir = os.path.join(work_dir, 'src', 'confluent_kafka')
1010
ext_dir = os.path.join(mod_dir, 'src')
1111

12-
INSTALL_REQUIRES = [
13-
'futures;python_version<"3.2"',
14-
'enum34;python_version<"3.4"',
15-
]
16-
17-
TEST_REQUIRES = [
18-
'pytest==4.6.4;python_version<"3.0"',
19-
'pytest;python_version>="3.0"',
20-
'pytest-timeout',
21-
'flake8'
22-
]
23-
24-
DOC_REQUIRES = ['sphinx', 'sphinx-rtd-theme']
25-
26-
SCHEMA_REGISTRY_REQUIRES = ['requests']
27-
28-
AVRO_REQUIRES = ['fastavro>=0.23.0,<1.0;python_version<"3.0"',
29-
'fastavro>=1.0;python_version>"3.0"',
30-
'avro>=1.11.1,<2',
31-
] + SCHEMA_REGISTRY_REQUIRES
32-
33-
JSON_REQUIRES = ['pyrsistent==0.16.1;python_version<"3.0"',
34-
'pyrsistent;python_version>"3.0"',
35-
'jsonschema'] + SCHEMA_REGISTRY_REQUIRES
36-
37-
PROTO_REQUIRES = ['protobuf'] + SCHEMA_REGISTRY_REQUIRES
38-
3912
# On Un*x the library is linked as -lrdkafka,
4013
# while on windows we need the full librdkafka name.
4114
if platform.system() == 'Windows':
@@ -52,45 +25,4 @@
5225
os.path.join(ext_dir, 'AdminTypes.c'),
5326
os.path.join(ext_dir, 'Admin.c')])
5427

55-
56-
def get_install_requirements(path):
57-
content = open(os.path.join(os.path.dirname(__file__), path)).read()
58-
return [
59-
req
60-
for req in content.split("\n")
61-
if req != '' and not req.startswith('#')
62-
]
63-
64-
65-
trove_classifiers = [
66-
'Development Status :: 5 - Production/Stable',
67-
'Intended Audience :: Developers',
68-
'License :: OSI Approved :: Apache Software License',
69-
'Programming Language :: Python',
70-
'Programming Language :: Python :: 2.7',
71-
'Programming Language :: Python :: 3',
72-
'Topic :: Software Development :: Libraries :: Python Modules',
73-
]
74-
75-
setup(name='confluent-kafka',
76-
# Make sure to bump CFL_VERSION* in confluent_kafka/src/confluent_kafka.h
77-
# and version in docs/conf.py.
78-
version='2.6.0',
79-
description='Confluent\'s Python client for Apache Kafka',
80-
author='Confluent Inc',
81-
author_email='[email protected]',
82-
url='https://github.com/confluentinc/confluent-kafka-python',
83-
ext_modules=[module],
84-
packages=find_packages('src'),
85-
package_dir={'': 'src'},
86-
data_files=[('', [os.path.join(work_dir, 'LICENSE.txt')])],
87-
install_requires=INSTALL_REQUIRES,
88-
classifiers=trove_classifiers,
89-
extras_require={
90-
'schema-registry': SCHEMA_REGISTRY_REQUIRES,
91-
'avro': AVRO_REQUIRES,
92-
'json': JSON_REQUIRES,
93-
'protobuf': PROTO_REQUIRES,
94-
'dev': TEST_REQUIRES + AVRO_REQUIRES,
95-
'doc': DOC_REQUIRES + AVRO_REQUIRES
96-
})
28+
setup(ext_modules=[module])

Diff for: src/confluent_kafka/avro/requirements.txt

-3
This file was deleted.

Diff for: src/confluent_kafka/requirements.txt

-2
This file was deleted.

Diff for: src/confluent_kafka/schema_registry/requirements.txt

-6
This file was deleted.

Diff for: src/confluent_kafka/src/confluent_kafka.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737

3838
/**
39-
* @brief confluent-kafka-python version, must match that of setup.py.
39+
* @brief confluent-kafka-python version, must match that of pyproject.toml.
4040
*
4141
* Hex version representation:
4242
* 0xMMmmRRPP

Diff for: tests/README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ A python3 env suitable for running tests:
1818

1919
$ python3 -m venv venv_test
2020
$ source venv_test/bin/activate
21-
$ pip install -r tests/requirements.txt
22-
$ python setup.py build
23-
$ python setup.py install
21+
$ python3 -m pip install .[tests]
2422

2523
When you're finished with it:
2624

Diff for: tests/requirements.txt

-14
This file was deleted.

Diff for: tests/soak/bootstrap.sh

+1-3
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ source $venv/bin/activate
4545

4646
pip install -U pip
4747

48-
pip install -v .
49-
50-
pip install -r tests/soak/requirements.txt
48+
pip install -v .[soaktest]
5149

5250
popd # ..python
5351

Diff for: tests/soak/build.sh

-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ set -u
3232
pushd confluent-kafka-python
3333
git fetch --tags
3434
git checkout $cflpy_version
35-
python3 setup.py clean -a
36-
python3 setup.py build
3735
python3 -m pip install .
3836
popd
3937

0 commit comments

Comments
 (0)