The easiest way is to use poetry to manage your dependencies and add mathlib to them.
[tool.poetry.dependencies] mathlib = "^0.5.0"