0

Problem

I have created a python package with binary components and depending on windows 10 platform. I used various classifiers to specify the target platform and environment:

 classifiers=(
    "Development Status :: 5 - Production/Stable",
    "Environment :: Console",
    "License :: Other/Proprietary License",
    "Operating System :: Microsoft :: Windows :: Windows 10",
    "Programming Language :: Python :: 3.9",
    "Programming Language :: Python :: Implementation :: CPython",
    "Topic :: Scientific/Engineering :: Medical Science Apps."
)

My expectation is, that the pip wheel is respecting these classifiers and creates a package for the appropriate platform. I use the following command (python 3.9) to create the wheel package:

 pip wheel mypack-1.0.0.zip

The resulting package name is

mypack-1.0.0-py3-none-any.whl

My expectation would be to get

mypack-1.0.0-cp39-cp39-win32.whl

Or something similar.

What I found out

I already found out that the content of the classifier field in setup.py is not really exactly defined. At least there is a list of typically used classifiers. Obviously this did not bring me forward.

Question

How can I tell pip wheel to produce a package that is limited to the platform and python version I specified in setup.py?

Georg W.
  • 1,292
  • 10
  • 27

1 Answers1

0

The trove classifiers don't affect the package tag, they're just for humans.

The wheeling process will use the broadest available specifier for your package.

If your package does not contain binary components that are compiled against a certain Python, OS, or CPU architecture, then py3-none-any is an excellent specifier.

If you don't have binary components, but want to fool the build process to think you do, here's one approach to do that – but really, there's no point in forcibly doing so.

AKX
  • 152,115
  • 15
  • 115
  • 172
  • The package has binary dependencies to OS and python version. This is why I need it to be build specifically. How can I do that? That was my question. Not tweaking the build process. – Georg W. May 16 '23 at 08:14
  • @GeorgW. Well, the crucial detail you left out of your original question was that you _do_ have specific binary dependencies. You will need to customize the build process if you've somehow shoved in binary bits that the default build isn't aware of; the linked answer has an easy hack to do just that. – AKX May 16 '23 at 08:19
  • As an aside, there is no tag for specifically `win10` that I'm aware of. – AKX May 16 '23 at 08:20
  • Do I understand correctly, that the build process is ignoring the information in the classifier about platform, python version and OS? So where and how can I specify that my package is binary dependent on OS and platform? – Georg W. May 16 '23 at 08:29
  • Yes, you're understanding correctly. The trove classifiers are just for humans and don't affect the package tag. You can run `python setup.py bdist_wheel --plat-name foo` to replace the platform-name part with what you like, but note it needs to be compatible with the usual tagging system (see `pip debug`) for `pip` to be able to install your package. IOW, don't try and shoehorn `win10` into the tag if `win10` isn't in `pip debug`'s output. – AKX May 16 '23 at 08:40
  • What I learned: There is no control on target platform and python version in setup.py, I have to do that in the build process on my own. My solution is now after building the wheel with `pip wheel` repack it with `wheel tags --python-tag=cp39 --abi-tag=cp39 --platform-tag=win32 mypack-1.0.0-py3-none-any.whl` what creates the expected output `mypack-1.0.0-cp39-cp39-win32.whl` – Georg W. May 16 '23 at 08:59