pypa / setuptools

Official project repository for the Setuptools build system
https://pypi.org/project/setuptools/
MIT License
2.5k stars 1.19k forks source link

Binary wheel 'zhlyr-4.2-cp312-cp312-linux_x86_64.whl' has an unsupported platform tag 'linux_x86_64'. #4359

Closed Gaoc3 closed 5 months ago

Gaoc3 commented 5 months ago

setuptools version

69.5.1

Python version

3.12.3

OS

Ubuntu 22.04.4 LTS on Windows 10 x86_64

Additional environment information

This only happend in my linux However, I'm not encountering this issue on my Windows system.

Description

When attempting to upload the wheel file "zhlyr-4.2-cp312-cp312-linux_x86_64.whl" using Twine, an error message is displayed indicating that the platform tag "linux_x86_64" is unsupported.

Expected behavior

i wanted to upload my library that contains some cython to pypi as first library for me

How to Reproduce

From Ubuntu OS : 1 - build my library that have cython files using python setup.py bdist_wheel 2 - upload library to pypi using twine

Output

Binary wheel 'zhlyr-4.2-cp312-cp312-linux_x86_64.whl' has an unsupported platform tag 'linux_x86_64'.
abravalheri commented 5 months ago

Hi @Gaoc3, could you please provide a minimal reproducible example? The methodology to create one is described in https://stackoverflow.com/help/minimal-reproducible-example.

Also please do not use the deprecated python setup.py bdist_wheel functionality. More information about the supported alternative in https://setuptools.pypa.io/en/latest/build_meta.html#how-to-use-it.

You should also list all your build dependencies (including setuptools itself and Cython) in pyproject.toml's [build-system] requires.

For compiling and publishing multi-platform wheels, a good place to start is by looking at https://cibuildwheel.pypa.io/en/stable/ (PyPI is likely to require wheels to be build on manylinux platform).

Gaoc3 commented 5 months ago

Hi @Gaoc3, could you please provide a minimal reproducible example? The methodology to create one is described in https://stackoverflow.com/help/minimal-reproducible-example.

Also please do not use the deprecated python setup.py bdist_wheel functionality. More information about the supported alternative in https://setuptools.pypa.io/en/latest/build_meta.html#how-to-use-it.

You should also list all your build dependencies (including setuptools itself and Cython) in pyproject.toml's [build-system] requires.

For compiling and publishing multi-platform wheels, a good place to start is by looking at https://cibuildwheel.pypa.io/en/stable/ (PyPI is likely to require wheels to be build on manylinux platform).

I used setup.py contain this code :

from setuptools import setup, find_packages
from Cython.Build import cythonize
import os
import zhlyr
with open('README.md', 'r') as file:
    long_description = file.read()

base_dir = os.path.dirname(os.path.abspath(__file__))

pyx_files = [os.path.join(root, file) for root, dirs, files in os.walk(base_dir) for file in files if file.endswith('.pyx')]
pyc_files = [os.path.join(root, file) for root, dirs, files in os.walk(base_dir) for file in files if file.endswith('.c')]
pyso_files = [os.path.join(root, file) for root, dirs, files in os.walk(base_dir) for file in files if file.endswith('.so')]

setup(
    name='zhlyr',
    version='4.8',
    packages=find_packages(),
    install_requires=['requests', 'shazamio', 'shazam', 'cython'],
    ext_modules=cythonize(pyx_files),
    long_description=long_description,
    long_description_content_type='text/markdown',
    description='Python library for music handling',
    author='Mtsky',
    author_email='secon2636@gmail.com',
    url='https://gaoc3.github.io/zhlyr/',
    license='MIT',
    classifiers=[
        "Development Status :: 1 - Planning",
        "Intended Audience :: Developers",
        "License :: OSI Approved :: MIT License",
        "Programming Language :: Python :: 3.9",
        "Programming Language :: Python :: 3",
        "Operating System :: Unix",
        "Operating System :: MacOS :: MacOS X",
        "Operating System :: Microsoft :: Windows",
    ],
    keywords=['lyrics', 'music', 'shazam', 'serialize', 'serializer', 'recognize'],
    python_requires=">=3.9",
    package_data={'zhlyr': pyso_files + pyc_files}
)

I'm sure that the Cython file has no errors. I tried it locally and it worked, but when I rebuild it with setuptools and then I want to upload it to pypi with twine through the command:

twine upload dist/*

But I see the message that I shared above. I tried to solve the problem using the manylinux Tools, but it uploads the library to only one distribution, which is Linux, and the update will not reach any distribution other than Linux. I mean, the update will not even reach any distribution other than Linux. I tried to update the library on Windows. Through the bash pip install -U zhlyr command, it tells me that the library is in the latest version , even though it is not updated, and that the update does not reach the Windows distribution if the user tries to update it. What is the solution, please.

abravalheri commented 5 months ago

but it uploads the library to only one distribution, which is Linux, and the update will not reach any distribution other than Linux.

I think that is the expected behaviour. The ".whl" file (a.k.a, wheel, the Python package binary distribution archive) built with Cython (and/or any C/Rust/Go etc...) is platform dependent so you need to build one ".whl" for each platform. Then you upload all of those files to PyPI.

I tried to update the library on Windows. Through the bash pip install -U zhlyr command, it tells me that the library is in the latest version , even though it is not updated, and that the update does not reach the Windows distribution if the user tries to update it.

I suppose the wheel for Windows was never built and uploaded to PyPI, so pip on Windows cannot find any newer candidate.

I recommend checking cibuildwheel to learn how to build and upload multiple distributions for all the mainstream platforms at the same time using a continuous integration service.

You can also upload the sdist so that users of non-mainstream platforms can still have a chance to compile the package themselves.

abravalheri commented 5 months ago

I am planning to move this thread to "Discussions" because I don't think there is a direct bug in setuptools here. The .whl file produced should be able to be installed in the same machine it is built, and Setuptools does not natively covers cross-compilation.

Using additional tools like cibuildwheel, on top of the existing setup.py that runs setuptools, is suggested to cover multiple platforms.

The choice of which platform tags PyPI wants to support is also not controlled by setuptools.

Gaoc3 commented 5 months ago

Using additional tools like cibuildwheel, on top of the existing setup.py that runs setuptools, is suggested to cover multiple platforms.

How i can do that? , please.

Gaoc3 commented 5 months ago

but it uploads the library to only one distribution, which is Linux, and the update will not reach any distribution other than Linux.

I think that is the expected behaviour. The ".whl" file (a.k.a, wheel, the Python package binary distribution archive) built with Cython (and/or any C/Rust/Go etc...) is platform dependent so you need to build one ".whl" for each platform. Then you upload all of those files to PyPI.

I tried to update the library on Windows. Through the bash pip install -U zhlyr command, it tells me that the library is in the latest version , even though it is not updated, and that the update does not reach the Windows distribution if the user tries to update it.

I suppose the wheel for Windows was never built and uploaded to PyPI, so pip on Windows cannot find any newer candidate.

I recommend checking cibuildwheel to learn how to build and upload multiple distributions for all the mainstream platforms at the same time using a continuous integration service.

You can also upload the sdist so that users of non-mainstream platforms can still have a chance to compile the package themselves.

I don't know how to use toml or cibuildwheel , only setuptools to built my library , is there any tutorials of that?

abravalheri commented 5 months ago

You can find the documentation for cibuildwheel in the links shared previously.