How can you add a dependency that is only used for a specific platform (e.g., Windows)?

Python interview question for Advanced practice.

Answer

Use the 'markers' property in the dependency specification (e.g., { version = "...", markers = "sysplatform == 'win32'" }).

Explanation

Poetry supports environment markers as defined in PEP 508, allowing dependencies to be conditionally installed based on the operating system or Python version.

Related Questions