MagicStack / MagicStack/asyncpg
setup.py relies on deprecated pkg_resources
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 8.1k
- Fork
- 468
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
### 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
```python
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](https://setuptools.pypa.io/en/latest/deprecated/pkg_resources.html) 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.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@b377b7c6885a1eb63cb8cf19db5ab66a12c79e21 — 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.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng cách đọc setup.py quanh các dòng 191 và 204-205, sau đó so sánh PR #1314 hiện có với cách tiếp cận đóng gói được uvloop sử dụng. Hoàn thành khi đường dẫn build từ mã nguồn không còn import pkg_resources, đồng thời vẫn giữ nguyên hành vi dự kiến của dependency Cython.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- build-system
- Loại issue
- Lỗi
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 28/100