ytooyamaのブログ

サーバ構築とか、仕事で発見したこととか、趣味のこととかを書いています。

Command Line Tools 12.0に更新したらmacOSにpython-openstackclientが入れられなくなったとさ

Command Line Tools 12.0に更新したら、error architecture not supported とか error: command 'xcrun' failed with exit status 1 といったエラーが出てしまい、macOSに python-openstackclient をインストールできなくなってしまいました。

回避策はCommand Line Toolsのバージョンを下げるか、対応するPython 3.7をHomebrewか公式パッケージなどを使ってで入れるかです。

ちなみに次のようなエラーが出ます。

(environment) machome3$ pip3 install python-openstackclient==5.3.1
...
    ERROR: Command errored out with exit status 1:
     command: /Users/ytooyama/working/openstack/virtual/environment/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/qw/0b8k_5b51_v024zclnmszhy40000gp/T/pip-install-p6g07cdl/netifaces/setup.py'"'"'; __file__='"'"'/private/var/folders/qw/0b8k_5b51_v024zclnmszhy40000gp/T/pip-install-p6g07cdl/netifaces/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/qw/0b8k_5b51_v024zclnmszhy40000gp/T/pip-record-37yjcmbl/install-record.txt --single-version-externally-managed --compile --install-headers /Users/ytooyama/working/openstack/virtual/environment/include/site/python3.8/netifaces
         cwd: /private/var/folders/qw/0b8k_5b51_v024zclnmszhy40000gp/T/pip-install-p6g07cdl/netifaces/
    Complete output (113 lines):
    running install
    running build
    running build_ext
    checking for getifaddrs...not found.
    checking for getnameinfo...not found.
    checking for socket IOCTLs...not found.
    checking for optional header files...none found.
    checking whether struct sockaddr has a length field...no.
    checking which sockaddr_xxx structs are defined...none!
    checking for routing socket support...no.
    checking for sysctl(CTL_NET...) support...no.
    checking for netlink support...no.
    building 'netifaces' extension
    xcrun -sdk macosx clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/Headers -arch arm64 -arch x86_64 -DNETIFACES_VERSION=0.10.9 -I/Users/ytooyama/working/openstack/virtual/environment/include -I/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/include/python3.8 -c netifaces.c -o build/temp.macosx-10.14.6-x86_64-3.8/netifaces.o
    In file included from netifaces.c:1:
    In file included from /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/include/python3.8/Python.h:11:
    In file included from /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/limits.h:21:
    In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/limits.h:63:
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h:807:2: error: Unsupported architecture
    #error Unsupported architecture
     ^
    In file included from netifaces.c:1:
    In file included from /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/include/python3.8/Python.h:11:
    In file included from /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/limits.h:21:
    In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/limits.h:64:
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/machine/limits.h:8:2: error: architecture not supported
    #error architecture not supported
     ^
    In file included from netifaces.c:1:
    In file included from /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/include/python3.8/Python.h:25:
    In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdio.h:64:
    In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_stdio.h:71:
    In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_types.h:27:
    In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types.h:33:
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/machine/_types.h:34:2: error: architecture not supported
    #error architecture not supported
     ^
    In file included from netifaces.c:1:
    In file included from /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/include/python3.8/Python.h:25:
    In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdio.h:64:
    In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_stdio.h:71:
    In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_types.h:27:
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types.h:55:9: error: unknown type name '__int64_t'
    typedef __int64_t       __darwin_blkcnt_t;      /* total blocks */
            ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types.h:56:9: error: unknown type name '__int32_t'; did you mean '__int128_t'?
    typedef __int32_t       __darwin_blksize_t;     /* preferred block size */
            ^
    note: '__int128_t' declared here
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types.h:57:9: error: unknown type name '__int32_t'; did you mean '__int128_t'?
    typedef __int32_t       __darwin_dev_t;         /* dev_t */
            ^
    note: '__int128_t' declared here
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types.h:60:9: error: unknown type name '__uint32_t'; did you mean '__uint128_t'?
    typedef __uint32_t      __darwin_gid_t;         /* [???] process and group IDs */
            ^
    note: '__uint128_t' declared here
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types.h:61:9: error: unknown type name '__uint32_t'; did you mean '__uint128_t'?
    typedef __uint32_t      __darwin_id_t;          /* [XSI] pid_t, uid_t, or gid_t*/
            ^
    note: '__uint128_t' declared here
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types.h:62:9: error: unknown type name '__uint64_t'
    typedef __uint64_t      __darwin_ino64_t;       /* [???] Used for 64 bit inodes */
            ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types.h:68:9: error: unknown type name '__darwin_natural_t'
    typedef __darwin_natural_t __darwin_mach_port_name_t; /* Used by mach */
            ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types.h:70:9: error: unknown type name '__uint16_t'; did you mean '__uint128_t'?
    typedef __uint16_t      __darwin_mode_t;        /* [???] Some file attributes */
            ^
    note: '__uint128_t' declared here
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types.h:71:9: error: unknown type name '__int64_t'
    typedef __int64_t       __darwin_off_t;         /* [???] Used for file sizes */
            ^
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types.h:72:9: error: unknown type name '__int32_t'; did you mean '__int128_t'?
    typedef __int32_t       __darwin_pid_t;         /* [???] process and group IDs */
            ^
    note: '__int128_t' declared here
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types.h:73:9: error: unknown type name '__uint32_t'; did you mean '__uint128_t'?
    typedef __uint32_t      __darwin_sigset_t;      /* [???] signal set */
            ^
    note: '__uint128_t' declared here
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types.h:74:9: error: unknown type name '__int32_t'; did you mean '__int128_t'?
    typedef __int32_t       __darwin_suseconds_t;   /* [???] microseconds */
            ^
    note: '__int128_t' declared here
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types.h:75:9: error: unknown type name '__uint32_t'; did you mean '__uint128_t'?
    typedef __uint32_t      __darwin_uid_t;         /* [???] user IDs */
            ^
    note: '__uint128_t' declared here
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types.h:76:9: error: unknown type name '__uint32_t'; did you mean '__uint128_t'?
    typedef __uint32_t      __darwin_useconds_t;    /* [???] microseconds */
            ^
    note: '__uint128_t' declared here
    In file included from netifaces.c:1:
    In file included from /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/include/python3.8/Python.h:25:
    In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdio.h:64:
    In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_stdio.h:71:
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_types.h:43:9: error: unknown type name '__uint32_t'; did you mean '__uint128_t'?
    typedef __uint32_t      __darwin_wctype_t;
            ^
    note: '__uint128_t' declared here
    In file included from netifaces.c:1:
    In file included from /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/include/python3.8/Python.h:25:
    In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdio.h:64:
    In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_stdio.h:75:
    In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types/_va_list.h:31:
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/machine/types.h:37:2: error: architecture not supported
    #error architecture not supported
     ^
    fatal error: too many errors emitted, stopping now [-ferror-limit=]
    20 errors generated.
    error: command 'xcrun' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Users/ytooyama/working/openstack/virtual/environment/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/qw/0b8k_5b51_v024zclnmszhy40000gp/T/pip-install-p6g07cdl/netifaces/setup.py'"'"'; __file__='"'"'/private/var/folders/qw/0b8k_5b51_v024zclnmszhy40000gp/T/pip-install-p6g07cdl/netifaces/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/qw/0b8k_5b51_v024zclnmszhy40000gp/T/pip-record-37yjcmbl/install-record.txt --single-version-externally-managed --compile --install-headers /Users/ytooyama/working/openstack/virtual/environment/include/site/python3.8/netifaces Check the logs for full command output.

Command Line Toolsのバージョンを下げるには?

以下のディレクトリーにCommand Line Toolsがインストールされるので、消してインストールしたいCommand Line Toolsをダウンロードしてインストールするだけです。

 sudo rm -rf /Library/Developer/CommandLineTools/

Command Line ToolsはApple Developerサイトからダウンロードします。

developer.apple.com

Command Line Toolsの自動更新をブロックする

現在CatalinaにCommand Line Tools の古いバージョンをインストールしていると、「Command Line Tools 12.0」と同「12.0 beta5」のアップデート通知が表示されます。Command Line Tools 12.0のアップデートが現れるのはわかるのですが、一緒に12.0 beta5が現れるのは謎ですし、「いますぐアップデート」ボタンを押すと、(Beta5の方はダウンロードする意味がないのに)Command Line Tools 12.0と 12.0 beta5がダウンロードされ、それぞれインストールされます。すごい無駄。

f:id:ytooyama:20201005184735p:plain:w600

とはいえ、うっかりアップデートするとopenstackclientをインストールできなくなります。 というわけで、一時的にこの問題を回避するためにこのアップデートを除外する方法を調べたら、次のようなフォーラムの投稿を見つけました。

developer.apple.com

回避策は softwareupdate --ignore を使う方法みたいです。

$ softwareupdate --ignore "Command Line Tools beta 5 for Xcode"
Ignored updates:
(
    "Command Line Tools beta 5 for Xcode"
)

Software Update can only ignore updates that are eligible for installation.
If the label provided to ignore is not in the above list, it is not eligible
to be ignored.

Ignoring software updates is deprecated.
The ability to ignore individual updates will be removed in a future release of macOS.

$ softwareupdate --ignore "Command Line Tools for Xcode"
Ignored updates:
(
    "Command Line Tools beta 5 for Xcode",
    "Command Line Tools for Xcode"
)

Software Update can only ignore updates that are eligible for installation.
If the label provided to ignore is not in the above list, it is not eligible
to be ignored.

Ignoring software updates is deprecated.
The ability to ignore individual updates will be removed in a future release of macOS.

ブロックしたCommand Line Toolsを取り消す

アップデートの除外を取り消す場合は softwareupdate --reset-ignored を実行します。 その後、softwareupdate --ignore "Command Line Tools beta 5 for Xcode" をもう一度実行した方が良いかもしれません。その間にもっと新しいバージョンのCommand Line Toolsが提供されれば自然と解決するわけですが。

python-openstackclientが無事インストールできるようになりました

以上で、なんとかpython-openstackclientをpip3コマンドでインストールすることができるようになりました。 Command Line Toolsは最新を使って、別途Python3.7をインストールする方法を早く見つけないと。

(environment) machome3$ pip3 install python-openstackclient==5.3.1
Collecting python-openstackclient==5.3.1
  Using cached https://files.pythonhosted.org/packages/e5/87/bccb52e4f556f71b2c35582c1273e63159837e3ce2dd9037230e9ed259c3/python_openstackclient-5.3.1-py3-none-any.whl
Collecting openstacksdk>=0.48.0 (from python-openstackclient==5.3.1)
  Using cached https://files.pythonhosted.org/packages/cd/f2/84e867fae8ed28f3aabb6cbe8b44f06aad501307e0073a2e1bc3528a5703/openstacksdk-0.50.0-py3-none-any.whl
Collecting stevedore>=2.0.1 (from python-openstackclient==5.3.1)
  Using cached https://files.pythonhosted.org/packages/b8/a1/004f04ba411a8002b02aadb089fd6868116c12ddc9f6d576175e89d07587/stevedore-3.2.2-py3-none-any.whl
Collecting oslo.i18n>=3.15.3 (from python-openstackclient==5.3.1)
  Using cached https://files.pythonhosted.org/packages/89/ac/b71a66e54c8fcf22c4205efe2b5f94dbf282c194f9f07dbf0a1ac52d4633/oslo.i18n-5.0.1-py3-none-any.whl
...
  Running setup.py install for PyYAML ... done
  Running setup.py install for dogpile.cache ... done
  Running setup.py install for wrapt ... done
  Running setup.py install for PrettyTable ... done
  Running setup.py install for pyperclip ... done
Successfully installed PrettyTable-0.7.2 PyYAML-5.3.1 appdirs-1.4.4 attrs-20.2.0 certifi-2020.6.20 cffi-1.14.3 chardet-3.0.4 cliff-3.4.0 cmd2-1.3.11 colorama-0.4.3 cryptography-3.1.1 debtcollector-2.2.0 decorator-4.4.2 dogpile.cache-1.0.2 idna-2.10 importlib-metadata-2.0.0 iso8601-0.1.13 jmespath-0.10.0 jsonpatch-1.26 jsonpointer-2.0 keystoneauth1-4.2.1 msgpack-1.0.0 munch-2.5.0 netaddr-0.8.0 netifaces-0.10.9 openstacksdk-0.50.0 os-service-types-1.7.0 osc-lib-2.2.1 oslo.config-8.3.2 oslo.i18n-5.0.1 oslo.serialization-4.0.1 oslo.utils-4.6.0 packaging-20.4 pbr-5.5.0 pycparser-2.20 pyparsing-2.4.7 pyperclip-1.8.0 python-cinderclient-7.2.0 python-keystoneclient-4.1.1 python-novaclient-17.2.1 python-openstackclient-5.3.1 pytz-2020.1 requests-2.24.0 requestsexceptions-1.4.0 rfc3986-1.4.0 simplejson-3.17.2 six-1.15.0 stevedore-3.2.2 urllib3-1.25.10 wcwidth-0.2.5 wrapt-1.12.1 zipp-3.3.0

つまり何が言いたいかというと、Catalinaはクソである。

追記: Command Line Tools 12.0を使いつつ、python-openstackclientも使う方法

Catalinaの場合、Command Line Toolsの導入以外の方法でPython3がインストールされているとそちらを優先して使うようで、次のようにしたら、この困った事象を回避できた。

Python 3.7の最新版をダウンロードしてインストールする。

Command Line Tools for Xcode 12.0をダウンロードしてインストールする

もしくは、以下を実行

$ softwareupdate --reset-ignored
$ softwareupdate --ignore "Command Line Tools beta 5 for Xcode"

このブログサイトはJavaScriptを使っていますが、読み込んでいるJavaScriptは全てはてなが提供しているものであり、筆者が設置しているものではありません。