HomeCloud ComputingPDM: A wiser approach to handle Python packages

PDM: A wiser approach to handle Python packages



PDM may also run single-file scripts. Python’s PEP 723 added a function known as “inline script metadata,” the place Python information that begin with a specifically formatted remark block can describe dependencies and different necessities a la pyproject.toml. Whenever you name pdm run to run a Python file that has this sort of knowledge, PDM will create a brief digital atmosphere 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 mission to include a listing, __pypackages__, the place packages could possibly be bundled as dependencies for a mission with out utilizing a digital atmosphere. In different phrases, the packages could possibly be saved straight within the mission’s supply tree, however in a method that didn’t intervene with its listing construction. Such packages wouldn’t must be put in into the mission’s venv as a part of its setup course of.

PEP 582 was not authorized for Python typically, however PDM-managed initiatives can use the __pypackages__ listing on a per-project or world foundation. A great use case for this might be in case you wished to vendor custom-modified packages right into a mission. On the entire, although, PDM recommends utilizing venvs, as they’re the extra broadly supported resolution for isolating mission necessities.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments