
PDM may run single-file scripts. Python’s PEP 723 added a characteristic 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 any such information, PDM will create a brief digital atmosphere to include the wanted dependencies.
Utilizing __pypackages__ with PDM
PDM was initially created to reap the benefits of a characteristic described in PEP 582, which has since been rejected. This concept was to permit a venture to include a listing, __pypackages__, the place packages might be bundled as dependencies for a venture with out utilizing a digital atmosphere. In different phrases, the packages might be saved straight within the venture’s supply tree, however in a method that didn’t intervene with its listing construction. Such packages wouldn’t should be put in into the venture’s venv as a part of its setup course of.
PEP 582 was not accredited for Python usually, however PDM-managed tasks can use the __pypackages__ listing on a per-project or world foundation. A great use case for this could be when you wished to vendor custom-modified packages right into a venture. On the entire, although, PDM recommends utilizing venvs, as they’re the extra broadly supported resolution for isolating venture necessities.
