13 C
Canberra
Wednesday, October 22, 2025

PDM: A better strategy to handle Python packages



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.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

[td_block_social_counter facebook="tagdiv" twitter="tagdivofficial" youtube="tagdiv" style="style8 td-social-boxed td-social-font-icons" tdc_css="eyJhbGwiOnsibWFyZ2luLWJvdHRvbSI6IjM4IiwiZGlzcGxheSI6IiJ9LCJwb3J0cmFpdCI6eyJtYXJnaW4tYm90dG9tIjoiMzAiLCJkaXNwbGF5IjoiIn0sInBvcnRyYWl0X21heF93aWR0aCI6MTAxOCwicG9ydHJhaXRfbWluX3dpZHRoIjo3Njh9" custom_title="Stay Connected" block_template_id="td_block_template_8" f_header_font_family="712" f_header_font_transform="uppercase" f_header_font_weight="500" f_header_font_size="17" border_color="#dd3333"]
- Advertisement -spot_img

Latest Articles