Is there a way to have a conditional requirements.txt file for my Python application based on platform?

前端 未结 4 1581
陌清茗
陌清茗 2020-12-02 15:06

I have a python application that I wrote to be compatible with both, Linux and Windows platforms. However there is one problem... One of the python packages I need for Windo

4条回答
  •  攒了一身酷
    2020-12-02 16:03

    You can add certain conditional requirements after a semi-colon particularly useful for sys_platform and python_version.

    Examples:

    atomac==1.1.0; sys_platform == 'darwin'
    futures>=3.0.5; python_version < '3.0'
    futures>=3.0.5; python_version == '2.6' or python_version=='2.7'
    

    Apparently you can also exclude particular versions of a library:

    futures>=3.0,!=3.0.5
    

    They are defined in PEP 508 and PEP 0345 (Environment Markers) but the syntax appears to follow the draft PEP 0496.

提交回复
热议问题