pendulum icon indicating copy to clipboard operation
pendulum copied to clipboard

Segmentation fault at import when running 3.0.0 under Docker Alpine linux

Open EmilBode opened this issue 2 years ago • 8 comments

  • [X] I am on the latest Pendulum version: 3.0.0

  • [X] I have searched the issues of this repo and believe that this is not a duplicate.

  • OS version and name:

    • Host system: Windows 10 22H2
    • Docker version: 4.17.1 (101757)
    • Docker container: Alpine Linux 3.16.0
    • CPython: 3.10.4
  • Pendulum version: 3.0.0

    • I first downloaded the needed files with pip download pendulum -d <temp-folder> --platform=musllinux_1_1_x86_64 --python-version=310 --only-binary=:all:
    • Then started my docker-container with docker run -it -v <temp-folder>:/packages/ pythonimage /bin/ash
    • Installed pendulum with pip install --no-index --find-links /packages pendulum

Issue

After installing pendulum 3.0.0, I simply started a python-session and ran import pendulum. At which point I immediately got a message "Segmentation fault", and my session was ended.

The same setup, except with stating pendulum!=3.0.0 caused pendulum 2.1.2 to be installed, which ran without any problems.

EmilBode avatar Dec 19 '23 14:12 EmilBode

same issue with python:3.12-alpine

fridayy avatar Dec 11 '24 07:12 fridayy

Facing the same issue. Any update or workaround on how to fix this?

bmg02 avatar Dec 17 '24 21:12 bmg02

https://github.com/Flexget/Flexget/issues/4085 ... using pythonXX-alpine3.20 worked for me

lordoffreaks avatar Jan 10 '25 12:01 lordoffreaks

python 3.12 alpine seems to be working but not 3.13

3.12:

❯ docker run -it ghcr.io/astral-sh/uv:0.6.6-python3.12-alpine sh
/ # uv init app
Initialized project `app` at `/app`
/ # cd app
/app # uv add pendulum
Using CPython 3.12.9 interpreter at: /usr/local/bin/python3.12
Creating virtual environment at: .venv
Resolved 6 packages in 1.53s
Prepared 5 packages in 2.10s
Installed 5 packages in 7ms
 + pendulum==3.0.0
 + python-dateutil==2.9.0.post0
 + six==1.17.0
 + time-machine==2.16.0
 + tzdata==2025.1

3.13:

❯ docker run -it ghcr.io/astral-sh/uv:0.6.6-python3.13-alpine sh
/ # uv init app
Initialized project `app` at `/app`
/ # cd app
/app # uv add pendulum
Using CPython 3.13.2 interpreter at: /usr/local/bin/python3.13
Creating virtual environment at: .venv
Resolved 6 packages in 1.74s
  x Failed to build `pendulum==3.0.0`
  |-> The build backend returned an error
  `-> Call to `maturin.build_wheel` failed (exit status: 1)

      [stdout]
      Running `maturin pep517 build-wheel -i /root/.cache/uv/builds-v0/.tmpL3MsHx/bin/python --compatibility off`

      [stderr]
      💥 maturin failed
        Caused by: Cargo metadata failed. Do you have cargo in your PATH?
        Caused by: No such file or directory (os error 2)
      Error: command ['maturin', 'pep517', 'build-wheel', '-i', '/root/.cache/uv/builds-v0/.tmpL3MsHx/bin/python', '--compatibility', 'off'] returned
      non-zero exit status 1

      hint: This usually indicates a problem with the package or the build environment.
  help: If you want to add the package regardless of the failed resolution, provide the `--frozen` flag to skip locking and syncing.

redbmk avatar Mar 13 '25 20:03 redbmk

Reproducible with the wheel file published on https://pypi.org/project/pendulum/#files and with python:3.12-alpine3.21 Docker image.

hongquan avatar Mar 24 '25 14:03 hongquan

Getting the same issue with uv on Windows 11 and Python 3.13.

uv add pendulum
Resolved 66 packages in 120ms
      Built aqi-api @ file:///D:/Dev/aqi_api                                                                                                                                                                   × Failed to build `pendulum==3.0.0`
  ├─▶ The build backend returned an error
  ╰─▶ Call to `maturin.build_wheel` failed (exit code: 1)

      [stdout]
      Running `maturin pep517 build-wheel -i C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmp3svbUC\Scripts\python.exe --compatibility off`

      [stderr]
      error: process didn't exit successfully: `rustc -vV` (exit code: 1)
      --- stderr
      error: the 'rustc.exe' binary, normally provided by the 'rustc' component, is not applicable to the 'stable-x86_64-pc-windows-msvc' toolchain

      💥 maturin failed
        Caused by: Cargo metadata failed. Does your crate compile with `cargo build`?
        Caused by: `cargo metadata` exited with an error:
      Error: command ['maturin', 'pep517', 'build-wheel', '-i', 'C:\\Users\\user\\AppData\\Local\\uv\\cache\\builds-v0\\.tmp3svbUC\\Scripts\\python.exe', '--compatibility', 'off'] returned non-zero exit  
      status 1

      hint: This usually indicates a problem with the package or the build environment.
  help: If you want to add the package regardless of the failed resolution, provide the `--frozen` flag to skip locking and syncing.

IlanOptinum avatar Mar 26 '25 15:03 IlanOptinum

The issue that @redbmk and @IlanOptinum encountered are different things. They are the errors at "building time", due to missing tools to build pendulum from source. The issue that the OP reported is that: pendulum has been installed (could be from wheel file), but error raises when the app tries to import pendulum.

@redbmk: When you tried to install pendulum in the uv:0.6.6-python3.13-alpine container, because this container comes with Python 3.13, and pendulum doesn't publish wheel file for Python 3.13 (you can see the list of wheel files in PyPI), uv have to build pendulum from source. But part of pendulum is written in Rust, and your container doesn't contain Rust compiler, so the build process failed.

@IlanOptinum: Your issue may be the same as @redbmk . Your system doesn't have Rust compiler, or the installation has been broken.

hongquan avatar Mar 26 '25 17:03 hongquan

It looks like this issue was resolved in 3.1.0.

vivodi avatar Sep 23 '25 22:09 vivodi