我正在尝试使用 setup.py 为项目安装包。当我运行命令 python setup.py install 时,我收到有关直接使用 setup.py 的弃用警告。尽管如此,安装仍然继续,但失败并出现致命错误。
该错误表明无法找到文件assert.h,并且Microsoft Visual Studio构建工具在编译过程中失败。
setup.py 文件
import os
from distutils.core import setup, Extension
sources = [
'src/python/core.c',`enter code here`
'src/libethash/io.c',
'src/libethash/internal.c',
'src/libethash/sha3.c']
if os.name == 'nt':
sources += [
'src/libethash/util_win32.c',
'src/libethash/io_win32.c',
'src/libethash/mmap_win32.c',
]
else:
sources += [
'src/libethash/io_posix.c'
]
depends = [
'src/libethash/ethash.h',
'src/libethash/compiler.h',
'src/libethash/data_sizes.h',
'src/libethash/endian.h',
'src/libethash/ethash.h',
'src/libethash/io.h',
'src/libethash/fnv.h',`enter code here`
'src/libethash/internal.h',
'src/libethash/sha3.h',
'src/libethash/util.h',
]
pyethash = Extension('pyethash',
sources=sources,
depends=depends,
extra_compile_args=["-Isrc/", "-std=gnu99", "-Wall"])
setup(
name='pyethash',
author="Matthew Wampler-Doty",
author_email="[email protected]",
license='GPL',
version='0.1.23',
url='https://github.com/ethereum/ethash',
download_url='https://github.com/ethereum/ethash/tarball/v23',
description=('Python wrappers for ethash, the ethereum proof of work'
'hashing function'),
ext_modules=[pyethash],
)
错误:
(py_venv) C:\Users\Vijay.VC-VIJAYPATIL\vc_project\inhouse_projects\ethash-master>python setup.py install
C:\Users\Vijay.VC-VIJAYPATIL\anaconda3\envs\py_venv\lib\site-packages\setuptools\_distutils\cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
!!
********************************************************************************
Please avoid running ``setup.py`` directly.
Instead, use pypa/build, pypa/installer or other
standards-based tools.
See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
********************************************************************************
!!
self.initialize_options()
C:\Users\Vijay.VC-VIJAYPATIL\anaconda3\envs\py_venv\lib\site-packages\setuptools\_distutils\cmd.py:66: EasyInstallDeprecationWarning: easy_install command is deprecated.
!!
********************************************************************************
Please avoid running ``setup.py`` and ``easy_install``.
Instead, use pypa/build, pypa/installer or other
standards-based tools.
See https://github.com/pypa/setuptools/issues/917 for details.
********************************************************************************
!!
self.initialize_options()
warning: no files found matching 'src\libethash\util.c'
cl : Command line warning D9002 : ignoring unknown option '-std=gnu99'
internal.c
src/libethash/internal.c(23): fatal error C1083: Cannot open include file: 'assert.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.41.34120\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
Python
ethereum
包不再维护。
五年多以来,任何 Python 项目都不应该使用或需要它。如果某个项目使用它,那么该项目的维护者就需要删除它。
真正的问题是你为什么认为你首先需要这个包。