coin-or / CyLP

A Python interface to CLP, CBC, and CGL to solve LPs and MIPs.
Other
182 stars 69 forks source link

How to install cylp on a Windows server in Github Actions? #147

Open erelsgl opened 2 years ago

erelsgl commented 2 years ago

On my home computer, I have Windows 10. I can install cylp by simply running

pip install cylp

I tried to do the same in GitHub actions, in a Windows 2019 environment, in order to automatically test a library that I am working on. But it did not work - I got an error message KeyError: 'COIN_INSTALL_DIR', and the following output:

Collecting numpy
  Downloading numpy-1.22.2-cp310-cp310-win_amd64.whl (14.7 MB)
     --------------------------------------- 14.7/14.7 MB 36.4 MB/s eta 0:00:00
Installing collected packages: numpy
Successfully installed numpy-1.22.2
Collecting scipy
  Downloading scipy-1.8.0-cp310-cp310-win_amd64.whl (37.0 MB)
     --------------------------------------- 37.0/37.0 MB 14.9 MB/s eta 0:00:00
Requirement already satisfied: numpy<1.25.0,>=1.17.3 in c:\hostedtoolcache\windows\python\3.10.1\x64\lib\site-packages (from scipy) (1.22.2)
Installing collected packages: scipy
Successfully installed scipy-1.8.0
Collecting cylp
  Downloading cylp-0.91.4.tar.gz (1.4 MB)
     ---------------------------------------- 1.4/1.4 MB 29.9 MB/s eta 0:00:00
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'error'
  error: subprocess-exited-with-error

  python setup.py egg_info did not run successfully.
  exit code: 1

  [49 lines of output]
  which: no cbc in (/c/Program Files/PowerShell/7:/c/Users/runneradmin/AppData/Roaming/Python/Python310/Scripts:/c/hostedtoolcache/windows/Python/3.10.1/x64/Scripts:/c/hostedtoolcache/windows/Python/3.10.1/x64:/c/Program Files/MongoDB/Server/5.0/bin:/c/aliyun-cli:/c/vcpkg:/c/cf-cli:/c/Program Files (x86)/NSIS:/c/tools/zstd:/c/Program Files/Mercurial:/c/hostedtoolcache/windows/stack/2.7.3/x64:/c/cabal/bin:/c/ghcup/bin:/c/tools/ghc-9.2.1/bin:/c/Program Files/dotnet:/c/mysql/bin:/c/Program Files/R/R-4.1.2/bin/x64:/c/SeleniumWebDrivers/GeckoDriver:/c/Program Files (x86)/sbt/bin:/c/Program Files (x86)/GitHub CLI:/bin:/c/Program Files (x86)/pipx_bin:/c/hostedtoolcache/windows/go/1.15.15/x64/bin:/c/hostedtoolcache/windows/Python/3.7.9/x64/Scripts:/c/hostedtoolcache/windows/Python/3.7.9/x64:/c/hostedtoolcache/windows/Ruby/2.5.9/x64/bin:/c/tools/kotlinc/bin:/c/hostedtoolcache/windows/Java_Temurin-Hotspot_jdk/8.0.322-6/x64/bin:/c/npm/prefix:/c/Program Files (x86)/Microsoft SDKs/Azure/CLI2/wbin:/c/ProgramData/kind:/c/Program Files/Eclipse Foundation/jdk-8.0.302.8-hotspot/bin:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Windows/System32/OpenSSH:/c/ProgramData/Chocolatey/bin:/c/Program Files/Docker:/c/Program Files/PowerShell/7:/c/Program Files/Microsoft/Web Platform Installer:/c/Program Files/dotnet:/c/Program Files/Microsoft SQL Server/130/Tools/Binn:/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/170/Tools/Binn:/c/Program Files (x86)/Windows Kits/10/Windows Performance Toolkit:/c/Program Files (x86)/Microsoft SQL Server/110/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/120/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/130/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/140/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/150/DTS/Binn:/c/Program Files/nodejs:/c/Program Files/OpenSSL/bin:/c/Strawberry/c/bin:/c/Strawberry/perl/site/bin:/c/Strawberry/perl/bin:/c/ProgramData/chocolatey/lib/pulumi/tools/Pulumi/bin:/c/Program Files/TortoiseSVN/bin:/c/Program Files/CMake/bin:/c/ProgramData/chocolatey/lib/maven/apache-maven-3.8.4/bin:/c/Program Files/Microsoft Service Fabric/bin/Fabric/Fabric.Code:/c/Program Files/Microsoft SDKs/Service Fabric/Tools/ServiceFabricLocalClusterManager:/cmd:/mingw64/bin:/usr/bin:/c/tools/php:/c/Program Files (x86)/sbt/bin:/c/SeleniumWebDrivers/ChromeDriver:/c/SeleniumWebDrivers/EdgeDriver:/c/Program Files/Amazon/AWSCLIV2:/c/Program Files/Amazon/SessionManagerPlugin/bin:/c/Program Files/Amazon/AWSSAMCLI/bin:/c/Program Files (x86)/Google/Cloud SDK/google-cloud-sdk/bin:/c/Program Files (x86)/Microsoft BizTalk Server:/c/Program Files/LLVM/bin:/c/Users/runneradmin/.dotnet/tools:/c/Users/runneradmin/.cargo/bin:/c/Users/runneradmin/AppData/Local/Microsoft/WindowsApps)
  Traceback (most recent call last):
    File "C:\Users\runneradmin\AppData\Local\Temp\pip-install-g7kshg50\cylp_c80969ec7dc94f4bb51abcf90226486b\setup.py", line 56, in <module>
      CoinDir = os.environ['COIN_INSTALL_DIR']
    File "C:\hostedtoolcache\windows\Python\3.10.1\x64\lib\os.py", line 679, in __getitem__
      raise KeyError(key) from None
  KeyError: 'COIN_INSTALL_DIR'

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "C:\Users\runneradmin\AppData\Local\Temp\pip-install-g7kshg50\cylp_c80969ec7dc94f4bb51abcf90226486b\setup.py", line 60, in <module>
      flags = (check_output(['pkg-config', '--libs', 'cbc'])
    File "C:\hostedtoolcache\windows\Python\3.10.1\x64\lib\subprocess.py", line 420, in check_output
      return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
    File "C:\hostedtoolcache\windows\Python\3.10.1\x64\lib\subprocess.py", line 501, in run
      with Popen(*popenargs, **kwargs) as process:
    File "C:\hostedtoolcache\windows\Python\3.10.1\x64\lib\subprocess.py", line 966, in __init__
      self._execute_child(args, executable, preexec_fn, close_fds,
    File "C:\hostedtoolcache\windows\Python\3.10.1\x64\lib\subprocess.py", line 1435, in _execute_child
      hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
  FileNotFoundError: [WinError 2] The system cannot find the file specified

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "C:\Users\runneradmin\AppData\Local\Temp\pip-install-g7kshg50\cylp_c80969ec7dc94f4bb51abcf90226486b\setup.py", line 74, in <module>
      check_output(['which', 'cbc']).strip()).decode('utf-8')
    File "C:\hostedtoolcache\windows\Python\3.10.1\x64\lib\subprocess.py", line 420, in check_output
      return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
    File "C:\hostedtoolcache\windows\Python\3.10.1\x64\lib\subprocess.py", line 524, in run
      raise CalledProcessError(retcode, process.args,
  subprocess.CalledProcessError: Command '['which', 'cbc']' returned non-zero exit status 1.

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "<string>", line 2, in <module>
    File "<pip-setuptools-caller>", line 34, in <module>
    File "C:\Users\runneradmin\AppData\Local\Temp\pip-install-g7kshg50\cylp_c80969ec7dc94f4bb51abcf90226486b\setup.py", line 78, in <module>
      raise Exception('''
  Exception:
              Could not find location of COIN installation.
              Please ensure that either
              * COIN_INSTALL_DIR is set to the location of the installation,
              * PKG_CONFIG_PATH points to the location of the .pc files, or
              * The cbc executable is in your executable path and is installed
              at the same location as the libraries.

  [end of output]

Is there any command I can insert to my workflow in order to ensure that COIN is installed, before I try to install cylp?

tkralphs commented 2 years ago

This means that there is no binary wheel available for the platform on which you are trying to install on Github Actions. Since we also use Github Actions to build Cbc binaries and attach them to releases, you should be able find a matching set of binaries that can be downloaded and installed (see here). You would then just need to set the environment variable COIN_INSTALL_DIR to point to where the binaries are located on the runner. Let me know if this works or if you need more information.

erelsgl commented 2 years ago

Do you know which of these releases should work on a Windows 2019 server environment? I would guess that it should be some of the "msvc" releases, but I cannot tell which one of them. What is the difference between these versions?

zhenyong97 commented 2 years ago

Hi, @erelsgl It may help for you.

Setp 1

I have installed the c++ develop environment on my window system by using vs_BuildTools.exe, like this:

Setp 2

I download the Cbc-releases.2.10.8-w64-msvc17-md

Setp 3

Finally, I unzip this file and set the environment variable COIN_INSTALL_DIR to point this location, then use pip to install Cylp. Everythings will be fine.