Python — установка numpy расширения из файла cpp без использования setup.py

У меня возникла проблема при попытке установить библиотеку Python (https://pypi.python.org/pypi?name=py_find_1st&: Действие = дисплей);

Я сделал пост некоторое время назад об этом, но я не получил ответ, который решил проблему (AttributeError: объект ‘MSVCCompiler’ не имеет атрибута ‘compiler’ при попытке установить пустое расширение), поэтому мне было интересно, можно ли использовать другой подход для его установки.

Когда я запускаю файл setup.py, я получаю сообщение об ошибке: AttributeError: 'MSVCCompiler' object has no attribute 'compiler',

У меня установлена ​​Visual Studio на моем компьютере с установленными инструментами сборки, и cl распознается как команда.

Я не знаю много о numpy расширении, но мне было интересно, есть ли возможность установить библиотеку без запуска setup.py, так как она не работает на моем компьютере, и у меня есть файл cpp в папке расширений.

Буду очень признателен за любую помощь, я выкладываю полное сообщение об ошибке и код setup.py ниже:

Редактировать: Я обнаружил, что установка может быть установлена ​​с использованием pip, я получаю такое же сообщение об ошибке в cmd с дополнительным красным, я добавил его в нижней части поста.

Сообщение об ошибке:

D:\Chrome dl\py_find_1st-1.0.6\py_find_1st-1.0.6>python setup.py install
running install
running bdist_egg
running egg_info
writing top-level names to py_find_1st.egg-info\top_level.txt
writing py_find_1st.egg-info\PKG-INFO
writing dependency_links to py_find_1st.egg-info\dependency_links.txt
reading manifest file 'py_find_1st.egg-info\SOURCES.txt'
writing manifest file 'py_find_1st.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_py
running build_ext
Traceback (most recent call last):
File "setup.py", line 117, in <module>
zip_safe = False,
File "D:\Anaconda\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "D:\Anaconda\lib\distutils\dist.py", line 955, in run_commands
self.run_command(cmd)
File "D:\Anaconda\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "D:\Anaconda\lib\site-packages\setuptools-3.5.1-py3.5.egg\setuptools\command\install.py", line 65, in run
File "D:\Anaconda\lib\site-packages\setuptools-3.5.1-py3.5.egg\setuptools\command\install.py", line 107, in do_egg_install
File "D:\Anaconda\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "D:\Anaconda\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "D:\Anaconda\lib\site-packages\setuptools-3.5.1-py3.5.egg\setuptools\command\bdist_egg.py", line 157, in run
File "D:\Anaconda\lib\site-packages\setuptools-3.5.1-py3.5.egg\setuptools\command\bdist_egg.py", line 143, in call_command
File "D:\Anaconda\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "D:\Anaconda\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "D:\Anaconda\lib\site-packages\setuptools-3.5.1-py3.5.egg\setuptools\command\install_lib.py", line 8, in run
File "D:\Anaconda\lib\distutils\command\install_lib.py", line 107, in build
self.run_command('build_ext')
File "D:\Anaconda\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "D:\Anaconda\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "D:\Anaconda\lib\distutils\command\build_ext.py", line 338, in run
self.build_extensions()
File "setup.py", line 42, in build_extensions
if compiler_is_clang(self.compiler.compiler):
AttributeError: 'MSVCCompiler' object has no attribute 'compiler'

Содержание setup.py:

#! /usr/bin/env python
from __future__ import print_function
from ez_setup import use_setuptools
use_setuptools()

from setuptools import setup
from distutils.extension import Extension
from distutils.command.build_ext import build_ext
from distutils.command.sdist import sdist

import numpy as np
import os
import sys
import re
import subprocess
import errno

def compiler_is_clang(comp) :
print("check for clang compiler ...", end=' ')
try:
cc_output = subprocess.check_output(comp+['--version'],
stderr = subprocess.STDOUT, shell=False)
except OSError as ex:
print("compiler test call failed with error {0:d} msg: {1}".format(ex.errno, ex.strerror))
print("no")
return False

ret = re.search(b'clang', cc_output) is not None
if ret :
print("yes")
else:
print("no")
return retclass build_ext_subclass( build_ext ):
def build_extensions(self):
#c = self.compiler.compiler_type
#print "compiler attr", self.compiler.__dict__
#print "compiler", self.compiler.compiler
#print "compiler is",c
if compiler_is_clang(self.compiler.compiler):
for e in self.extensions:
e.extra_compile_args.append('-stdlib=libstdc++')
e.extra_compile_args.append('-Wno-unused-function')
for e in self.extensions:
e.extra_link_args.append('-stdlib=libstdc++')
build_ext.build_extensions(self)find_1st_ext = Extension("find_1st", ["utils_find_1st/find_1st.cpp"],
include_dirs=[np.get_include()],
language="c++"   )ext_modules=[find_1st_ext]# get _pysndfile version number
for line in open("utils_find_1st/__init__.py") :
if "version" in line:
version = re.split('[()]', line)[1].replace(',','.')
break

# Utility function to read the README file.
# Used for the long_description.  It's nice, because now 1) we have a top level
# README file and 2) it's easier to type in the README file than to put a raw
# string in below ...
def update_long_descr():
README_path     = os.path.join(os.path.dirname(__file__), 'README.md')
LONG_DESCR_path = os.path.join(os.path.dirname(__file__), 'LONG_DESCR')
if ((not os.path.exists(LONG_DESCR_path))
or os.path.getmtime(README_path) > os.path.getmtime(LONG_DESCR_path)):
try :
subprocess.check_call(["pandoc", "-f", "markdown", '-t', 'rst', '-o', LONG_DESCR_path, README_path], shell=False)
except (OSError, subprocess.CalledProcessError) :
print("setup.py::error:: pandoc command failed. Cannot update LONG_DESCR.txt from modified README.txt")
return open(LONG_DESCR_path).read()

def read_long_descr():
LONG_DESCR_path = os.path.join(os.path.dirname(__file__), 'LONG_DESCR')
return open(LONG_DESCR_path).read()

class sdist_subclass(sdist) :
def run(self):
# Make sure the compiled Cython files in the distribution are up-to-date
update_long_descr()
sdist.run(self)setup( name = "py_find_1st",
version = version,
packages = ['utils_find_1st'],
ext_package = 'utils_find_1st',
ext_modules = ext_modules,
author = "A. Roebel",
description = "Numpy extension module for efficient search of first array index that compares true",
cmdclass = {'build_ext': build_ext_subclass, "sdist": sdist_subclass },
author_email = "axel.dot.roebel@ircam.dot.fr",
long_description = read_long_descr(),
license = "GPL",
url = "http://github.com/roebel/py_find_1st",
download_url = "https://github.com/roebel/py_find_1st/archive/v{0}.tar.gz".format(version),
keywords = "numpy,extension,find",
classifiers = [
"Topic :: Software Development :: Libraries :: Python Modules",
"Programming Language :: Python :: 3",
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: GNU General Public License (GPL)",
"Operating System :: MacOS :: MacOS X",
"Operating System :: POSIX :: Linux",
"Operating System :: Microsoft :: Windows",
],

# don't install as zip file because those cannot be analyzed by pyinstaller
zip_safe = False,
)

Красное сообщение об ошибке в cmd при попытке установить расширение с помощью pip:

Command "D:\Anaconda\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\erlin\\AppData\\Local\\Temp\\pip-build-1k70u6ig\\py-find-1st\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\erlin\AppData\Local\Temp\pip-szd7d6ya-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\erlin\AppData\Local\Temp\pip-build-1k70u6ig\py-find-1st\

1

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector