Skip to content

Commit fea7154

Browse files
committed
Introduced pyproject.toml and moved static metadata from setup.py
1 parent a27d113 commit fea7154

17 files changed

+80
-103
lines changed

DEVELOPER.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ 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

LICENSE.txt renamed to LICENSE

File renamed without changes.

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

Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ all:
66

77
clean:
88
python setup.py clean
9+
rm -rf dist
910
make -C docs clean
1011

1112
.PHONY: docs

examples/README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ 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
45+
$ rm -rf dist
46+
$ python -m build
47+
$ pip install -e dist/confluent_kafka*whl
4648
$ cd examples
4749
$ pip install -r requirements.txt
4850
```

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

pyproject.toml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[build-system]
2+
requires = [ "setuptools>=62", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "confluent-kafka"
7+
version = "2.1.1"
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+
dependencies = [ "futures;python_version<\"3.2\"", "enum34;python_version<\"3.4\"",]
17+
readme = "README.md"
18+
license = { file = "LICENSE" }
19+
requires-python = ">=3.7"
20+
21+
[[project.authors]]
22+
name = "\"Confluent Inc\""
23+
24+
25+
[project.urls]
26+
Homepage = "https://github.com/confluentinc/confluent-kafka-python"
27+
28+
[project.optional-dependencies]
29+
schema-registry = [ "requests",]
30+
avro = [ "fastavro>=0.23.0,<1.0;python_version<\"3.0\"", "fastavro>=1.0;python_version>\"3.0\"", "avro>=1.11.1,<2", "requests",]
31+
json = [ "pyrsistent==0.16.1;python_version<\"3.0\"", "pyrsistent;python_version>\"3.0\"", "jsonschema", "requests",]
32+
protobuf = [ "protobuf", "requests",]
33+
dev = [ "pytest==4.6.4;python_version<\"3.0\"", "pytest;python_version>=\"3.0\"", "pytest-timeout", "flake8", "fastavro>=0.23.0,<1.0;python_version<\"3.0\"", "fastavro>=1.0;python_version>\"3.0\"", "avro>=1.11.1,<2", "requests",]
34+
doc = [ "sphinx", "sphinx-rtd-theme", "fastavro>=0.23.0,<1.0;python_version<\"3.0\"", "fastavro>=1.0;python_version>\"3.0\"", "avro>=1.11.1,<2", "requests",]
35+
36+
[tool.setuptools]
37+
include-package-data = false

setup.py

+3-72
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,13 @@
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

8-
work_dir = os.path.dirname(os.path.realpath(__file__))
9-
mod_dir = os.path.join(work_dir, 'src', 'confluent_kafka')
8+
mod_dir = os.path.join('src', 'confluent_kafka')
109
ext_dir = os.path.join(mod_dir, 'src')
1110

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-
3911
# On Un*x the library is linked as -lrdkafka,
4012
# while on windows we need the full librdkafka name.
4113
if platform.system() == 'Windows':
@@ -52,45 +24,4 @@
5224
os.path.join(ext_dir, 'AdminTypes.c'),
5325
os.path.join(ext_dir, 'Admin.c')])
5426

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.3.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-
})
27+
setup(ext_modules=[module])

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

tests/README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ A python3 env suitable for running tests:
1919
$ python3 -m venv venv_test
2020
$ source venv_test/bin/activate
2121
$ pip install -r tests/requirements.txt
22-
$ python setup.py build
23-
$ python setup.py install
22+
$ python3 -m pip install .
2423

2524
When you're finished with it:
2625

tests/requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ fastavro
1212
avro>=1.11.1,<2
1313
jsonschema
1414
protobuf
15+
build

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

tools/RELEASE.md

+14-15
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ RCs, so it only needs to be set once for each release.
140140
* `src/confluent_kafka/src/confluent_kafka.h`
141141
update both `CFL_VERSION` and `CFL_VERSION_STR`.
142142
* `docs/conf.py` - change `version` variable.
143-
* `setup.py` - change `version` argument to `setup()`.
143+
* `pyproject.toml` - change `version` field.
144144

145145
Commit these changes with a commit-message containing the version:
146146

@@ -290,30 +290,29 @@ With the PR merged to master, check out and update master:
290290
Now go back to 5.1 and start the final RELEASE ITERATION.
291291

292292

293-
### 5.6. Upload wheel packages to PyPi
293+
### 5.6. Create source distribution
294294

295-
**CANDIDATE ITERATION:** To upload binary packages to test.pypi.org, use:
295+
When creating the source packages make sure to have checked out the correct tag
296+
and that you do not have any uncommited modifications and that the `dist/`
297+
directory is empty.
296298

297-
$ twine upload -r test dl-v0.11.4rc1/*
299+
$ python -m build -s
298300

299-
**RELEASE ITERATION:** To upload binary packages to the proper pypi.org (WARNING!), use:
301+
The above command will create the necessary source distribution. Move this
302+
generated sdist file to correct `tools\dl-<tag>` folder
300303

301-
$ twine upload dl-v0.11.4rc1/*
304+
$ mv dist/confluent-kafka-0.11.4rc1.tar.gz tools/dl-v0.11.4rc1/
302305

303306

304-
### 5.7. Upload source packages to PyPi
307+
### 5.7. Upload wheel packages and sdist to PyPi
305308

306-
When uploading source packages make sure to have checked out the correct tag
307-
and that you do not have any uncommited modifications and that the `build/`
308-
directory is empty.
309-
310-
**CANDIDATE ITERATION:** Upload source packages to test.pypi.org:
309+
**CANDIDATE ITERATION:** To upload binary packages to test.pypi.org, use:
311310

312-
$ python setup.py sdist upload -r test
311+
$ twine upload -r test tools/dl-v0.11.4rc1/*
313312

314-
**RELEASE ITERATION:** Upload source packages to the proper pypi.org (WARNING!):
313+
**RELEASE ITERATION:** To upload binary packages to the proper pypi.org (WARNING!), use:
315314

316-
$ python setup.py sdist upload
315+
$ twine upload tools/dl-v0.11.4rc1/*
317316

318317

319318
### 5.8. Verify installation from PyPi

tools/build-manylinux.sh

+4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515
# docker run -t -v $(pwd):/io quay.io/pypa/manylinux2010_x86_64:latest /io/tools/build-manylinux.sh <librdkafka_tag>
1616

1717
LIBRDKAFKA_VERSION=$1
18+
<<<<<<< HEAD
1819
PYTHON_VERSIONS=("cp36" "cp37" "cp38" "cp39" "cp310" "cp311" "cp312")
20+
=======
21+
PYTHON_VERSIONS=("cp37" "cp38" "cp39" "cp310" "cp311" )
22+
>>>>>>> 64c166e (Introduced pyproject.toml and moved static metadata from setup.py)
1923

2024
if [[ -z "$LIBRDKAFKA_VERSION" ]]; then
2125
echo "Usage: $0 <librdkafka_tag>"

tools/source-package-verification.sh

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ set -e
88
pip install -r docs/requirements.txt
99
pip install -U protobuf
1010
pip install -r tests/requirements.txt
11+
pip install -U build
1112

1213
lib_dir=dest/runtimes/$OS_NAME-$ARCH/native
1314
tools/wheels/install-librdkafka.sh "${LIBRDKAFKA_VERSION#v}" dest
@@ -16,7 +17,10 @@ export LDFLAGS="$LDFLAGS -L${PWD}/${lib_dir}"
1617
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PWD/$lib_dir"
1718
export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:$PWD/$lib_dir"
1819

19-
python setup.py build && python setup.py install
20+
rm -rf dist
21+
python3 -m build
22+
pip install dist/confluent_kafka*.whl
23+
2024
if [[ $OS_NAME == linux && $ARCH == x64 ]]; then
2125
flake8 --exclude ./_venv,*_pb2.py
2226
make docs

tools/wheels/build-wheels.bat

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ set WHEELHOUSE=%4
1313
if [%WHEELHOUSE%]==[] goto usage
1414
echo on
1515

16-
set CIBW_BUILD=cp36-%BW_ARCH% cp37-%BW_ARCH% cp38-%BW_ARCH% cp39-%BW_ARCH% cp310-%BW_ARCH% cp311-%BW_ARCH% cp312-%BW_ARCH%
16+
set CIBW_BUILD=cp37-%BW_ARCH% cp38-%BW_ARCH% cp39-%BW_ARCH% cp310-%BW_ARCH% cp311-%BW_ARCH% cp312-%BW_ARCH%
1717
set CIBW_BEFORE_BUILD=python -m pip install delvewheel==1.1.4
1818
set CIBW_TEST_REQUIRES=-r tests/requirements.txt
1919
set CIBW_TEST_COMMAND=pytest {project}\tests\test_Producer.py

tools/wheels/build-wheels.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ this_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
88

99

1010
# Skip PyPy, Python2, old Python3 versions, musl, and x86 builds.
11-
export CIBW_SKIP="pp* cp27-* cp35-* *i686 *musllinux* $CIBW_SKIP"
11+
export CIBW_SKIP="pp* cp27-* cp35-* cp36-* *i686 *musllinux* $CIBW_SKIP"
1212
# Run a simple test suite
1313
export CIBW_TEST_REQUIRES="-r tests/requirements.txt"
1414
export CIBW_TEST_COMMAND="pytest {project}/tests/test_Producer.py"

0 commit comments

Comments
 (0)