Skip to content

Commit

Permalink
chore: fix Python 3.8 compatibility issue (#368)
Browse files Browse the repository at this point in the history
  • Loading branch information
huxuan committed Mar 7, 2024
1 parent 3359947 commit d99abdc
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 6 deletions.
12 changes: 10 additions & 2 deletions .devcontainer/Dockerfile
Expand Up @@ -6,6 +6,10 @@ ARG PYTHON_VERSION=3.12

FROM python:${PYTHON_VERSION} as dev

# NOTE: python docker image has env `PYTHON_VERSION` but with patch version.
# ARG is used here for temporary override without changing the original env.
ARG PYTHON_VERSION

RUN apt-get update && apt-get install -y --no-install-recommends \
# pipx: To install Python applications.
pipx \
Expand All @@ -22,7 +26,11 @@ ENV PIPX_DEFAULT_PYTHON=/usr/local/bin/python
RUN pipx install pdm==2.12.4

# Install pre-commit
RUN pipx install pre-commit==3.6.2
RUN if [ "${PYTHON_VERSION}" = "3.8" ]; then \
pipx install pre-commit==3.5.0; \
else \
pipx install pre-commit==3.6.2; \
fi

# Create a non-root user with sudo permission
ARG USERNAME=ss-python
Expand Down Expand Up @@ -60,7 +68,7 @@ FROM python:${PYTHON_VERSION}-slim as prod

# NOTE: python docker image has env `PYTHON_VERSION` but with patch version.
# ARG is used here for temporary override without changing the original env.
ARG PYTHON_VERSION=3.12
ARG PYTHON_VERSION

# Retrieve packages from build stage.
ENV PYTHONPATH=/workspace/pkgs
Expand Down
10 changes: 9 additions & 1 deletion .renovaterc.json
Expand Up @@ -9,7 +9,7 @@
"^template\\/\\.devcontainer/Dockerfile\\.jinja$"
],
"matchStrings": [
"RUN pipx install (?<depName>.*?)==(?<currentValue>.*?)\n"
"pipx install (?<depName>.*?)==(?<currentValue>.*?)[;\n]"
]
},
{
Expand Down Expand Up @@ -59,6 +59,14 @@
]
},
"semanticCommitScope": "copier-template"
},
{
"description": "Pre-commit 3.5.0 is pinned as the last version supporting Python 3.8.",
"enabled": false,
"matchCurrentVersion": "==3.5.0",
"matchPackageNames": [
"pre-commit"
]
}
]
}
12 changes: 10 additions & 2 deletions template/.devcontainer/Dockerfile.jinja
Expand Up @@ -6,6 +6,10 @@ ARG PYTHON_VERSION={{ default_py }}

FROM python:${PYTHON_VERSION} as dev

# NOTE: python docker image has env `PYTHON_VERSION` but with patch version.
# ARG is used here for temporary override without changing the original env.
ARG PYTHON_VERSION

RUN apt-get update && apt-get install -y --no-install-recommends \
# pipx: To install Python applications.
pipx \
Expand All @@ -22,7 +26,11 @@ ENV PIPX_DEFAULT_PYTHON=/usr/local/bin/python
RUN pipx install pdm==2.12.4

# Install pre-commit
RUN pipx install pre-commit==3.6.2
RUN if [ "${PYTHON_VERSION}" = "3.8" ]; then \
pipx install pre-commit==3.5.0; \
else \
pipx install pre-commit==3.6.2; \
fi

# Create a non-root user with sudo permission
ARG USERNAME={{ repo_name }}
Expand Down Expand Up @@ -60,7 +68,7 @@ FROM python:${PYTHON_VERSION}-slim as prod

# NOTE: python docker image has env `PYTHON_VERSION` but with patch version.
# ARG is used here for temporary override without changing the original env.
ARG PYTHON_VERSION={{ default_py }}
ARG PYTHON_VERSION

# Retrieve packages from build stage.
ENV PYTHONPATH=/workspace/pkgs
Expand Down
11 changes: 10 additions & 1 deletion template/.renovaterc.json.jinja
@@ -1,3 +1,4 @@
[% from pathjoin("includes", "version_compare.jinja") import version_higher_than -%]
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"customManagers": [
Expand All @@ -11,7 +12,7 @@
[%- endif %]
],
"matchStrings": [
"RUN pipx install (?<depName>.*?)==(?<currentValue>.*?)\n"
"pipx install (?<depName>.*?)==(?<currentValue>.*?)[;\n]"
]
},
{
Expand Down Expand Up @@ -65,6 +66,14 @@
]
},
"semanticCommitScope": "copier-template"
},
{
"description": "Pre-commit 3.5.0 is pinned as the last version supporting Python 3.8.",
"enabled": false,
"matchCurrentVersion": "==3.5.0",
"matchPackageNames": [
"pre-commit"
]
}
]
}

0 comments on commit d99abdc

Please sign in to comment.