如何在 Alpine Linux 上安装 GLPK?

How to install GLPK on Alpine Linux?

在 Alpine Linux 上安装 swiglpk 包失败,跟踪如下:

Collecting swiglpk>=1.2.14; extra == "all" (from cameo[all]==0.6.3->-r requirements.txt (line 1))
   Downloading swiglpk-1.2.14.tar.gz
Complete output from command python setup.py egg_info:
which: no glpsol in (/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin)
Trying to determine glpk.h location
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/pip-build-_g57y7ed/swiglpk/setup.py", line 45, in <module>
    copy_glpk_header()
  File "/tmp/pip-build-_g57y7ed/swiglpk/setup.py", line 28, in copy_glpk_header
    glpsol_path = os.path.dirname(subprocess.check_output(['which', 'glpsol']))
  File "/usr/local/lib/python3.5/subprocess.py", line 626, in check_output
    **kwargs).stdout
  File "/usr/local/lib/python3.5/subprocess.py", line 708, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['which', 'glpsol']' returned non-zero exit status 1

所以在路径中找不到glpsol

如果可能,如何在 Alpine Linux 上安装 glpk/glpsol

因为还没有 glpk Alpine 包,可以从源安装它

wget ftp://ftp.gnu.org/gnu/glpk/glpk-4.55.tar.gz
tar -xzvf glpk-4.55.tar.gz
cd glpk-4.55
./configure
make install

为了确保它有效,运行 which glpsol