3

My requirements.txt has got dataclasses in it, to backport for python 3.6

However, some build machines and coworkers use python 3.7, which fails when it attempts to install this module.

Is there a way to make dataclasses only installed if it is necessary?

Daniel Paczuski Bak
  • 3,720
  • 8
  • 32
  • 78
  • There's nothing wrong with supporting multiple versions of Python and having different dependencies for each, but: "However, some build machines and coworkers use python 3.7"—why wouldn't your build machines and development machines all be using the same version of Python? – ChrisGPT was on strike Mar 03 '20 at 23:49

1 Answers1

5

You can use Environmental Markers

dataclasses; python_version < '3.7'

Reference: https://www.python.org/dev/peps/pep-0345/#environment-markers

Gabriel Cappelli
  • 3,632
  • 1
  • 17
  • 31