Skip to content

fix: inspect the project Python environment - #920

Open
tdstein wants to merge 12 commits into
mainfrom
symphony/posit-dev_rsconnect-python_889-e922273cb0dbb9c6
Open

tdstein wants to merge 12 commits into
mainfrom
symphony/posit-dev_rsconnect-python_889-e922273cb0dbb9c6

Conversation

@tdstein

@tdstein tdstein commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

select project Python → inspect from CLI environment → query target Python and freeze its packages
                                                    → render static notebooks with target Python

Resolve uv once for export and pip-free or old-pip environments. Preserve pip's bootstrap exclusions and validate editable dependencies for both freeze paths.

Evidence

  • Before: an activated project environment was ignored and an isolated target could not import the inspector.
  • After: focused environment, manifest, and notebook tests pass on Python 3.14 and 3.8; real pip 20.2.4 compatibility passes.
  • Live Connect acceptance of a manifest without a pip version remains unverified because available credentials failed.

Merge Danger

Door: Two-way

Blast Radius: Deployment environment discovery and generated requirements.

Closes #889

tdstein and others added 9 commits October 27, 2026 17:09
- Pass --python through to deploy quarto.
- Run the inspector and pip with -E instead of -I so user site-packages
  are still visible, from the inspector's directory so a stray pip.py in
  the working directory is not imported.
- Resolve ".." in the project path before searching parents for .venv.
- Fall back to uv on PATH when the bundled uv binary can't be found.
- Report pyproject.toml parse errors with their details.
- Make preflight check the selected interpreter's Python version and
  accept --python, matching deploy.
- Isolate interpreter-lookup and preflight tests from the shell's
  VIRTUAL_ENV, CONDA_PREFIX, and working directory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://posit-dev.github.io/rsconnect-python/pr-preview/pr-920/

Built to branch gh-pages at 2026-11-05 20:33 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

tdstein and others added 2 commits November 5, 2026 14:41
The inspector runs under rsconnect's own interpreter and imports its
dependencies (packaging, toml). Starting it with -I hid user
site-packages and PYTHONPATH, so `pip install --user` and PYTHONPATH
installs failed with "No module named 'packaging'".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Without the flush, Python 3.8 left nbconvert's diagnostics buffered when
the error was raised, failing test_deploy_static_notebook_render_failure.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
11134 9854 89% 0% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
rsconnect/bundle.py 89% 🟢
rsconnect/environment.py 94% 🟢
rsconnect/main.py 87% 🟢
rsconnect/preflight.py 87% 🟢
rsconnect/subprocesses/inspect_environment.py 93% 🟢
TOTAL 90% 🟢

updated for commit: c07c30d by action🐍

@tdstein
tdstein requested review from amol- and joshyam-k November 5, 2026 19:49
Comment thread rsconnect/environment.py

project = pathlib.Path(os.path.abspath(directory or os.curdir))
project_environment = os.environ.get("UV_PROJECT_ENVIRONMENT") or ".venv"
for parent in (project, *project.parents):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 The .venv search keeps going up to the filesystem root, so it can pick up an unrelated environment. The test test_project_environment_lookup_ignores_non_ancestors covers sibling directories, but no test covers an ancestor that is outside the project.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 The requested lookup explicitly includes the deployment directory’s ancestors without a project-root boundary, so this search intentionally continues to the filesystem root. A boundary would change the specified precedence and exclude legitimate parent environments. An explicit --python overrides discovery; I’ll add coverage documenting the ancestor behavior.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tell me a joke

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't programmed jokes into it.


try:
proc = subprocess.Popen(
command = (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 The two branches don't produce equivalent output:

  • Line 199–207: pip freeze silently skips pip, setuptools, wheel, and distribute. That's built-in pip behavior, not something this code asks for.
  • Line 209: uv pip freeze lists every installed distribution, including those four.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inspect the project's Python environment instead of the CLI's (support uv tool install)

2 participants