Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the "mock" dependency optional (only used in Python 2.7). #2518

Merged
merged 1 commit into from
Mar 11, 2025

Conversation

Romain-Geissler-1A
Copy link
Contributor

"mock" is included inside the standard "unittest" package in Python >= 3.3.

(This is an alternatve version of what was proposed (and declined) earlier in #2516. The idea is to allow distributions to package kafka-python without having to patch it explicitly to remove the "mock" dependency).

@dpkp
Copy link
Owner

dpkp commented Mar 11, 2025

I think I can merge this, thanks for the update. Can you show me what commands you are using to package that break on the current master? Our intent was to make testing dependencies / requirements-dev optional and wouldn't expect them to be included generally. The are not included in wheels uploaded to pypi, for example.

@Romain-Geissler-1A
Copy link
Contributor Author

Actually we have upgraded python-kafka in Fedora + EPEL 10 this week-end, including the diff of the closed pull request #2516: https://src.fedoraproject.org/rpms/python-kafka/pull-request/4#request_diff They way most fedora python packages are built are via some %pyproject_ macros, which honestly I don't really know what they do. See the spec file here: https://src.fedoraproject.org/rpms/python-kafka/blob/rawhide/f/python-kafka.spec The most basic use case is to read the pyproject.toml and look for dependencies there, but I have seen other package defining their dependencies either a tox.ini file or various requirements.txt files. These macro will try to discover dependencies this way, and "convert" these to actual RPM packages dependencies. In Fedora, python-mock has been removed already, no one is meant to depend on it anymore, and thus right now trying to package python-kafka without any patch results in a missing mock dependency. Note that usually fedora packages try to run tests (which often catches some breakages when something changes).

pyproject.toml Outdated
@@ -37,7 +37,7 @@ crc32c = ["crc32c"]
lz4 = ["lz4"]
snappy = ["python-snappy"]
zstd = ["zstandard"]
testing = ["pytest", "mock", "pytest-mock"]
testing = ["pytest", "mock; python_version < '2.7'", "pytest-mock"]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we make this < '3.3' ?

@@ -3,7 +3,7 @@ crc32c
docker-py
flake8
lz4
mock
mock; python_version < '2.7'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same -- prefer to cover all python before unittest.mock added in 3.3

@Romain-Geissler-1A
Copy link
Contributor Author

I have update the version constraint to < '3.3' everywhere as suggested.

@dpkp
Copy link
Owner

dpkp commented Mar 11, 2025

sorry, i also removed tox.ini and you'll need to rebase against that change before I can merge :(

"mock" is included inside the standard "unittest" package in Python >= 3.3
@dpkp dpkp merged commit 0ae708a into dpkp:master Mar 11, 2025
16 checks passed
@dpkp
Copy link
Owner

dpkp commented Mar 11, 2025

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants