Skip to content

[build] Stop installing python3-regex via apt to avoid pip uninstall-no-record-file failure#28144

Merged
yijingyan2 merged 1 commit into
sonic-net:masterfrom
yijingyan2:regex-fix
Jun 30, 2026
Merged

[build] Stop installing python3-regex via apt to avoid pip uninstall-no-record-file failure#28144
yijingyan2 merged 1 commit into
sonic-net:masterfrom
yijingyan2:regex-fix

Conversation

@yijingyan2

@yijingyan2 yijingyan2 commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Why I did it

target/python-wheels/trixie/sonic_utilities-1.2-py3-none-any.whl-install and sonic-marvell-prestera-armhf.bin started failing during the sonic-utilities wheel install with:

Cannot uninstall regex 2024.11.6
╰─> The package's contents are unknown: no RECORD file was found for regex.

 hint: The package was installed by debian. You should check if it can uninstall the package.

sonic-slave-trixie and sonic_debian_extension installed python3-regex from debian apt repo in dist-packages folder without a pip RECORD file, so pip cannot uninstall it later.
When the sonic-utilities wheel pulls in a newer regex - currently triggered by sonic-utilities -> docker-image-py (the unbounded docker-image-py>=0.1.10 dependency now resolves to 0.2.0, published 2026-06-29, which requires regex>=2026.6.28) - pip failed on uninstall-no-record-file.

Work item tracking
  • Microsoft ADO (number only):

How I did it

  • removed python3-regex from sonic-slave-trixie/Dockerfile.j2
  • remove python3-regex from sonic_debian_extension.j2

How to verify it

Which release branch to backport (provide reason below if selected)

  • 202305
  • 202311
  • 202405
  • 202411
  • 202505
  • 202511
  • 202512
  • 202605
  • 202608

Tested branch (Please provide the tested image version)

Description for the changelog

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

…d-file failure

Signed-off-by: Yijing Yan <yijingyan@microsoft.com>
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

securely1g added a commit to securely1g/sonic-buildimage that referenced this pull request Jun 29, 2026
TEMPORARY: pulls the build-infra fix from sonic-net#28144
(author: yijingyan2) to unblock this PR's CI. The shared 'Build sonic image'
stage currently fails on ALL platforms with:

    Cannot uninstall regex 2024.11.6 ... no RECORD file was found for regex
    hint: The package was installed by debian

because python3-regex is apt-installed without a pip RECORD, so pip cannot
upgrade it when the sonic-utilities wheel (via docker-image-py) requires a
newer regex. This is unrelated to this PR's docker-sonic-vs changes.

DROP THIS COMMIT on the next rebase once sonic-net#28144 has merged into master.

Original-change-by: yijingyan2
Ref: sonic-net#28144
Signed-off-by: securely1g <securely1g@users.noreply.github.com>
@yijingyan2
yijingyan2 marked this pull request as ready for review June 30, 2026 01:29
@yijingyan2
yijingyan2 requested a review from lguohan as a code owner June 30, 2026 01:29
Copilot AI review requested due to automatic review settings June 30, 2026 01:29

Copilot AI left a comment

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.

Pull request overview

This PR updates the SONiC build environment/templates to avoid installing python3-regex via Debian apt, preventing pip failures when a wheel later needs to upgrade regex (pip cannot uninstall the apt-installed package due to missing RECORD metadata).

Changes:

  • Removes python3-regex installation from the Debian extension template to let pip resolve/install regex via Python dependencies.
  • Adds a cleanup step in the trixie build slave image to remove python3-regex if present, avoiding apt vs pip ownership conflicts.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
sonic-slave-trixie/Dockerfile.j2 Removes python3-regex from the build slave image to avoid pip uninstall/upgrade conflicts.
files/build_templates/sonic_debian_extension.j2 Stops installing python3-regex via apt in the target filesystem, documenting the pip RECORD conflict rationale.

Comment on lines +549 to +550
# Let pip own these (avoid apt vs pip no-RECORD uninstall conflicts)
RUN eatmydata apt-get remove -y python3-regex || true

@lunyue-ms lunyue-ms left a comment

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.

LGTM

@mssonicbld

Copy link
Copy Markdown
Collaborator

Cherry-pick PR to 202511: #28180

@mssonicbld

Copy link
Copy Markdown
Collaborator

Cherry-pick PR to 202605: #28182

securely1g added a commit to securely1g/sonic-buildimage that referenced this pull request Jul 1, 2026
TEMPORARY: pulls the build-infra fix from sonic-net#28144
(author: yijingyan2) to unblock this PR's CI. The shared 'Build sonic image'
stage currently fails on ALL platforms with:

    Cannot uninstall regex 2024.11.6 ... no RECORD file was found for regex
    hint: The package was installed by debian

because python3-regex is apt-installed without a pip RECORD, so pip cannot
upgrade it when the sonic-utilities wheel (via docker-image-py) requires a
newer regex. This is unrelated to this PR's docker-sonic-vs changes.

DROP THIS COMMIT on the next rebase once sonic-net#28144 has merged into master.

Original-change-by: yijingyan2
Ref: sonic-net#28144
Signed-off-by: securely1g <securely1g@users.noreply.github.com>
@mssonicbld

Copy link
Copy Markdown
Collaborator

Cherry-pick PR to msft-202608: Azure/sonic-buildimage-msft#2584

@mssonicbld

Copy link
Copy Markdown
Collaborator

This PR is approved for branch msft-202607. No cherry pick PR has been created because of code conflict. @yijingyan2, please manually create the cherry pick PR.
If this change is already in msft-202607, please comment "already in msft-202607". Thanks!

---Powered by SONiC BuildBot

mssonicbld added a commit to sonic-net/sonic-utilities that referenced this pull request Jul 10, 2026
…re/sonic' in registry test (#4674)

#### What I did

`docker-image-py` was pulled in unpinned (`docker-image-py>=0.1.10`). When **0.2.0** was released (2026-06-29) it changed `Reference.split_docker_domain()` to treat an uppercase first path component as a registry domain (Docker Hub repository names must be lowercase). This broke `tests/sonic_package_manager/test_registry.py::test_get_registry_for`, which resolved the reference `Azure/sonic`.

The key point is that `Azure/sonic` is **not a valid Docker Hub reference** in the first place — Docker Hub namespaces must be lowercase (`Azure/...` is rejected as an invalid namespace). So instead of pinning `docker-image-py` to `==0.1.13` (#4660) or reimplementing `split_docker_domain()`, this change simply fixes the test to use the valid lowercase reference `azure/sonic` and drops the pin (`>=0.1.10`), so registry resolution and the test are correct regardless of the installed `docker-image-py` version and the build can adopt 0.2.0. It pairs with sonic-net/sonic-buildimage#28144, which stops installing `python3-regex` via apt so 0.2.0's `regex>=2026.6.28` installs cleanly.

#### How I did it

- `setup.py`: `docker-image-py==0.1.13` → `docker-image-py>=0.1.10` (drop the pin added in #4660).
- `tests/sonic_package_manager/test_registry.py`: `resolver.get_registry_for('Azure/sonic')` → `resolver.get_registry_for('azure/sonic')`.

#### How to verify it

Run the package-manager registry test with `docker-image-py` 0.2.0 installed:

```
pytest tests/sonic_package_manager/test_registry.py::test_get_registry_for
```

It passes (CI green) — `azure/sonic` resolves to the `DockerHubRegistry` singleton regardless of the `docker-image-py` version.

#### Previous command output (if the output of a command-line utility has changed)

N/A - no user-facing command output changes.

#### New command output (if the output of a command-line utility has changed)

N/A - no user-facing command output changes.

Signed-off-by: Sonic Build Admin <sonicbld@microsoft.com>
roger-nexthop pushed a commit to nexthop-ai/sonic-buildimage that referenced this pull request Jul 12, 2026
…no-record-file failure (sonic-net#28144)

Signed-off-by: Yijing Yan <yijingyan@microsoft.com>
mssonicbld added a commit to Azure/sonic-utilities.msft that referenced this pull request Jul 13, 2026
…re/sonic' in registry test (#394)

#### What I did

`docker-image-py` was pulled in unpinned (`docker-image-py>=0.1.10`). When **0.2.0** was released (2026-06-29) it changed `Reference.split_docker_domain()` to treat an uppercase first path component as a registry domain (Docker Hub repository names must be lowercase). This broke `tests/sonic_package_manager/test_registry.py::test_get_registry_for`, which resolved the reference `Azure/sonic`.

The key point is that `Azure/sonic` is **not a valid Docker Hub reference** in the first place — Docker Hub namespaces must be lowercase (`Azure/...` is rejected as an invalid namespace). So instead of pinning `docker-image-py` to `==0.1.13` (#4660) or reimplementing `split_docker_domain()`, this change simply fixes the test to use the valid lowercase reference `azure/sonic` and drops the pin (`>=0.1.10`), so registry resolution and the test are correct regardless of the installed `docker-image-py` version and the build can adopt 0.2.0. It pairs with sonic-net/sonic-buildimage#28144, which stops installing `python3-regex` via apt so 0.2.0's `regex>=2026.6.28` installs cleanly.

#### How I did it

- `setup.py`: `docker-image-py==0.1.13` → `docker-image-py>=0.1.10` (drop the pin added in #4660).
- `tests/sonic_package_manager/test_registry.py`: `resolver.get_registry_for('Azure/sonic')` → `resolver.get_registry_for('azure/sonic')`.

#### How to verify it

Run the package-manager registry test with `docker-image-py` 0.2.0 installed:

```
pytest tests/sonic_package_manager/test_registry.py::test_get_registry_for
```

It passes (CI green) — `azure/sonic` resolves to the `DockerHubRegistry` singleton regardless of the `docker-image-py` version.

#### Previous command output (if the output of a command-line utility has changed)

N/A - no user-facing command output changes.

#### New command output (if the output of a command-line utility has changed)

N/A - no user-facing command output changes.

Signed-off-by: Sonic Build Admin <sonicbld@microsoft.com>
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.

8 participants