Conditional setup.py

I’m trying to run a conditional setup.py to choose between mac and linux dependencies, but snapcraft installs mac dependencies even if the condition is false (it’s actually running on ubuntu)

Any help regarding this would be a joy

Luís

Is the version of setuptools new enough to support it?

Can you share your test case or something to reproduce with?

from setuptools import setup, find_packages
import sys

APP = []
DATA_FILES = []
OPTIONS = {}
SETUP = []
INSTALL = []
SCRIPT = []

if sys.platform.startswith('darwin'):
    APP = ['app.py']
    DATA_FILES = []
    OPTIONS = {'py2app': {
        'argv_emulation': True,
        'iconfile': 'icon.icns',
        'plist': {
            'CFBundleShortVersionString': '0.2.0',
            'LSUIElement': True,
        },
        'packages': ['rumps', 'requests'],
    }}
    SETUP = ['py2app']
    INSTALL =  ['rumps', 'requests']
    SCRIPT = []
elif sys.platform.startswith('linux'):
    APP = ['app.py']
    DATA_FILES = []
    OPTIONS = {
            'packages': [],
        }
    SETUP = []
    SCRIPT = ['bin/coronabar']
    

setup(
        app=APP,
        name='CoronaBar',
        data_files=DATA_FILES,
        options=OPTIONS,
        setup_requires=SETUP,
        install_requires=INSTALL,
        scripts=SCRIPT
        )

Can you share your yaml? Snapcraft itself has conditionals in our setup.py and do not experience any issues…

Are you using a requirements.txt file?

It seems the problem was OPTIONS, once I removed it from the linux part it now works.

1 Like