Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ErrorArgumentParser override of _parse_known_args is incompatible with 3.12.7 #3264

Closed
ludwick opened this issue Nov 8, 2024 · 0 comments · Fixed by #3266
Closed

ErrorArgumentParser override of _parse_known_args is incompatible with 3.12.7 #3264

ludwick opened this issue Nov 8, 2024 · 0 comments · Fixed by #3266
Assignees
Labels
🐛 bug Something isn't working

Comments

@ludwick
Copy link

ludwick commented Nov 8, 2024

  • [ x] I have searched the issue tracker and believe that this is not a duplicate.

Summary: latest pdm is not compatible with python 3.12.7 changes to argparse internals and pdm install will fail on pdm --help execution in ErrorArgumentParser

Steps to reproduce

On Debian Trixie, it is installing python 3.7.12. This can be reproduced with this dockerfile:

# syntax=docker/dockerfile:1

ARG DEBIAN_VERSION=trixie

FROM debian:${DEBIAN_VERSION}-slim AS deb-base

# Include global arg in this stage of the build
ARG BUILD_DIR="/opt/build"
ARG PYSETUP_DIR="${BUILD_DIR}/pysetup"
ARG PDM_HOME="${BUILD_DIR}/pdm"
ARG PDM_VESION=2.19.3

USER root

RUN apt-get update -y \
    && apt-get install -y --no-install-recommends \
      build-essential \
      cmake \
      curl \
      python3-dev \
      python3-pip \
      python3-venv \
      python-is-python3

RUN mkdir -p ${PDM_HOME} 

WORKDIR ${PYSETUP_DIR}

ENV VIRTUAL_ENV="${PYSETUP_DIR}/venv"  \
    PATH="${PYSETUP_DIR}/venv/bin:$PATH" \
    PDM_CHECK_UPDATE=false \
    PDM_NON_INTERACTIVE=1 \
    PATH="${PDM_HOME}/bin:$PATH"

RUN curl -sSLO https://pdm-project.org/install-pdm.py \
    && ( curl -sSL https://pdm-project.org/install-pdm.py.sha256 | shasum -a 256 -c - ) \
    && python install-pdm.py \
    && rm install-pdm.py \
    && pdm --version

Copy the above to a file Dockerfile and run:

docker buildx build --progress plain -f Dockerfile .

Actual behavior

Docker build fails with the following:

#10 [5/5] RUN curl -sSLO https://pdm-project.org/install-pdm.py     && ( curl -sSL https://pdm-project.org/install-pdm.py.sha256 | shasum -a 256 -c - )     && python install-pdm.py     && rm install-pdm.py     && pdm --version
#10 0.468 install-pdm.py: OK
#10 7.533 Traceback (most recent call last):
#10 7.533   File "/opt/build/pdm/bin/pdm", line 8, in <module>
#10 7.533     sys.exit(main())
#10 7.533              ^^^^^^
#10 7.533   File "/opt/build/pdm/venv/lib/python3.12/site-packages/pdm/core.py", line 378, in main
#10 7.533     return core.main(args or sys.argv[1:])
#10 7.533            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#10 7.533   File "/opt/build/pdm/venv/lib/python3.12/site-packages/pdm/core.py", line 244, in main
#10 7.533     options = self.parser.parse_args(args)
#10 7.533               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#10 7.533   File "/usr/lib/python3.12/argparse.py", line 1918, in parse_args
#10 7.533     args, argv = self.parse_known_args(args, namespace)
#10 7.533                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#10 7.533   File "/opt/build/pdm/venv/lib/python3.12/site-packages/pdm/cli/utils.py", line 152, in parse_known_args
#10 7.534     args, argv = super().parse_known_args(args, namespace)
#10 7.534                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#10 7.534   File "/usr/lib/python3.12/argparse.py", line 1928, in parse_known_args
#10 7.534     return self._parse_known_args2(args, namespace, intermixed=False)
#10 7.534            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#10 7.534   File "/usr/lib/python3.12/argparse.py", line 1957, in _parse_known_args2
#10 7.534     namespace, args = self._parse_known_args(args, namespace, intermixed)
#10 7.534                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#10 7.534 TypeError: ErrorArgumentParser._parse_known_args() takes 3 positional arguments but 4 were given
#10 7.558 Installing PDM (2.20.0.post1): Creating virtual environment
#10 7.558 Installing PDM (2.20.0.post1): Installing PDM and dependencies
#10 7.558 Installing PDM (2.20.0.post1): Making binary at /opt/build/pdm/bin
#10 7.558 Traceback (most recent call last):
#10 7.558   File "/opt/build/pysetup/install-pdm.py", line 473, in <module>
#10 7.559     main()
#10 7.559   File "/opt/build/pysetup/install-pdm.py", line 469, in main
#10 7.559     installer.install()
#10 7.559   File "/opt/build/pysetup/install-pdm.py", line 378, in install
#10 7.559     self._post_install(venv, bin_dir)
#10 7.559   File "/opt/build/pysetup/install-pdm.py", line 348, in _post_install
#10 7.559     subprocess.check_call([str(script), "--help"])
#10 7.559   File "/usr/lib/python3.12/subprocess.py", line 413, in check_call
#10 7.559     raise CalledProcessError(retcode, cmd)
#10 7.559 subprocess.CalledProcessError: Command '['/opt/build/pdm/bin/pdm', '--help']' returned non-zero exit status 1.
#10 ERROR: process "/bin/sh -c curl -sSLO https://pdm-project.org/install-pdm.py     && ( curl -sSL https://pdm-project.org/install-pdm.py.sha256 | shasum -a 256 -c - )     && python install-pdm.py     && rm install-pdm.py     && pdm --version" did not complete successfully: exit code: 1
------
 > [5/5] RUN curl -sSLO https://pdm-project.org/install-pdm.py     && ( curl -sSL https://pdm-project.org/install-pdm.py.sha256 | shasum -a 256 -c - )     && python install-pdm.py     && rm install-pdm.py     && pdm --version:
7.559     main()
7.559   File "/opt/build/pysetup/install-pdm.py", line 469, in main
7.559     installer.install()
7.559   File "/opt/build/pysetup/install-pdm.py", line 378, in install
7.559     self._post_install(venv, bin_dir)
7.559   File "/opt/build/pysetup/install-pdm.py", line 348, in _post_install
7.559     subprocess.check_call([str(script), "--help"])
7.559   File "/usr/lib/python3.12/subprocess.py", line 413, in check_call
7.559     raise CalledProcessError(retcode, cmd)
7.559 subprocess.CalledProcessError: Command '['/opt/build/pdm/bin/pdm', '--help']' returned non-zero exit status 1.
------
Dockerfile.tst:35
--------------------
  34 |
  35 | >>> RUN curl -sSLO https://pdm-project.org/install-pdm.py \
  36 | >>>     && ( curl -sSL https://pdm-project.org/install-pdm.py.sha256 | shasum -a 256 -c - ) \
  37 | >>>     && python install-pdm.py \
  38 | >>>     && rm install-pdm.py \
  39 | >>>     && pdm --version
  40 |
--------------------
ERROR: failed to solve: process "/bin/sh -c curl -sSLO https://pdm-project.org/install-pdm.py     && ( curl -sSL https://pdm-project.org/install-pdm.py.sha256 | shasum -a 256 -c - )     && python install-pdm.py     && rm install-pdm.py     && pdm --version" did not complete successfully: exit code: 1

Expected behavior

It should succeed building docker and build the image with python & pdm installed.

Environment Information

N/A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants