posit-dev / posit-dev/rsconnect-python

Generate a Python version requirement for requirements.txt-only projects

Aperta
#854 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Python
Stelle
37
Fork
28
Merge medio
1g 3h
PR unite (30g)
7

Descrizione

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:

  1. .python-version
  2. pyproject.tomlproject.requires-python
  3. setup.cfgpython_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.requires when a constraint is
    explicitly available.
  • #659 addressed adapting .python-version values 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.txt gets an
    environment.python.requires fallback 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.version for backward compatibility.
  • Tests cover requirements-only projects and explicit-constraint precedence.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con Environment.create_python_environment() e con il percorso di generazione di Manifest descritto nell’issue. Traccia come vengono rilevati i requisiti e come python_version_requirement raggiunge environment.python.requires, quindi aggiungi la copertura per i progetti che contengono solo requirements e per la precedenza dei vincoli espliciti. Il lavoro è completo quando il fallback preserva python.version, consente release patch compatibili e i vincoli espliciti continuano a prevalere.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
cli, tooling
Tipo di issue
Funzionalità
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Attiva
Chiarezza
Abbastanza chiara
Idoneità per principianti
64/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.