在conan中识别linux发行版

问题描述 投票:0回答:1

我为一些使用 Ncurses 的项目创建了一个 Ncurses conan 包。我使用 conanfile.py 进行配置。现在我遇到的问题是,在 Centos 下 terminfo 位于 /usr/lib 中,而在基于 Debian 的系统中则位于 /lib 中。

因此,我必须根据分布在 conanfile.py 中设置一个参数:

.
.
.
settings = "os", "compiler", "build_type", "arch"
.
.
.
def build(self):
    env_build = AutoToolsBuildEnvironment(self)
    env_build.configure(configure_dir="src", build=False, host=False, target=False)
    args = ["--without-debug"]
    # if debian-based
    args += ["--datadir=/lib"]
    if self.options.shared:
        args += ["--with-shared", "--without-normal"]
    env_build.configure(configure_dir="src", args=args, build=False, host=False, target=False)
    env_build.make()

如何实现 if 语句

# if debian-based
?在这种情况下,最佳实践是什么?

ncurses conan terminfo
1个回答
3
投票

您可以使用 OSInfo 帮助器,它是

uname
和其他操作系统函数的包装器。在你的情况下,你想要这样的东西:

from conans.tools import OSInfo

info = OSInfo()
if info.is_linux and info.linux_distro in ("debian", "ubuntu"):
    # your logic here
© www.soinside.com 2019 - 2024. All rights reserved.