Movatterモバイル変換


[0]ホーム

URL:


Following system colour schemeSelected dark colour schemeSelected light colour scheme

Python Enhancement Proposals

PEP 365 – Adding the pkg_resources module

Author:
Phillip J. Eby <pje at telecommunity.com>
Status:
Rejected
Type:
Standards Track
Topic:
Packaging
Created:
30-Apr-2007
Post-History:
30-Apr-2007

Table of Contents

Abstract

This PEP proposes adding an enhanced version of thepkg_resourcesmodule to the standard library.

pkg_resources is a module used to find and manage Pythonpackage/version dependencies and access bundled files and resources,including those inside of zipped.egg files. Currently,pkg_resources is only available through installing the entiresetuptools distribution, but it does not depend on any other partof setuptools; in effect, it comprises the entire runtime supportlibrary for Python Eggs, and is independently useful.

In addition, with one feature addition, this module could supporteasy bootstrap installation of several Python package managementtools, includingsetuptools,workingenv, andzc.buildout.

Proposal

Rather than proposing to includesetuptools in the standardlibrary, this PEP proposes only thatpkg_resources be added to thestandard library for Python 2.6 and 3.0.pkg_resources isconsiderably more stable than the rest of setuptools, with virtuallyno new features being added in the last 12 months.

However, this PEP also proposes that a new feature be added topkg_resources, before being added to the stdlib. Specifically, itshould be possible to do something like:

python-mpkg_resourcesSomePackage==1.2

to request downloading and installation ofSomePackage from PyPI.This feature wouldnot be a replacement foreasy_install;instead, it would rely onSomePackage having pure-Python.eggfiles listed for download via the PyPI XML-RPC API, and the eggs wouldbe placed in the$PYTHON_EGG_CACHE directory, where they wouldnot be importable by default. (And no scripts would be installed.)However, if the download egg contains installation bootstrap code, itwill be given a chance to run.

These restrictions would allow the code to be extremely simple, yetstill powerful enough to support users downloading package managementtools such assetuptools,workingenv andzc.buildout,simply by supplying the tool’s name on the command line.

Rationale

Many users have requested thatsetuptools be included in thestandard library, to save users needing to go through the awkwardprocess of bootstrapping it. However, most of the bootstrappingcomplexity comes from the fact that setuptools-installed code cannotuse thepkg_resources runtime module unless setuptools is alreadyinstalled. Thus, installing setuptools requires (in a sense) thatsetuptools already be installed.

Other Python package management tools, such asworkingenv andzc.buildout, have similar bootstrapping issues, since they bothmake use of setuptools, but also want to provide users with somethingapproaching a “one-step install”. The complexity of creating bootstraputilities for these and any other such tools that arise in future, isgreatly reduced ifpkg_resources is already present, and is alsoable to download pre-packaged eggs from PyPI.

(It would also mean that setuptools would not need to be installedin order to simplyuse eggs, as opposed to building them.)

Finally, in addition to providing access to eggs built via setuptoolsor other packaging tools, it should be noted that since Python 2.5,the distutils install package metadata (akaPKG-INFO) files thatcan be read bypkg_resources to identify what distributions arealready onsys.path. In environments where Python packages areinstalled using system package tools (like RPM), thepkg_resourcesmodule provides an API for detecting what versions of what packagesare installed, even if those packages were installed via the distutilsinstead of setuptools.

Implementation and Documentation

Thepkg_resources implementation is maintained in the PythonSVN repository under/sandbox/trunk/setuptools/; seepkg_resources.py andpkg_resources.txt. Documentation for theegg format(s) supported bypkg_resources can be found indoc/formats.txt. HTML versions of these documents are availableat:

(These HTML versions are for setuptools 0.6; they may not reflect allof the changes found in the Subversion trunk’s.txt versions.)

Copyright

This document has been placed in the public domain.


Source:https://github.com/python/peps/blob/main/peps/pep-0365.rst

Last modified:2025-02-01 08:59:27 GMT


[8]ページ先頭

©2009-2025 Movatter.jp