PDM may run single-file scripts. Python’s PEP 723 added a function referred to as “inline script metadata,” the place Python recordsdata that begin with a specifically formatted remark block can describe dependencies and different necessities a la pyproject.toml
. If you name pdm run
to run a Python file that has this sort of knowledge, PDM will create a brief digital setting to include the wanted dependencies.
Utilizing __pypackages__ with PDM
PDM was initially created to make the most of a function described in PEP 582, which has since been rejected. This concept was to permit a challenge to include a listing, __pypackages__
, the place packages could possibly be bundled as dependencies for a challenge with out utilizing a digital setting. In different phrases, the packages could possibly be saved straight within the challenge’s supply tree, however in a approach that didn’t intervene with its listing construction. Such packages wouldn’t must be put in into the challenge’s venv as a part of its setup course of.
PEP 582 was not accepted for Python usually, however PDM-managed tasks can use the __pypackages__
listing on a per-project or world foundation. A very good use case for this may be should you wished to vendor custom-modified packages right into a challenge. On the entire, although, PDM recommends utilizing venvs, as they’re the extra broadly supported resolution for isolating challenge necessities.