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

ephem package fails to install correctly for non-x86 architectures #395

Closed
felddy opened this issue Dec 29, 2024 · 0 comments · Fixed by #396
Closed

ephem package fails to install correctly for non-x86 architectures #395

felddy opened this issue Dec 29, 2024 · 0 comments · Fixed by #396

Comments

@felddy
Copy link
Owner

felddy commented Dec 29, 2024

🐛 Summary

The ephem Python package does not install correctly for non-x86 architectures (e.g., arm64, arm/v6, arm/v7, ppc64le, s390x) when building the WeeWX Docker container. This issue occurs because the package relies on a compiled C extension (_libastro), which is built for x86_64 by default during cross-compilation.

This isn't a breaking bug, as WeeWX will detect catch the import error, and figure the package is not installed.

See:

To reproduce

Steps to reproduce the behavior:

  1. Build the WeeWX Docker container for any non-x86 platform using Docker Buildx:
    docker buildx build --platform linux/arm64 -t weewx-arm64 .
  2. Run a container from the image.
  3. Open a Python interpreter inside the container and attempt to import the ephem module:
    python -c "import ephem"

Expected behavior

The ephem module should import successfully without errors, and the _libastro shared object should be compiled for the target architecture.

Any helpful log output or screenshots

Paste the results here:

>>> import ephem
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/venv/lib/python3.13/site-packages/ephem/__init__.py", line 5, in <module>
    import ephem._libastro as _libastro
ModuleNotFoundError: No module named 'ephem._libastro'

Add any screenshots of the problem here.


Proposed Fix

The issue was resolved by modifying the Dockerfile to ensure that the ephem package is compiled from source during the build process. The following changes were made:

  1. Added build tools and dependencies to the build-stage:

    RUN apt-get update && apt-get install -y build-essential python3-dev libffi-dev gcc
  2. Forced the ephem package to compile from source using pip:

    RUN pip install --no-cache --no-binary :all: ephem

These changes ensure that the _libastro shared object is built correctly for the target architectures, resolving the import issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant