0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Macでのpython-axolotl-curve25519インストール時のエラー対処

Posted at

前置き

この前、MacBook Proでpython-axolotl-curve25519をインストールしようとしたら、エラーが出たので対処法を書き留めておく。
github: https://github.com/tgalal/python-axolotl-curve25519

エラー内容

DEPRECATION: Loading egg at /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/python_axolotl-0.2.3-py3.11.egg is deprecated. pip 24.3 will enforce this behaviour change. A possible replacement is to use pip for package installation.. Discussion can be found at https://github.com/pypa/pip/issues/12330
Collecting python-axolotl-curve25519
  Using cached python-axolotl-curve25519-0.4.1.post2.tar.gz (79 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: python-axolotl-curve25519
  Building wheel for python-axolotl-curve25519 (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [104 lines of output]
      /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/setuptools/dist.py:318: InformationOnly: Normalizing '0.4.1-2' to '0.4.1.post2'
        self.metadata.version = self._normalize_version(self.metadata.version)
      running bdist_wheel
      running build
      running build_ext
      building 'axolotl_curve25519' extension
      creating build
      creating build/temp.macosx-10.9-universal2-cpython-311
 .
 .
 .
 
      clang -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g -Icurve/ed25519/nacl_includes -Icurve/ed25519/additions -Icurve/ed25519 -I/Library/Frameworks/Python.framework/Versions/3.11/include/python3.11 -c curve25519module.c -o build/temp.macosx-10.9-universal2-cpython-311/curve25519module.o
      curve25519module.c:161:9: error: incompatible pointer to integer conversion initializing 'Py_ssize_t' (aka 'long') with an expression of type 'void *' [-Wint-conversion]
              NULL,
              ^~~~
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_null.h:30:15: note: expanded from macro 'NULL'
      #define NULL  __DARWIN_NULL
                    ^~~~~~~~~~~~~
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types.h:52:23: note: expanded from macro '__DARWIN_NULL'
      #define __DARWIN_NULL ((void *)0)
                            ^~~~~~~~~~~
      1 error generated.
      error: command '/usr/bin/clang' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for python-axolotl-curve25519
  Running setup.py clean for python-axolotl-curve25519
Failed to build python-axolotl-curve25519
ERROR: Could not build wheels for python-axolotl-curve25519, which is required to install pyproject.toml-based projects

原因

ビルドプロセス中にエラーが発生しているようだ。
curve25519module.cというファイルでの型変換の問題が原因でコンパイルが失敗している。
エラーメッセージによると、Py_ssize_t 型の変数を void* 型の NULL で初期化しようとしているため、型の不一致が発生している。
解決するためには、ソースコードを修正する必要があった。
具体的には、 NULL を直接 Py_ssize_t 型の変数に割り当てるのではなく、適切な整数値(通常は 0)で初期化する必要がある。

解決策

上記Githubリンクからダウンロード後、curve25519module.cを開き161行目を書き換える。

#if PY_MAJOR_VERSION >= 3
    static struct PyModuleDef
    curve25519_module = {
        PyModuleDef_HEAD_INIT,
        "axolotl_curve25519",
        NULL,
        0, //NULLを0に書き換える。
        curve25519_functions,
    };

    PyObject *
    PyInit_axolotl_curve25519(void)
    {
        return PyModule_Create(&curve25519_module);
    }

変更したらターミナルを開いて、

python setup.py install

これでインストールできるはずだ。
Windowsは、これをしなくてもVisual Studio C/C++ コンパイラを入れればできる(多分)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?