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

Use packaging instead of distutils for Version #2931

Merged
merged 2 commits into from
Jul 26, 2022
Merged

Use packaging instead of distutils for Version #2931

merged 2 commits into from
Jul 26, 2022

Conversation

FrancescoCasalegno
Copy link
Contributor

Fixes #2928.

Context

setuptools has deprecated the usage of distutils Version classes since version 60.3.0. See pypa/setuptools@1701579 for details.

As a consequence, a warning is raised any time we try, e.g., to do from docker import from_env. Notice that this warning can be fatal if the user has set a warning filter to error mode, which is not too uncommon when running unit tests in CI.

Proposed solution

  1. Replace occurrences of distutils.Version (and its subclasses) with packaging.Version.
  2. Add packaging to the install_requires.

Signed-off-by: Francesco Casalegno <francesco.casalegno@gmail.com>
@FrancescoCasalegno
Copy link
Contributor Author

@aiordache @ulyssessouza this PR has been open for 2 days but the CI tests is still on hold, because it needs your approval before being run.

Could you please give your green light to run the CI workflow (and also provide some feedback on this PR, when you have time)?

@marco-m-pix4d
Copy link

Hello @aiordache @ureyes84 any chance you could have a look at the request by @FrancescoCasalegno above? Thanks!

@cristianmtr
Copy link

Any update on this? We use the docker package quite a bit and this warning is polluting our logs

@florian-hoenicke
Copy link

I use import warnings and warnings.filterwarnings("ignore", category=DeprecationWarning) as a workaround but it would be better if it could be fixed here.

@zanieb
Copy link

zanieb commented Apr 12, 2022

For others that are encountering this, you can do a temporary ignore as follows:

import warnings
import docker


def get_docker_client():
    with warnings.catch_warnings():
        # Silence warnings due to use of deprecated methods within dockerpy
        # See https://github.com/docker/docker-py/pull/2931
        warnings.filterwarnings(
            "ignore",
            message="distutils Version classes are deprecated.*",
            category=DeprecationWarning,
        )

        return docker.from_env()

@liadmord
Copy link

liadmord commented May 3, 2022

Seems like the maintainers have gone AWOL, maybe someone should fork this repo?

cemiarni pushed a commit to OneIdentity/bldr that referenced this pull request Jul 14, 2022
…ckage

After docker package resolves that warning, this commit should be reverted.

docker/docker-py#2928
docker/docker-py#2931
cemiarni pushed a commit to OneIdentity/bldr that referenced this pull request Jul 15, 2022
…ckage

After docker package resolves that warning, this commit should be reverted.

docker/docker-py#2928
docker/docker-py#2931
cemiarni pushed a commit to OneIdentity/bldr that referenced this pull request Jul 15, 2022
…ckage

After docker package resolves that warning, this commit should be reverted.

docker/docker-py#2928
docker/docker-py#2931
@milas milas self-assigned this Jul 26, 2022
@milas milas merged commit 2e6dad7 into docker:master Jul 26, 2022
@milas milas added this to the 6.0.0 milestone Jul 30, 2022
@marco-m-pix4d
Copy link

Thanks @milas !

@milas milas mentioned this pull request Jan 3, 2024
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.

docker.from_env produces "DeprecationWarning: distutils Version classes are deprecated" warnings.
7 participants