Skip to content

setup.py relies on deprecated pkg_resources #1337

Description

@jasonwbarnett

Summary

setup.py imports and uses the deprecated pkg_resources module (from setuptools) to validate the installed Cython version when building asyncpg from source:

import pkg_resources
...
cython_dep = pkg_resources.Requirement.parse(CYTHON_DEPENDENCY)
if Cython.__version__ not in cython_dep:
    ...

Problem

pkg_resources has long been deprecated by setuptools: importing it emits DeprecationWarning: pkg_resources is deprecated as an API, and it is slated for removal. On recent setuptools/distro configurations it may no longer be importable at all, which can make source builds of asyncpg warn or fail.

Existing work / options

  • Drop the check: open PR Drop the Cython version check from setup.py #1314 already proposes removing the Cython version check from setup.py entirely to eliminate the pkg_resources dependency.
  • Port to packaging: alternatively the check can be preserved by switching to the packaging library, as the sister project uvloop did in MagicStack/uvloop@b377b7c — replacing pkg_resources.Requirement.parse(...) with packaging.requirements.Requirement(...) and x not in dep with dep.specifier.contains(x, prereleases=True) (adding packaging to build-system.requires). pkg_resources.Requirement.__contains__ used prereleases=True internally, so passing prereleases=True preserves the original behavior exactly.

Either approach removes the deprecated dependency. Filing this to track the deprecation as an issue alongside the in-flight PR #1314.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions