MagicStack / MagicStack/asyncpg
setup.py relies on deprecated pkg_resources
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 8.1k
- Fork
- 469
- Merge medio
- 18m
- PR unite (30g)
- 4
Descrizione
Summary
setup.py imports and uses the deprecated pkg_resources module (from setuptools) to validate the installed Cython version when building asyncpg from source:
- https://github.com/MagicStack/asyncpg/blob/db8ecc2/setup.py#L191
- https://github.com/MagicStack/asyncpg/blob/db8ecc2/setup.py#L204-L205
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 #1314 already proposes removing the Cython version check from
setup.pyentirely to eliminate thepkg_resourcesdependency. - Port to
packaging: alternatively the check can be preserved by switching to thepackaginglibrary, as the sister project uvloop did in MagicStack/uvloop@b377b7c6885a1eb63cb8cf19db5ab66a12c79e21 — replacingpkg_resources.Requirement.parse(...)withpackaging.requirements.Requirement(...)andx not in depwithdep.specifier.contains(x, prereleases=True)(addingpackagingtobuild-system.requires).pkg_resources.Requirement.__contains__usedprereleases=Trueinternally, so passingprereleases=Truepreserves 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.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia leggendo setup.py intorno alle righe 191 e 204-205, quindi confronta il PR #1314 esistente con l’approccio di packaging utilizzato da uvloop. Il lavoro è completato quando il percorso di build dai sorgenti non importa più pkg_resources, preservando al contempo il comportamento previsto della dipendenza da Cython.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- build-system
- Tipo di issue
- Bug
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 28/100