簡體   English   中英

我們可以使用什么來區分 linux 和 macOS AppVeyor 構建?

[英]What can we use to distinguish beetween linux and macos AppVeyor builds?

AppVeyor 為 windows、linux 和 macos 提供構建工作鏡像以運行單元測試。

所以我們可以使用相同的 appveyor.yml 來控制在這兩個操作系統上運行的構建。

我們可以通過使用一些可能性來區分 windows 和 linux 平台,如變量($isLinux、$isWindows、APPVEYOR_YML_DISABLE_PS_LINUX)或前綴命令(sh:、cmd:)。

我們用什么來區分linux和macos?

我需要命令行中的解決方案。 我認為解決方案是使用 python -c "import platform; platform.system()",但在這種情況下如何獲得結果?

在 Bash:

platform=$(uname -s)
if [[ $platform == Darwin ]]; then
    echo "it's macOS"
elif [[ $platform == Linux ]]; then
    echo "it's Linux"
else

來自Python:我正在運行什么操作系統?

>>> import platform
>>> platform.system()
'Windows' # for Linux it prints 'Linux', Mac it prints `'Darwin'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM