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'",
]
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742318864a4421395.html
评论列表(0条)