Generate a Python version requirement for requirements.txt-only projects
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 64/100
Hướng nghiên cứu
Bắt đầu với Environment.create_python_environment() và đường dẫn tạo Manifest được mô tả trong issue. Theo dõi cách các yêu cầu được phát hiện và cách python_version_requirement đi tới environment.python.requires, sau đó bổ sung độ bao phủ cho các dự án chỉ có requirements và cho thứ tự ưu tiên của các ràng buộc rõ ràng. Hoàn thành có nghĩa là fallback giữ nguyên python.version, cho phép các bản patch tương thích và các ràng buộc rõ ràng vẫn được ưu tiên.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem
For Python projects that contain requirements.txt but do not contain a
.python-version, pyproject.toml with project.requires-python, or
setup.cfg with python_requires, rsconnect-python generates a manifest with
only the exact local interpreter version:
{
"python": {
"version": "3.11.9"
}
}
It does not generate environment.python.requires.
This is likely the most common project layout for Python content deployed to
Posit Connect. The generated manifest therefore relies on the legacy
python.version field rather than expressing the content's compatibility as a
version constraint. This can prevent Connect from rebuilding content with a
different available Python version, particularly when exact version matching
is enabled.
Current behavior
Environment.create_python_environment() detects a requirement only from:
.python-versionpyproject.toml→project.requires-pythonsetup.cfg→python_requires
When none is present, python_version_requirement remains None.
Manifest consequently omits environment.python.requires, while
python.version is populated with the full version of the interpreter used for
environment inspection.
Proposed behavior
When no explicit Python requirement is found, derive a major/minor-compatible
requirement from the inspected interpreter and include it in the manifest.
For example, packaging with Python 3.11.9 could produce:
{
"python": {
"version": "3.11.9"
},
"environment": {
"python": {
"requires": "~=3.11.0"
}
}
}
An explicit requirement from .python-version, pyproject.toml, or
setup.cfg should continue to take precedence.
The exact fallback constraint syntax is open for discussion, but it should
allow Connect to select an available compatible patch release while preserving
the deployed interpreter's major/minor version.
Motivation
requirements.txt-only projects are common.- Users should not need to add unrelated packaging metadata solely to obtain
appropriate Python version matching. - Connect should be able to rebuild content with another compatible Python
installation when the original patch release is unavailable. - This would make the default behavior consistent with the intent of
environment.python.requires.
Related work
- #648 added support for
environment.python.requireswhen a constraint is
explicitly available. - #659 addressed adapting
.python-versionvalues into version constraints. - posit-dev/connect#43572 contains a recent discussion of Connect rebuilding
content after supported Python installations change.
Acceptance criteria
- A Python project containing only
requirements.txtgets an
environment.python.requiresfallback derived from the inspected
interpreter. - The fallback matches compatible patch releases within the same major/minor
version. - Explicit project constraints continue to override the fallback.
- Generated manifests retain
python.versionfor backward compatibility. - Tests cover requirements-only projects and explicit-constraint precedence.
- Ngôn ngữ chính
- Python
- Star
- 37
- Fork
- 28
- Merge trung bình
- 1 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 7
Hướng dẫn đóng góp
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.
Issue khác của posit-dev/rsconnect-python
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
posit-dev/rsconnect-python#786 · 1 reaction ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
posit-dev/rsconnect-python#543 · 2 bình luận ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
posit-dev/rsconnect-python#513 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
posit-dev/rsconnect-python#178 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 58/100
posit-dev/rsconnect-python#855 ·
Tất cả issue của posit-dev/rsconnect-python
Issue tương tự
-
documentation help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
simonw/sqlite-utils#872 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100