Skip to content

Resolve docker hiccups around regexp build#1101

Open
ahouseholder wants to merge 7 commits intomainfrom
maybe-fix-1067-with-1065
Open

Resolve docker hiccups around regexp build#1101
ahouseholder wants to merge 7 commits intomainfrom
maybe-fix-1067-with-1065

Conversation

@ahouseholder
Copy link
Copy Markdown
Contributor

This PR


This pull request refactors how namespace pattern regular expressions are generated and used within the project. Instead of generating these patterns dynamically at runtime using the abnf-to-regexp library, the patterns are now generated ahead of time and stored in a dedicated, auto-generated Python file. This change simplifies the runtime dependencies and setup, and moves the abnf-to-regexp dependency to development only. The Makefile and Dockerfile are updated to ensure the generated patterns file is always up to date before running development, tests, or documentation.

Key changes include:

Namespace pattern generation and usage:

  • Namespace regex patterns are now auto-generated into src/ssvc/utils/namespace_patterns.py at build time using a Makefile rule, rather than generated dynamically at runtime. The runtime code now imports these pre-generated patterns. [1] [2] [3] [4]

Dependency management:

  • The abnf-to-regexp dependency is moved from the main dependencies list to the development dependencies group in pyproject.toml, so it is no longer installed in production environments. [1] [2]
  • The Dockerfile is updated to ensure only production dependencies are installed in the main image, and development dependencies (including abnf-to-regexp) are installed only in the test image.

Build and test process:

  • The Makefile is updated so that all development, test, documentation, and API commands depend on the generated src/ssvc/utils/namespace_patterns.py file, ensuring it is always up to date before these tasks run.

Minor code cleanup:

  • Small formatting and copyright/license header adjustments in src/ssvc/utils/patterns.py.

These changes improve reliability and reproducibility by ensuring regular expressions are always up to date and by reducing unnecessary runtime dependencies.

bernhardreiter and others added 5 commits February 19, 2026 16:41
 * add abnf-to-regexp as requirement
 * split namespace_patterns.py out from patterns.py as file that can
   be generated fully
 * add Makefile rule
 * add autogeneration warning to namespace_patterns.py

resolve #899
… namespace_patterns.py

- Move abnf-to-regexp from runtime to dev dependency group in pyproject.toml
- Replace dynamic ABNF parsing in patterns.py with static import from
  namespace_patterns.py (no runtime dependency on abnf-to-regexp)
- Add namespace_patterns.py with pre-generated static regex patterns
- Add Makefile rule to regenerate namespace_patterns.py from ABNF source
- Add --no-dev to 'uv sync --frozen' in Dockerfile dependencies stage so
  abnf-to-regexp (and its sdist-only regex==2021.4.4 dep) are not installed
  in production images
- Add gcc+libc-dev to test stage for compiling regex when running dev sync

Fixes docker-compose --project-directory docker build --no-cache

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 27, 2026 18:21
@ahouseholder ahouseholder requested a review from sei-renae March 27, 2026 18:21
@ahouseholder ahouseholder changed the title Maybe fix 1067 with 1065 Resolve docker hiccups around regexp build Mar 27, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors SSVC namespace regex handling by switching from runtime ABNF parsing to build-time generation of a committed Python module, while adjusting dependency groups and Docker/Make targets to keep builds working without production installing abnf-to-regexp.

Changes:

  • Replace runtime ABNF-to-regexp execution with import of pre-generated namespace_patterns.py.
  • Move abnf-to-regexp to dev dependencies only (and update lockfile accordingly).
  • Update Makefile and Dockerfile to align generation/install steps with the new approach.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
uv.lock Moves abnf-to-regexp from main deps to dev deps in the lock metadata.
pyproject.toml Moves abnf-to-regexp into [dependency-groups].dev.
src/ssvc/utils/patterns.py Stops runtime ABNF parsing and instead imports pre-generated namespace regex components.
src/ssvc/utils/namespace_patterns.py Adds the generated namespace regex components module.
Makefile Adds/threads a generation rule for namespace_patterns.py into common targets.
docker/Dockerfile Installs only prod deps in the main image and dev deps in the test image, adding build tooling for tests.

Comment on lines +14 to 20
src/ssvc/utils/namespace_patterns.py: src/ssvc/utils/ssvc_namespace_pattern.abnf
echo "# AUTOGENERATED, DO NOT CHANGE manually, see Makefile" >$@
uv run abnf-to-regexp --format python-nested -i $< >>$@

dev: src/ssvc/utils/namespace_patterns.py
@echo "Set up dev environment..."
uv sync --dev
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

make dev now depends on src/ssvc/utils/namespace_patterns.py, but generating that file runs uv run abnf-to-regexp before uv sync --dev executes. Since abnf-to-regexp is a dev-only dependency, a fresh checkout is likely to fail when running make dev. Consider generating the file after uv sync --dev (e.g., call $(MAKE) from the recipe) or otherwise ensuring the dev dependency is available before invoking abnf-to-regexp (and using $(UV_RUN) for consistency).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

@sei-renae sei-renae Mar 27, 2026

Choose a reason for hiding this comment

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

@ahouseholder see the copilot suggestion pls

Comment on lines +1 to +5
# AUTOGENERATED, DO NOT CHANGE manually, see Makefile
alnum = '[a-zA-Z0-9]'
lower = '[a-z]'
alnumlow = f'({lower}|[0-9])'
dash = '-'
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

This new generated Python module does not include the standard CMU copyright/license header that appears to be present in essentially all other src/ssvc/**/*.py files (including other generated helpers). If the project requires that header in distributed source files, update the generation rule (Makefile) to emit the full header before the autogenerated content so the generated file stays compliant.

Copilot uses AI. Check for mistakes.
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.

@ahouseholder can we configure the makefile to add the legalese?

ahouseholder and others added 2 commits March 27, 2026 14:47
- Create separate 'codegen' dependency group for abnf-to-regexp so that
  'uv sync --frozen --dev' in the test Docker stage does NOT pull in
  abnf-to-regexp (and its sdist-only regex==2021.4.4 dependency that
  requires gcc to build)
- Update uv.lock to reflect codegen group membership
- Remove gcc/libc6-dev from test Docker stage (no longer needed)
- Add --no-sync to all 'uv run' CMD instructions in Dockerfile so
  containers don't re-sync on startup (which would pull dev/codegen deps)
- Update Makefile to invoke abnf-to-regexp via --group codegen

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@sei-renae sei-renae left a comment

Choose a reason for hiding this comment

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

it builds, but I've got a couple of concerns in the comments.

Comment on lines +1 to +5
# AUTOGENERATED, DO NOT CHANGE manually, see Makefile
alnum = '[a-zA-Z0-9]'
lower = '[a-z]'
alnumlow = f'({lower}|[0-9])'
dash = '-'
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.

@ahouseholder can we configure the makefile to add the legalese?

Comment on lines +14 to 20
src/ssvc/utils/namespace_patterns.py: src/ssvc/utils/ssvc_namespace_pattern.abnf
echo "# AUTOGENERATED, DO NOT CHANGE manually, see Makefile" >$@
uv run abnf-to-regexp --format python-nested -i $< >>$@

dev: src/ssvc/utils/namespace_patterns.py
@echo "Set up dev environment..."
uv sync --dev
Copy link
Copy Markdown
Contributor

@sei-renae sei-renae Mar 27, 2026

Choose a reason for hiding this comment

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

@ahouseholder see the copilot suggestion pls

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.

4 participants