55 words
1 minute
Use setup.py to install platform-specific dependencies
Anubhav Gain
2024-06-28

Use setup.py to install platform-specific dependencies#

For photos-to-sqlite I needed to install osxphotos as a dependency, but only if the platform is macOS - it’s not available for Linux.

Here’s the magic incantation to do that:

setup(
name="photos-to-sqlite",
...
install_requires=[
"sqlite-utils>=2.7",
"boto3>=1.12.41",
"osxphotos>=0.28.13 ; sys_platform=='darwin'",
]
)

So ; sys_platform=='darwin' in the install requires line.

More details: https://www.python.org/dev/peps/pep-0508/#environment-markers and https://hynek.me/articles/conditional-python-dependencies/

Use setup.py to install platform-specific dependencies
https://mranv.pages.dev/posts/use-setuppy-to-install-platform-specific-dependencies/
Author
Anubhav Gain
Published at
2024-06-28
License
CC BY-NC-SA 4.0