How can I create a Python package with a platform?

I have a Python package that can only run effectively on Linux. I saw in docs that there is a key platformsin the metadata setup.py, but as far as I can tell from the jolting in the source distutils, this metadata is actually not used for anything.

Then I went and looked at PyObjC, the famous X-only Python package. I noticed that it fills the above platformskey in setup.py. However, when I try to install PyObjC on Linux, the installation is not prevented or blocked in any deliberate way. Failed failure mode: it fails when it platform.mac_ver()returns a value that it does not expect. I tried to fix this problem manually, and distutilsit seemed to be going with my fun way of collecting dependencies, etc., So far, in the end, I could not find a specific platform file ... The bottom line distutilsdoes not process packages for a specific platform by any reasonable way.

Ideally, I expected the installation to complete with some message indicating that the package is not compatible with the current platform. I was a little bothered, and the "best" thing that I could think of, includes subclassing teams installand developand manual test platform.

Is there a better way?

+4
source share
1 answer

I probably simplify, but at the top of yours setup.pyyou could not just do something like:

import platform
distname,version,id = platform.linux_distribution()
if not distname:
   raise Exception('Aborting installation: Requires Linux')
+2
source

Source: https://habr.com/ru/post/1610180/


All Articles