Skip to content

Commit 9bbe5f6

Browse files
committed
Optional requirements related changes
1 parent 63440af commit 9bbe5f6

26 files changed

+54
-65
lines changed

DEVELOPER.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ If librdkafka is installed in a non-standard location provide the include and li
1717

1818
Install sphinx and sphinx_rtd_theme packages:
1919

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

2222
Build HTML docs:
2323

docs/conf.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,13 @@
1717
import os
1818
from glob import glob
1919

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.*')]
24-
2520
# -- General configuration ------------------------------------------------
2621

2722

2823
######################################################################
2924
# General information about the project.
3025
project = u'confluent-kafka'
31-
copyright = u'2016-2023, Confluent Inc.'
26+
copyright = u'2016-2024, Confluent Inc.'
3227

3328
# The version info for the project you're documenting, acts as replacement for
3429
# |version| and |release|, also used in various other places throughout the

examples/README.md

Lines changed: 3 additions & 7 deletions
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,11 +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-
$ rm -rf dist
46-
$ python -m build
47-
$ pip install -e dist/confluent_kafka*whl
48-
$ cd examples
49-
$ pip install -r requirements.txt
45+
$ pip install .[examples]
5046
```
5147

5248
When you're finished with the venv:

pyproject.toml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ classifiers = [
1313
"Programming Language :: Python",
1414
"Programming Language :: Python :: 3",
1515
"Topic :: Software Development :: Libraries :: Python Modules"]
16-
dependencies = []
1716
readme = "README.md"
1817
license = { file = "LICENSE" }
1918
requires-python = ">=3.7"
19+
dynamic = ["optional-dependencies","dependencies"]
2020

2121
[[project.authors]]
2222
name = "Confluent Inc."
@@ -25,13 +25,17 @@ email = "support@confluent.io"
2525
[project.urls]
2626
Homepage = "https://github.com/confluentinc/confluent-kafka-python"
2727

28-
[project.optional-dependencies]
29-
schema-registry = [ "requests",]
30-
avro = [ "fastavro>=1.0", "avro>=1.11.1,<2", "requests",]
31-
json = [ "pyrsistent", "jsonschema", "requests",]
32-
protobuf = [ "protobuf", "requests",]
33-
dev = [ "pytest", "pytest-timeout", "flake8", "fastavro>=1.0", "avro>=1.11.1,<2", "requests",]
34-
doc = [ "sphinx", "sphinx-rtd-theme", "fastavro>=1.0", "avro>=1.11.1,<2", "requests",]
35-
3628
[tool.setuptools]
3729
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 = ["requirements/requirements-tests.txt", "requirements/requirements-docs.txt", "requirements/examples.txt"] }
38+
optional-dependencies.docs = { file = ["requirements/requirements-docs.txt"] }
39+
optional-dependencies.tests = { file = ["requirements/requirements-tests.txt"] }
40+
optional-dependencies.examples = { file = ["requirements/examples.txt"] }
41+
optional-dependencies.soaktest = { file = ["requirements/soaktest.txt"] }

requirements/requirements-all.txt

Lines changed: 9 additions & 0 deletions
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
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
fastavro>=0.23.0
22
requests
3-
avro>=1.11.1,<2
3+
avro>=1.11.1,<2
File renamed without changes.
File renamed without changes.

requirements/requirements-json.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pyrsistent
2+
jsonschema
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
protobuf
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
requests
File renamed without changes.

requirements/requirements-tests.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
urllib3<2.0.0;python_version<="3.7"
2+
urllib3
3+
flake8
4+
pytest
5+
pytest-timeout
6+
requests-mock
7+
trivup>=0.8.3
8+
build

requirements/requirements.txt

Whitespace-only changes.

src/confluent_kafka/requirements.txt

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

src/confluent_kafka/schema_registry/requirements.txt

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

tests/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +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
21+
$ pip install -r requirements/requirements-tests.txt
2222
$ python3 -m pip install .
2323

2424
When you're finished with it:

tests/requirements.txt

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

tests/soak/ubuntu-bootstrap.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ source $venv/bin/activate
4646

4747
pip install -U pip
4848

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

5351
popd # ..python
5452

tools/build-manylinux.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ for PYBIN in /opt/python/cp*/bin; do
9292
"${PYBIN}/pip" -V
9393
"${PYBIN}/pip" install --no-index -f /io/wheelhouse confluent_kafka
9494
"${PYBIN}/python" -c 'import confluent_kafka; print(confluent_kafka.libversion())'
95-
"${PYBIN}/pip" install -r /io/tests/requirements.txt
95+
"${PYBIN}/pip" install -r /io/requirements/requirements-tests.txt
9696
"${PYBIN}/pytest" /io/tests/test_Producer.py
9797
echo "## Uninstalling $PYBIN"
9898
"${PYBIN}/pip" uninstall -y confluent_kafka

tools/smoketest.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ for py in 3.8 ; do
6060
hash -r
6161

6262
pip install -U pip pkginfo
63-
pip install -r tests/requirements.txt
63+
pip install -r requirements/requirements-tests.txt
6464

6565
# Get the packages version so we can pin the install
6666
# command to this version (which hopefully loads it from the wheeldir

tools/source-package-verification.sh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
#
66
set -e
77

8-
pip install -r docs/requirements.txt
8+
pip install -r requirements/requirements-docs.txt
99
pip install -U protobuf
10-
pip install -r tests/requirements.txt
10+
pip install -r requirements/requirements-tests.txt
1111
pip install -U build
1212

1313
lib_dir=dest/runtimes/$OS_NAME-$ARCH/native
@@ -17,9 +17,7 @@ export LDFLAGS="$LDFLAGS -L${PWD}/${lib_dir}"
1717
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PWD/$lib_dir"
1818
export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:$PWD/$lib_dir"
1919

20-
rm -rf dist
21-
python3 -m build
22-
pip install dist/confluent_kafka*.whl
20+
python3 -m pip install .
2321

2422
if [[ $OS_NAME == linux && $ARCH == x64 ]]; then
2523
flake8 --exclude ./_venv,*_pb2.py

tools/wheels/build-wheels.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ echo on
1515

1616
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
18-
set CIBW_TEST_REQUIRES=-r tests/requirements.txt
18+
set CIBW_TEST_REQUIRES=-r requirements/requirements-tests.txt
1919
set CIBW_TEST_COMMAND=pytest {project}\tests\test_Producer.py
2020
rem set CIBW_BUILD_VERBOSITY=3
2121
set include=%cd%\%DEST%\build\native\include

tools/wheels/build-wheels.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ this_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
1010
# Skip PyPy, Python2, old Python3 versions, musl, and x86 builds.
1111
export CIBW_SKIP="pp* cp27-* cp35-* cp36-* *i686 *musllinux* $CIBW_SKIP"
1212
# Run a simple test suite
13-
export CIBW_TEST_REQUIRES="-r tests/requirements.txt"
13+
export CIBW_TEST_REQUIRES="-r requirements/requirements-tests.txt"
1414
export CIBW_TEST_COMMAND="pytest {project}/tests/test_Producer.py"
1515

1616

tools/windows-build.bat

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ set
1010
rem Download and install librdkafka from NuGet.
1111
call tools\windows-install-librdkafka.bat %LIBRDKAFKA_NUGET_VERSION% dest || exit /b 1
1212

13-
pip install -U -r tests/requirements.txt -r src/confluent_kafka/avro/requirements.txt
13+
pip install -U -r requirements/requirements-tests.txt -r requirements/requirements-avro.txt
1414
pip install cibuildwheel==0.12.0 || exit /b 1
1515

1616
rem Build wheels (without tests)
@@ -51,8 +51,8 @@ for %%W in (wheelhouse\confluent_kafka-*cp%PYTHON_SHORTVER%*win*%PYTHON_ARCH%.wh
5151
python -c "import struct; print(struct.calcsize('P') * 8)"
5252
7z l %%~W
5353
pip install %%~W || exit /b 1
54-
pip install -r src\confluent_kafka\requirements.txt
55-
pip install -r src\confluent_kafka\avro\requirements.txt
54+
pip install -r requirements\requirements.txt
55+
pip install -r requirements\requirements-avro.txt
5656

5757
python -c "from confluent_kafka import libversion ; print(libversion())" || exit /b 1
5858

tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = flake8,py37,py38,py39,py310
2+
envlist = flake8,py37,py38,py39,py310,py311,py312
33

44
[testenv]
55
setenv =
@@ -22,7 +22,7 @@ commands =
2222

2323
deps =
2424
# https://docs.pytest.org/en/latest/changelog.html#id53
25-
-rtests/requirements.txt
25+
-rrequirements/requirement-dev.txt
2626

2727
[testenv:flake8]
2828
deps = flake8

0 commit comments

Comments
 (0)