Question

I'm working on a package that requires sh. This package is not supported on Windows. For Windows, I use the old package sh was forked from, pbs, and rename it to sh in my namespace.

How can I create a setup.py that will properly install pbs on Windows and sh on other platforms?

EDIT: After some research, it turns out my question was specific to the new wheel format as my answer reflects. I'll ask a different question in the future if I can't figure out how wheels are supposed to work.

Was it helpful?

Solution 2

Ok, it turns out my original solution was correct:

# setup.py
...
setup(
...

    install_requires=["pbs" if os.name == 'nt' else "sh"]
...
)

The reason this recently broke was due to releasing in the new wheel format. My understanding is that this new format does not ship a setup.py with your package and handles dependencies using some other means.

Until I understand how to ship a wheel with conditional dependencies, I just won't produce wheels for this project.

OTHER TIPS

Yes! Just put your code in a conditional block on the sys.platform variable such as:

import sys
if (sys.platform=='win32'):
    import somewindowsmodule
elif (sys.platform=='macOSX'):
    import somemacmodule
elif (sys.platform=='linux'):
    import somelinuxmodule

I'm not sure what the platform strings are for mac or linux, but you can figure that out, I'm sure. Also, the somemodule names are all fictitious to protect the innocent. :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top