Skip to content

fix: pass --package-installer to write-manifest <framework> and deploy quarto - #877

Open
pcbeingused333 wants to merge 1 commit into
posit-dev:mainfrom
pcbeingused333:fix/package-installer-write-manifest-quarto
Open

pcbeingused333 wants to merge 1 commit into
posit-dev:mainfrom
pcbeingused333:fix/package-installer-write-manifest-quarto

Conversation

@pcbeingused333

Copy link
Copy Markdown

Part 1 of #852; the second part of that issue (click >= 8.2 Choice matching) is noted at the end.

--package-installer is accepted by write-manifest <framework> (streamlit|dash|bokeh|panel|shiny|api|fastapi|flask) and by deploy quarto, but both code paths drop it before calling Environment.create_python_environment. The other commands from #708 pass package_manager=package_installer. As a result rsconnect write-manifest shiny --package-installer uv ./app exits 0 and writes python.package_manager.name: pip into manifest.json.

What changed. package_manager=package_installer is now passed in the create_python_environment calls in _write_framework_manifest and deploy_quarto (2 lines), plus a CHANGELOG entry.

Tests. New tests/test_package_installer.py drives the CLI with CliRunner:

  • write-manifest for shiny, streamlit and fastapi with --package-installer uv|pip asserts the value reaches create_python_environment and that manifest["python"]["package_manager"]["name"] matches.
  • deploy quarto --package-installer uv (with create_python_environment, Quarto and the executor mocked) asserts the value is forwarded.

All 7 cases fail on main and pass with the change. ruff format --check and ruff check are clean. The rest of the suite passes; the failures seen were environment-dependent and unrelated to this change (test_quickstart.py tests that boot a process or need a writable cwd, which fail the same way on main, plus one intermittent timing test in tests/test_agent_cli_e2e.py).

Not included. Part 2 of the issue (click.Choice(PackageInstaller) matching by name instead of value on click >= 8.2, so uv is rejected) is a maintainer decision (click.Choice(["pip", "uv"]) plus conversion, or bounding click), so it is left as a possible follow-up.

This change was made with Claude Code.

🤖 Generated with Claude Code

…y quarto

`_write_framework_manifest` and `deploy_quarto` accepted `package_installer`
but never forwarded it to `Environment.create_python_environment`, so
`write-manifest shiny --package-installer uv` wrote `package_manager: pip`.
The other commands already pass `package_manager=package_installer`.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@karawoo karawoo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

thanks for the PR, I think the logic looks right but the tests need a few small tweaks

from .utils import apply_common_args


def _fake_create(captured: dict[str, typing.Any]):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

could you please update this to work against python 3.8?

assert result.exit_code == 0, result.output
assert captured["package_manager"].value == installer
manifest = json.loads((tmp_path / "manifest.json").read_text())
assert manifest["python"]["package_manager"]["name"] == installer

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This mostly tests the fake, since the fake builds the environment from the kwarg it was passed. It also misses allow_uv, which the real create_python_environment sets. Could you mock Environment._get_python_env_info instead and assert both name and allow_uv?

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.

3 participants