Skip to content

fix static notebook deploy passing python version string instead of interpreter path#820

Merged
karawoo merged 4 commits into
mainfrom
kara-fix-static
Jul 14, 2026
Merged

fix static notebook deploy passing python version string instead of interpreter path#820
karawoo merged 4 commits into
mainfrom
kara-fix-static

Conversation

@karawoo

@karawoo karawoo commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Intent

rsconnect deploy notebook --static runs nbconvert locally to render the notebook before bundling it. Since #648, that call was passed environment.python, which is the Python version string recorded for the manifest (e.g. 3.12.1), not an interpreter path. nbconvert was invoked as a subprocess named 3.12.1, so every static notebook deploy failed with Unable to include the file 3.12.1 in the bundle: No such file or directory.

Fixes #721

Approach

Use environment.python_interpreter (the resolved executable path, defaulting to sys.executable) instead of environment.python.

Automated Tests

Added a regression test that deploys a static notebook with --override-python-version set to a value that would visibly diverge from the real interpreter path, and asserts nbconvert is invoked with the real path. Confirmed it fails without the fix.

Directions for Reviewers

Checklist

  • I have updated CHANGELOG.md to cover notable changes.
  • I have updated all related GitHub issues to reflect their current state.
  • I have run the rsconnect-python-tests-at-night workflow in Connect against this feature branch.

karawoo added 2 commits July 13, 2026 14:39
…nterpreter path

deploy_notebook passed environment.python (the manifest Python version
string, e.g. 3.12.1) to make_notebook_html_bundle instead of
environment.python_interpreter (the resolved executable path), so nbconvert
was invoked as a subprocess named 3.12.1 and failed with ENOENT.

Fixes #721
@karawoo karawoo requested a review from a team July 13, 2026 21:42
@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-07-14 19:07 UTC

@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
7636 6352 83% 0% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
rsconnect/main.py 81% 🟢
TOTAL 81% 🟢

updated for commit: fe56dd7 by action🐍

Comment thread tests/test_main.py Outdated
@edavidaja

Copy link
Copy Markdown
Collaborator

I was having some difficulty discerning the intent of the tests relative to the fix, 🤖 suggested something like:

import sys
from os.path import join
from types import SimpleNamespace
from unittest import mock

from click.testing import CliRunner

from rsconnect.main import cli, make_notebook_html_bundle
from tests.utils import apply_common_args, get_dir


def test_deploy_notebook_static_passes_interpreter_not_version():
    # Regression test for #721. For a static notebook deploy, deploy_notebook must
    # hand make_notebook_html_bundle the local interpreter *path* (used to run
    # nbconvert), not environment.python, which is only a version string and would
    # make nbconvert fail with "No such file or directory".
    #
    # In practice these always diverge: environment.python comes from
    # sys.version_info ("3.12.1"), environment.python_interpreter from sys.executable.
    fake_env = SimpleNamespace(python="3.12.1", python_interpreter=sys.executable)

    with mock.patch(
        "rsconnect.main.Environment.create_python_environment", return_value=fake_env
    ), mock.patch("rsconnect.main.RSConnectExecutor") as MockExecutor:
        ce = MockExecutor.return_value

        runner = CliRunner()
        args = apply_common_args(
            ["deploy", "notebook", get_dir(join("pip1", "dummy.ipynb"))],
            server="http://fake_server",
            key="FAKE_API_KEY",
        )
        args += ["--static", "--no-verify"]
        result = runner.invoke(cli, args)

    assert result.exit_code == 0, result.output
    # make_bundle(make_notebook_html_bundle, file, <python>, hide_all, hide_tagged)
    bundle_args = ce.make_bundle.call_args.args
    assert bundle_args[0] is make_notebook_html_bundle
    assert bundle_args[2] == sys.executable

@karawoo karawoo merged commit a93d535 into main Jul 14, 2026
22 checks passed
@karawoo karawoo deleted the kara-fix-static branch July 14, 2026 19:07
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.

When deploying Jupyter notebooks --static doesn't work.

3 participants