Создать расширение Cython в среде fre sh: не удается найти /lib/libpthread.so.0 - PullRequest
0 голосов
/ 19 февраля 2020

Я пытаюсь развернуть пакет, который использует некоторые расширения Cython. Я написал следующий скрипт установки:

import os
import sys
from setuptools import setup, Extension

# factory function
def my_build_ext(pars):
    # import delayed:
    from setuptools.command.build_ext import build_ext as _build_ext

    # include_dirs adjusted: 
    class build_ext(_build_ext):
        def finalize_options(self):
            _build_ext.finalize_options(self)
            # Prevent numpy from thinking it is still in its setup process:
            __builtins__.__NUMPY_SETUP__ = False
            import numpy
            self.include_dirs.append(numpy.get_include())

    #object returned:
    return build_ext(pars)

# cython c++ extensions
extnames = [
    'npextc',
    'intquickheapdict',
    'FixedOrderedIntDict'
    ]

...

PATHADD = 'vemomoto_core/npcollections/'
PACKAGEADD = PATHADD.replace("/", ".")

ext = '.pyx'

extensions = [Extension(PACKAGEADD+name, [PATHADD+name+ext],
                        extra_compile_args=['-std=c++11', '-O3']+parcompileargs,
                        extra_link_args=parlinkargs,
                        )
              for name in extnames]
for e in extensions:
    e.language_level = 3
    e.language = 'c++'

setup(
    name="vemomoto_core_npcollections",
    version="0.9.0.a7",
    cmdclass={'build_ext' : my_build_ext},
    setup_requires=['numpy', 'setuptools>=18.0'],
    install_requires=['numpy', 'scipy'], 
    python_requires='>=3.6',
    packages=['vemomoto_core', PACKAGEADD[:-1]],
    ext_modules=extensions,
    package_data={
        '': ['*.pxd', '*.pyx', '*.c', '*.cpp'],
    },
    zip_safe=False,
)

Когда я собираю пакет с помощью выполнения pip install . в каталоге setup.py, все работает нормально, пока я работаю в среде по умолчанию. Однако, когда я тестирую процесс в тестовой среде fre sh, я получаю сообщение об ошибке

    /home/user/anaconda3/envs/test37/compiler_compat/ld: cannot find /lib/libpthread.so.0
    /home/user/anaconda3/envs/test37/compiler_compat/ld: cannot find /usr/lib/libpthread_nonshared.a
    collect2: error: ld returned 1 exit status
    error: command 'g++' failed with exit status 1

(полный вывод ниже.)

Я предполагаю, что отсутствует некоторая зависимость здесь, но я понятия не имею, как я мог узнать, что это такое и, следовательно, как устранить ошибку. Что я мог сделать?

Полное сообщение об ошибке:

Building wheels for collected packages: vemomoto-core-npcollections                                                                                                                                   [76/1898]
  Building wheel for vemomoto-core-npcollections (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /home/user/anaconda3/envs/test37/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-0_ns61r9/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-0_ns61r9/se
tup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-4zeu
yeay
       cwd: /tmp/pip-req-build-0_ns61r9/
  Complete output (49 lines):
  /home/user/anaconda3/envs/test37/lib/python3.7/site-packages/setuptools/dist.py:476: UserWarning: Normalizing '0.9.0.a1' to '0.9.0a1'
    normalized_version,
  running bdist_wheel
  running build
  running build_py
  package init file 'vemomoto_core/__init__.py' not found (or not a regular file)
  creating build
  creating build/lib.linux-x86_64-3.7
  creating build/lib.linux-x86_64-3.7/vemomoto_core
  creating build/lib.linux-x86_64-3.7/vemomoto_core/npcollections
  copying vemomoto_core/npcollections/_setup_npextc.py -> build/lib.linux-x86_64-3.7/vemomoto_core/npcollections
  copying vemomoto_core/npcollections/sparse3d.py -> build/lib.linux-x86_64-3.7/vemomoto_core/npcollections
  copying vemomoto_core/npcollections/_setup_FixedOrderedIntDict.py -> build/lib.linux-x86_64-3.7/vemomoto_core/npcollections
  copying vemomoto_core/npcollections/_FixedOrderedIntDict_reduce.py -> build/lib.linux-x86_64-3.7/vemomoto_core/npcollections
  copying vemomoto_core/npcollections/__init__.py -> build/lib.linux-x86_64-3.7/vemomoto_core/npcollections                                                                                                      copying vemomoto_core/npcollections/_setup_intquickheapdict.py -> build/lib.linux-x86_64-3.7/vemomoto_core/npcollections                                                                                       copying vemomoto_core/npcollections/npext.py -> build/lib.linux-x86_64-3.7/vemomoto_core/npcollections
  copying vemomoto_core/npcollections/_npextc_utils.py -> build/lib.linux-x86_64-3.7/vemomoto_core/npcollections
  copying vemomoto_core/__init__.pxd -> build/lib.linux-x86_64-3.7/vemomoto_core
  copying vemomoto_core/npcollections/FixedOrderedIntDict.pxd -> build/lib.linux-x86_64-3.7/vemomoto_core/npcollections
  copying vemomoto_core/npcollections/npextc.pxd -> build/lib.linux-x86_64-3.7/vemomoto_core/npcollections
  copying vemomoto_core/npcollections/intquickheapdict.pxd -> build/lib.linux-x86_64-3.7/vemomoto_core/npcollections
  copying vemomoto_core/npcollections/intquickheapdict.pyx -> build/lib.linux-x86_64-3.7/vemomoto_core/npcollections                                                                                             copying vemomoto_core/npcollections/npextc.pyx -> build/lib.linux-x86_64-3.7/vemomoto_core/npcollections
  copying vemomoto_core/npcollections/FixedOrderedIntDict.pyx -> build/lib.linux-x86_64-3.7/vemomoto_core/npcollections
  copying vemomoto_core/npcollections/heapoperations_c.c -> build/lib.linux-x86_64-3.7/vemomoto_core/npcollections
  copying vemomoto_core/npcollections/sectionsum.c -> build/lib.linux-x86_64-3.7/vemomoto_core/npcollections                                                                                                     copying vemomoto_core/npcollections/intquickheapdict.cpp -> build/lib.linux-x86_64-3.7/vemomoto_core/npcollections                                                                                             copying vemomoto_core/npcollections/FixedOrderedIntDict.cpp -> build/lib.linux-x86_64-3.7/vemomoto_core/npcollections
  copying vemomoto_core/npcollections/npextc.cpp -> build/lib.linux-x86_64-3.7/vemomoto_core/npcollections
  running build_ext
  building 'vemomoto_core.npcollections.npextc' extension
  creating build/temp.linux-x86_64-3.7
  creating build/temp.linux-x86_64-3.7/vemomoto_core
  creating build/temp.linux-x86_64-3.7/vemomoto_core/npcollections                                                                                                                                               gcc -pthread -B /home/user/anaconda3/envs/test37/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/user/anaconda3/envs/test37/include/python3.7m -I/home/user/anaconda3/envs/test37/lib/python3.7/site-packages/numpy/core/include -c vemomoto_core/npcollections/npextc.cpp -o build/temp.linux-x86_64-3.7/vemomoto_core/npcollections/npextc.o -std=c++11 -O3 -fopenmp
  cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
  In file included from /home/user/anaconda3/envs/test37/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1832:0,
                   from /home/user/anaconda3/envs/test37/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,
                   from /home/user/anaconda3/envs/test37/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,
                   from vemomoto_core/npcollections/npextc.cpp:636:
  /home/user/anaconda3/envs/test37/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEP
RECATED_API NPY_1_7_API_VERSION" [-Wcpp]
   #warning "Using deprecated NumPy API, disable it with " \
    ^~~~~~~
  g++ -pthread -shared -B /home/user/anaconda3/envs/test37/compiler_compat -L/home/user/anaconda3/envs/test37/lib -Wl,-rpath=/home/user/anaconda3/envs/test37/lib -Wl,--no-as-needed -Wl,--sysroot=
/ -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -Wl,--gc-sections build/temp.linux-x86_64-3.7/vemomoto_core/npcollections/npextc.o -o build/lib.linux-x86_64-3.7/ve
momoto_core/npcollections/npextc.cpython-37m-x86_64-linux-gnu.so -fopenmp
  /home/user/anaconda3/envs/test37/compiler_compat/ld: cannot find /lib/libpthread.so.0
  /home/user/anaconda3/envs/test37/compiler_compat/ld: cannot find /usr/lib/libpthread_nonshared.a
  collect2: error: ld returned 1 exit status
  error: command 'g++' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for vemomoto-core-npcollections
  Running setup.py clean for vemomoto-core-npcollections
Failed to build vemomoto-core-npcollections

1 Ответ

0 голосов
/ 19 февраля 2020

Чтобы решить эту проблему, я сравнил среду anaconda fre sh с той, которую использовал. Для этого я использовал

conda list

как в более старой, так и в fre sh установке и сравнил вывод. Затем я искал пакеты, которые были включены в старую среду, но не в новую среду, и у которых было имя, указывающее, что они могут включать в себя правильные файлы.

После установки кандидатов и повторной попытки сборки я обнаружил, что gxx_linux-64 (и для другого пакета cmake) были необходимые требования для сборки. Поскольку эти пакеты, по-видимому, недоступны в PyPI, я буду требовать от конечных пользователей использования команд anaconda

conda install gxx_linux-64
conda install cmake

перед установкой моего пакета. Было бы неплохо включить эту зависимость в скрипт установки, но это другой вопрос ...

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...