0

I am trying to build a package that depending on the os of the target machine will include an extra package. More specifically my application depends on redis however when the machine where the package is going to be deployed to runs linux, I would like to have redis-server as an extra dependency.

What I was thinking to do is to have in my setup.py the following lines:

from setuptools import setup, find_packages
import sys


install_deps = ['redis']

if sys.platform in ['linux', 'darwin']:
    install_deps.append('redis-server')


setup(
    name="my_app",
    version=version,
    license="BSD",
    author="first_name last_name",
    author_email="first.last@mymail.com",

    packages=find_packages(),
    install_requires=install_deps,
)

That unfortunately doest work since the value of install_deps is determined the moment I run 'python setup.py sdist bdist_wheel' on the the machine that keeps the source code and not when I install the wheel on the new (target) machine. I would like when I deploy my package and do pip install my_app on a windows pc to install only redis as a requirement but when the targer computer runs linux, pip to fetch both redis and redis-server into the environment.

Is there a way to do that without releasing two different builds, one for windows and another for linux?

Aenaon
  • 3,169
  • 4
  • 32
  • 60
  • https://stackoverflow.com/a/42946495/7976758 Found in https://stackoverflow.com/search?q=%5Bsetuptools%5D+conditional+dependencies – phd Aug 30 '23 at 20:52
  • https://stackoverflow.com/a/16055603/7976758 Found in https://stackoverflow.com/search?q=%5Bsetuptools%5D+platform-specific+dependencies – phd Aug 30 '23 at 20:53

0 Answers0