python - Build a wheel and Install package version depending on OS - Stack Overflow

I have several python packages that need to be installed on various osenvironments. These packages hav

I have several python packages that need to be installed on various os/environments. These packages have dependencies and some of them like Polars needs a different package depending on the OS, for example: polars-lts-cpu on MacOS (Darwin) and polars on all the other OS.

I use setuptools to create a whl file, but the dependencies installed depend on the OS where the wheel file was created. Here is my code:

import platform
from setuptools import find_packages, setup

setup(
    ...
    install_requires=["glob2>=0.7",
                       "numpy>=1.26.4",
                       "polars>=1.12.0" if platform.system() != "Darwin" else "polars-lts-cpu>=1.12.0"]
    ...)

As mentioned above, this code installs the version of Polars according to the OS where the wheel file was created, not according to where the package will be installed.

How can I fix this?

I have several python packages that need to be installed on various os/environments. These packages have dependencies and some of them like Polars needs a different package depending on the OS, for example: polars-lts-cpu on MacOS (Darwin) and polars on all the other OS.

I use setuptools to create a whl file, but the dependencies installed depend on the OS where the wheel file was created. Here is my code:

import platform
from setuptools import find_packages, setup

setup(
    ...
    install_requires=["glob2>=0.7",
                       "numpy>=1.26.4",
                       "polars>=1.12.0" if platform.system() != "Darwin" else "polars-lts-cpu>=1.12.0"]
    ...)

As mentioned above, this code installs the version of Polars according to the OS where the wheel file was created, not according to where the package will be installed.

How can I fix this?

Share Improve this question asked Nov 21, 2024 at 1:46 FiReTiTiFiReTiTi 5,89813 gold badges34 silver badges62 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 3

Use declarative environment markers as described in PEP 496 and PEP 508:

   install_requires=[
      "polars>=1.12.0; platform_system!='Darwin'",
      "polars-lts-cpu>=1.12.0; platform_system=='Darwin'",
   ]

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742318864a4421395.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信