Skip to content

Add configurable port and browser behavior for autobuild#405

Open
conradolandia wants to merge 1 commit intospyder-ide:masterfrom
conradolandia:autobuild-errors
Open

Add configurable port and browser behavior for autobuild#405
conradolandia wants to merge 1 commit intospyder-ide:masterfrom
conradolandia:autobuild-errors

Conversation

@conradolandia
Copy link
Copy Markdown
Contributor

@conradolandia conradolandia commented Mar 23, 2026

Pull Request Checklist

  • Read and followed this repo's Contributing Guidelines
  • Based your PR on the latest version of the correct branch (master or 4.x)
  • Checked your writing carefully for correct English spelling, grammar, etc
  • Described your changes and the motivation for them below
  • Noted what issue(s) this pull request resolves, creating one if needed

Description of Changes

This PR adds noxfile options so developers can choose the port and browser behavior for autobuild sessions.

By default, the autobuild session now serves docs on port 8000 (instead of a random port) and opens the default browser. You can override this behavior with environment variables:

SPYDER_DOCS_AUTOBUILD_PORT=8765 nox -s autobuild
SPYDER_DOCS_AUTOBUILD_OPEN_BROWSER=0 nox -s autobuild

This behavior is documented in CONTRIBUTING.md.

Motivation

This change makes autobuild more predictable while keeping it flexible. A fixed default port (8000, which is commonly used in local development setups) simplifies repeated local runs and integration with local tooling. Environment-variable overrides still allow custom setups, including alternate ports and workflows where opening a browser is not desired.

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 23, 2026

Deploy Preview for spyder-docs-preview ready!

Name Link
🔨 Latest commit 65c54da
🔍 Latest deploy log https://app.netlify.com/projects/spyder-docs-preview/deploys/69c1940964d6fb0007223cfe
😎 Deploy Preview https://deploy-preview-405--spyder-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Copy Markdown
Member

@CAM-Gerlach CAM-Gerlach left a comment

Choose a reason for hiding this comment

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

While I certainly understand the motivation for making the port and open browser behavior configurable, and I'm not fundamentally opposed to using environment variables for doing that, every other configurable nox command we have (and we have many) does so via CLI options rather than env variables, so it seems inconsistent to treat nox -s autobuild as a special case and require long, verbose env vars to configure them. Furthermore, this is also inconsistent with our nox -s serve command, which exposes the exact same potentially configurable behavior (serving on a port and opening that in the browser) but lacks this novel configuration technique.

To be simpler and more consistent for users, at least for now instead of all this we should just read the config from CLI args (using the existing extract_option_values helper as necessary), and do so in nox -s serve as well, in addition to using a consistent default for both of them.

Comment on lines 48 to +49
SERVE_PORT = 5000
AUTOBUILD_PORT = 8000
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there a legitimate reason why SERVE_PORT and AUTOBUILD_PORT need to be different here? Can they not just use a common SERVE_PORT, and the port for nox -s serve be configurable via the same mechanism as that for nox -s autobuild?

Comment on lines 133 to 144
return filenames


def env_var_to_bool(var_name, *, default):
"""Convert an environment variable to bool with common false values."""
value = os.environ.get(var_name)
if value is None:
return default
return value.strip().lower() not in {"0", "false", "no", "off"}


def extract_option_values(options, option_names, *, split_csv=False):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
return filenames
def env_var_to_bool(var_name, *, default):
"""Convert an environment variable to bool with common false values."""
value = os.environ.get(var_name)
if value is None:
return default
return value.strip().lower() not in {"0", "false", "no", "off"}
def extract_option_values(options, option_names, *, split_csv=False):
return filenames
def extract_option_values(options, option_names, *, split_csv=False):

Not needed anymore if we just use CLI args, like everything else in here does.

Comment on lines +445 to +450
autobuild_port = os.environ.get(
AUTOBUILD_PORT_ENV_VAR, str(AUTOBUILD_PORT)
)
open_browser = env_var_to_bool(
AUTOBUILD_OPEN_BROWSER_ENV_VAR, default=True
)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
autobuild_port = os.environ.get(
AUTOBUILD_PORT_ENV_VAR, str(AUTOBUILD_PORT)
)
open_browser = env_var_to_bool(
AUTOBUILD_OPEN_BROWSER_ENV_VAR, default=True
)
ports = extract_option_values(posargs, "--port")[0]
autobuild_port = port[-1] if ports else SERVE_PORT
open_browser = "--no-browser" not in posargs

Just use CLI args for this instead

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants