Can you set conditional dependencies for Python 2 and 3 in setuptools?

前端 未结 3 1915
醉梦人生
醉梦人生 2021-02-04 01:18

When releasing a Python egg with support for both Python 2 and 3, can you specify dependencies that change depending on which version you\'re using? For example, if you use

3条回答
  •  生来不讨喜
    2021-02-04 01:49

    The setup.py portion of the answer by @Harold did not work for me: pip install distribution.whl still installs the dependency that the if code says it shouldn't. I will further update this answer in a few days when I have this issue resolved.

    Here are some links that may provide additional ways to deal with this ():

    • Wheel docs section explaining conditional dependencies: not completely clear but gives a hint of what to do
    • Example on github
    • Blog post

提交回复
热议问题