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

Add support for Alpine #756

Closed
torepettersen opened this issue Jul 14, 2018 · 15 comments
Closed

Add support for Alpine #756

torepettersen opened this issue Jul 14, 2018 · 15 comments
Assignees
Labels
Feature Request Missing Feature/Wrapper OS: Linux GNU/Linux OS
Milestone

Comments

@torepettersen
Copy link

It does not seems like it is possible to install the ortools on Alpine.
Is it possible to add support for that?

FROM python:3-alpine

RUN pip install ortools
Step 2/2 : RUN pip install ortools
 ---> Running in 2cf3452ad8a8
Collecting ortools
  Could not find a version that satisfies the requirement ortools (from versions: )
No matching distribution found for ortools
The command '/bin/sh -c pip install ortools' returned a non-zero code: 1

@Mizux
Copy link
Collaborator

Mizux commented Jul 14, 2018

I'll try to do it on my free time once I finish my docker rework !
Should be easy to add alpine docker image.

Alpine is good but never use it, except to create a port for assimp

@Mizux Mizux added this to the v6.9 milestone Jul 14, 2018
@Mizux Mizux added the Feature Request Missing Feature/Wrapper label Jul 14, 2018
@Mizux Mizux self-assigned this Jul 14, 2018
@Mizux Mizux modified the milestones: v6.9, v6.10 Aug 24, 2018
@Mizux Mizux added the OS: Linux GNU/Linux OS label Aug 31, 2018
@marzetas
Copy link

Is it possible, though? I'm trying to get or-tools running on an alpine distro, and it seems like ortools is trying to call to dlvsym, causing an error:

Traceback (most recent call last):
  File "/root/.local/lib/python3.6/site-packages/ortools-6.8.5510-py3.6-linux-x86_64.egg/ortools/linear_solver/pywraplp.py", line 14, in swig_import_helper
    return importlib.import_module(mname)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 658, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 571, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 922, in create_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: Error relocating /root/.local/lib/python3.6/site-packages/ortools-6.8.5510-py3.6-linux-x86_64.egg/ortools/linear_solver/../../ortools/.libs/libortools.so: dlvsym: symbol not found

dlvsym is a glibc specific extension, which unfortunately is not implemented in musl libc, the C standard library used by alpine. From dlvsym man page

Glibc extensions: dladdr() and dlvsym()
Glibc adds two functions not described by POSIX, with prototypes

I've been trying a number of workarounds, but I've been unable to get it to work, so any ideas are welcome.

@Mizux
Copy link
Collaborator

Mizux commented Oct 12, 2018

ortools is a python native library, and like you figure out alpine is based on libmusl not glibc that's why they are binary incompatible

@Mizux
Copy link
Collaborator

Mizux commented Oct 16, 2018

You may be interested on pypa/manylinux#37
TLDR: python native package for alpine is not supported by Pypi.org 😢

@Mizux Mizux modified the milestones: v6.10, Backlog Oct 19, 2018
@lperron
Copy link
Collaborator

lperron commented Aug 6, 2019

Sorry won't fix on our side.
We welcome PR though.

@lperron lperron closed this as completed Aug 6, 2019
@Mizux Mizux modified the milestones: Backlog, v7.4 Jan 2, 2020
@kasaiee
Copy link

kasaiee commented Oct 12, 2020

Maybe this is the reason of there is no whl for or-tools https://pythonspeed.com/articles/alpine-docker-python/
in this article, we find out alpine is not the best choice to dockerize python based projects

@Mizux
Copy link
Collaborator

Mizux commented Oct 12, 2020

we do have alpine docker to test python and all other languages, we simply don't upload the wheel package to pypi yet...

@luomengY
Copy link

luomengY commented Jul 9, 2024

Why is it not supported yet?

@lperron
Copy link
Collaborator

lperron commented Jul 9, 2024 via email

@luomengY
Copy link

luomengY commented Jul 9, 2024

PR welcome :-) not a priority for us. Laurent Perron | Operations Research | @.*** | (33) 1 42 68 53 00 Le mar. 9 juil. 2024 à 13:18, zhijiayang @.> a écrit :

Why is it not supported yet? — Reply to this email directly, view it on GitHub <#756 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUPL3IDZAFJ26WQF4GYVSDZLPBJRAVCNFSM6AAAAABKSUW3QKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMJXGM4DMNBSGE . You are receiving this because you modified the open/close state.Message ID: @.
>

So, what method do I have to install it? our basic image requirement is python: 3.9-alpine

@lperron
Copy link
Collaborator

lperron commented Jul 9, 2024

we use manylinux for python wheels.

This is not compatible with musl images. I believe there is a PEP to support musl it.

All the cmake tooling needs to be adapted to support it.

@Mizux
Copy link
Collaborator

Mizux commented Jul 9, 2024

So, what method do I have to install it? our basic image requirement is python: 3.9-alpine

You could build your own ortools wheel package for alpine, just need a linux distro with docker and makefile installed
then you'll have two options...

Using our Alpine cmake python CI

please take a look at/adapt:
https://github.com/google/or-tools/blob/stable/cmake/docker/alpine/Dockerfile
https://github.com/google/or-tools/blob/stable/cmake/docker/alpine/python.Dockerfile

Makefile orchestrator:
https://github.com/google/or-tools/blob/stable/cmake/Makefile

So change alpine:edge by your alpine python3.9 image in the Dockerfile
Then you should be able to build using

make --directory=cmake
make --directory=cmake amd64_alpine_python_build

after you should have an image with the wheel package inside, just need to docker run the image and copy the build/python/dist?/*.whl package...

Using our release tools

Please take a look at
https://github.com/google/or-tools/blob/stable/tools/docker/python/amd64/alpine.Dockerfile

Makefila orchestrator:
https://github.com/google/or-tools/blob/stable/tools/docker/Makefile

So change alpine:edge by your alpine python3.9 image in the Dockerfile
Then you should be able to build using:

cd tools/docker
make
make python_amd64_alpine_export

should copy the wheel package from a container to export/ directory on your host...

@luomengY
Copy link

luomengY commented Jul 9, 2024

So, what method do I have to install it? our basic image requirement is python: 3.9-alpine

You could build your own ortools wheel package for alpine, just need a linux distro with docker and makefile installed then you'll have two options...

Using our Alpine cmake python CI

please take a look at/adapt: https://github.com/google/or-tools/blob/stable/cmake/docker/alpine/Dockerfile https://github.com/google/or-tools/blob/stable/cmake/docker/alpine/python.Dockerfile

Makefile orchestrator: https://github.com/google/or-tools/blob/stable/cmake/Makefile

So change alpine:edge by your alpine python3.9 image in the Dockerfile Then you should be able to build using

make --directory=cmake
make --directory=cmake amd64_alpine_python_build

after you should have an image with the wheel package inside, just need to docker run the image and copy the build/python/dist?/*.whl package...

Using our release tools

Please take a look at https://github.com/google/or-tools/blob/stable/tools/docker/python/amd64/alpine.Dockerfile

Makefila orchestrator: https://github.com/google/or-tools/blob/stable/tools/docker/Makefile

So change alpine:edge by your alpine python3.9 image in the Dockerfile Then you should be able to build using:

cd tools/docker
make
make python_amd64_alpine_export

should copy the wheel package from a container to export/ directory on your host...

Thank you very much. My architecture is arm64, and during compilation, I execute the command: make python_arm64_alpine_export?

@Mizux
Copy link
Collaborator

Mizux commented Jul 9, 2024

You should try:

cd tools/docker
make python_arm64v8_alpine_export 

ref:
https://github.com/google/or-tools/blob/main/tools/docker/python/arm64v8/alpine.Dockerfile

@echo -e "\t${BOLD}<platform>${RESET}:"
@echo -e "\t\t${BOLD}amd64${RESET}"
@echo -e "\t\t${BOLD}arm64v8${RESET}"
@echo
@echo -e "\t${BOLD}<target>${RESET}:"
@echo -e "\t\t${BOLD}<platform>_<distro>${RESET}"
@echo -e "\t\t${BOLD}<platform>_manylinux_cp<version>${RESET}"
@echo
@echo -e "\t${BOLD}<distro>${RESET}:"
@echo -e "\t\t${BOLD}alpine${RESET} (latest)"

@luomengY
Copy link

luomengY commented Jul 9, 2024

 python_arm64v8_alpine_export 

ok!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request Missing Feature/Wrapper OS: Linux GNU/Linux OS
Projects
None yet
Development

No branches or pull requests

6 participants