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

coin-osi: add v0.108.10, apply autoreconf, use OpenBLAS, add GLPK support #23533

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions recipes/coin-osi/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
sources:
"0.108.10":
url: "https://github.com/coin-or/Osi/archive/releases/0.108.10.tar.gz"
sha256: "614c2b329caf57c00326412266299fdfd93c5691492034fbb46990b5e71cc5a7"
"0.108.7":
url: "https://github.com/coin-or/Osi/archive/releases/0.108.7.tar.gz"
sha256: "f1bc53a498585f508d3f8d74792440a30a83c8bc934d0c8ecf8cd8bc0e486228"
Expand All @@ -7,13 +10,11 @@ sources:
sha256: "984a5886825e2da9bf44d8a665f4b92812f0700e451c12baf9883eaa2315fad5"
patches:
"0.108.7":
- patch_file: "patches/0.108.6-0001-no-pkg-config-check.patch"
- patch_file: "patches/0.108.6-0002-cpp17-compat.patch"
patch_description: "C++17 compatibility"
patch_type: "portability"
patch_source: "https://github.com/coin-or/Osi/pull/177"
"0.108.6":
- patch_file: "patches/0.108.6-0001-no-pkg-config-check.patch"
- patch_file: "patches/0.108.6-0002-cpp17-compat.patch"
patch_description: "C++17 compatibility"
patch_type: "portability"
Expand Down
69 changes: 49 additions & 20 deletions recipes/coin-osi/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import os
import shutil

from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.apple import fix_apple_shared_install_name
from conan.tools.build import cross_building
from conan.tools.env import VirtualBuildEnv
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rename, rm, rmdir
from conan.tools.gnu import Autotools, AutotoolsToolchain, PkgConfigDeps
from conan.tools.layout import basic_layout
from conan.tools.microsoft import check_min_vs, is_msvc, msvc_runtime_flag
import os

required_conan_version = ">=1.57.0"

Expand All @@ -24,10 +24,12 @@ class CoinOsiConan(ConanFile):
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_glpk": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"with_glpk": True,
}

@property
Expand All @@ -49,19 +51,20 @@ def layout(self):
basic_layout(self, src_folder="src")

def requirements(self):
self.requires("coin-utils/2.11.9")

def validate(self):
if self.settings.os == "Windows" and self.options.shared:
raise ConanInvalidConfiguration("coin-osi does not support shared builds on Windows")
# FIXME: This issue likely comes from very old autotools versions used to produce configure.
if hasattr(self, "settings_build") and cross_building(self) and self.options.shared:
raise ConanInvalidConfiguration("coin-osi shared not supported yet when cross-building")
self.requires("coin-utils/2.11.11")
self.requires("openblas/0.3.28")
if self.options.with_glpk:
self.requires("glpk/4.48")
# TODO: add support for: Cplex, Mosek, Xpress, Gurobi
# https://github.com/coin-or/Osi/blob/stable/0.108/Osi/configure.ac#L65-L77
# soplex support requires v4.0, which is not available on CCI and is distributed under ZIB Academic License
# https://github.com/coin-or-tools/ThirdParty-SoPlex/blob/master/INSTALL.SoPlex

def build_requirements(self):
self.tool_requires("coin-buildtools/0.8.11")
self.tool_requires("gnu-config/cci.20210814")
if not self.conf.get("tools.gnu:pkg_config", check_type=str):
self.tool_requires("pkgconf/2.0.3")
self.tool_requires("pkgconf/[>=2.2 <3]")
if self._settings_build.os == "Windows":
self.win_bash = True
if not self.conf.get("tools.microsoft.bash:path", check_type=str):
Expand All @@ -74,10 +77,30 @@ def generate(self):
env = VirtualBuildEnv(self)
env.generate()

deps = PkgConfigDeps(self)
deps.generate()

def _add_pkg_config_alias(src_name, dst_name):
shutil.copy(os.path.join(self.generators_folder, f"{src_name}.pc"),
os.path.join(self.generators_folder, f"{dst_name}.pc"))

_add_pkg_config_alias("openblas", "coinblas")
_add_pkg_config_alias("openblas", "coinlapack")
if self.options.with_glpk:
_add_pkg_config_alias("glpk", "coinglpk")

tc = AutotoolsToolchain(self)
tc.configure_args.extend([
"--without-blas",
"--without-lapack",
# the coin*.pc pkg-config files are only used when set to BUILD
"--with-blas=BUILD",
"--with-lapack=BUILD",
"--with-glpk=BUILD" if self.options.with_glpk else "--without-glpk",
"--with-soplex=no",
# These are only used for sample datasets
"--without-netlib",
"--without-sample",
"--disable-dependency-linking",
"F77=unavailable",
])
if is_msvc(self):
tc.extra_cxxflags.append("-EHsc")
Expand All @@ -98,18 +121,19 @@ def generate(self):
env.define("PKG_CONFIG_PATH", self.generators_folder)
tc.generate(env)

deps = PkgConfigDeps(self)
deps.generate()

def build(self):
apply_conandata_patches(self)
copy(self, "*", os.path.join(self.dependencies.build["coin-buildtools"].package_folder, "res"),
os.path.join(self.source_folder, "BuildTools"))
copy(self, "*", os.path.join(self.dependencies.build["coin-buildtools"].package_folder, "res"),
os.path.join(self.source_folder, "Osi", "BuildTools"))
for gnu_config in [
self.conf.get("user.gnu-config:config_guess", check_type=str),
self.conf.get("user.gnu-config:config_sub", check_type=str),
]:
if gnu_config:
copy(self, os.path.basename(gnu_config), src=os.path.dirname(gnu_config), dst=self.source_folder)
copy(self, os.path.basename(gnu_config), src=os.path.dirname(gnu_config), dst=self.source_folder)
autotools = Autotools(self)
autotools.autoreconf()
autotools.configure()
autotools.make()

Expand All @@ -130,8 +154,13 @@ def package_info(self):
self.cpp_info.components["libosi"].set_property("pkg_config_name", "osi")
self.cpp_info.components["libosi"].libs = ["Osi"]
self.cpp_info.components["libosi"].includedirs = [os.path.join("include", "coin")]
self.cpp_info.components["libosi"].requires = ["coin-utils::coin-utils"]
self.cpp_info.components["libosi"].requires = ["coin-utils::coin-utils", "openblas::openblas"]

self.cpp_info.components["osi-unittests"].set_property("pkg_config_name", "osi-unittests")
self.cpp_info.components["osi-unittests"].libs = ["OsiCommonTests"]
self.cpp_info.components["osi-unittests"].requires = ["libosi"]

if self.options.with_glpk:
self.cpp_info.components["osi-glpk"].set_property("pkg_config_name", "osi-glpk")
self.cpp_info.components["osi-glpk"].libs = ["OsiGlpk"]
self.cpp_info.components["osi-glpk"].requires = ["libosi", "glpk::glpk"]
2 changes: 1 addition & 1 deletion recipes/coin-osi/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def requirements(self):

def build_requirements(self):
if not self.conf.get("tools.gnu:pkg_config", check_type=str):
self.tool_requires("pkgconf/2.0.3")
self.tool_requires("pkgconf/[>=2.2 <3]")

def build(self):
cmake = CMake(self)
Expand Down
8 changes: 0 additions & 8 deletions recipes/coin-osi/all/test_v1_package/CMakeLists.txt

This file was deleted.

20 changes: 0 additions & 20 deletions recipes/coin-osi/all/test_v1_package/conanfile.py

This file was deleted.

2 changes: 2 additions & 0 deletions recipes/coin-osi/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
versions:
"0.108.10":
folder: "all"
"0.108.7":
folder: "all"
"0.108.6":
Expand Down