admin管理员组文章数量:1332361
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 badges1 Answer
Reset to default 3Use 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'",
]
本文标签: pythonBuild a wheel and Install package version depending on OSStack Overflow
版权声明:本文标题:python - Build a wheel and Install package version depending on OS - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742318864a2452371.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论