whl is not a supported wheel on this platform

使用cypthon编译的程序带有“cp37-cp37m-linux_x86_64.whl”

实际安装的时候显示whl is not a supported wheel on this platform。

一时间不知道该怎么处理。

查看系统支持的安装版本

1、首先获取系统版本信息

import platform
print(platform.platform())

输出信息Linux-xxxxxxx-x86_64-with-glibc2.29.

2、判断pip能安装的数据类型

import wheel.pep425tags as w
print(w.get_supported("linux_x86_64"))

输出('cp38','cp38','linux_x86_64')。

3、就是改名字

“cp37-cp37m-linux_x86_64.whl”---》“cp38-cp38-linux_x86_64.whl”

4、待验证了。

实际运行的时候还是会有找不到文件的提示,因此so文件不要添加扩展名

import os
import sysconfig

from distutils.core import setup
from Cython.Build import cythonize
from Cython.Distutils import build_ext


def get_ext_filename_without_platform_suffix(filename):
    name, ext = os.path.splitext(filename)
    ext_suffix = sysconfig.get_config_var('EXT_SUFFIX')

    if ext_suffix == ext:
        return filename

    ext_suffix = ext_suffix.replace(ext, '')
    idx = name.find(ext_suffix)

    if idx == -1:
        return filename
    else:
        return name[:idx] + ext


class BuildExtWithoutPlatformSuffix(build_ext):
    def get_ext_filename(self, ext_name):
        filename = super().get_ext_filename(ext_name)
        return get_ext_filename_without_platform_suffix(filename)


setup(
    name="foo",
    cmdclass={'build_ext': BuildExtWithoutPlatformSuffix},
    ext_modules=cythonize("foo.pyx")
)

你可能感兴趣的:(linux,运维,服务器)