[Python-Dev] PEP 0365: Adding the pkg_resources module (original) (raw)

M.-A. Lemburg mal at egenix.com
Fri May 4 16:06:54 CEST 2007


On 2007-05-01 02:29, Phillip J. Eby wrote:

I wanted to get this in before the Py3K PEP deadline, since this is a Python 2.6 PEP that would presumably impact 3.x as well. Feedback welcome.

Could you add a section that explains the side effects of importing pkg_resources ?

The documentation of the module doesn't mention any, but the code suggests that you are installing (some form of) import hooks.

Some other comments:

Thanks,

Marc-Andre Lemburg eGenix.com

Professional Python Services directly from the Source (#1, May 04 2007)

Python/Zope Consulting and Support ... http://www.egenix.com/ mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/


:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::

eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611

PEP: 365 Title: Adding the pkgresources module Version: Revision:55032Revision: 55032 Revision:55032 Last-Modified: Date:2007−04−3020:24:48−0400(Mon,30Apr2007)Date: 2007-04-30 20:24:48 -0400 (Mon, 30 Apr 2007) Date:2007043020:24:480400(Mon,30Apr2007) Author: Phillip J. Eby <pje at telecommunity.com> Status: Draft Type: Standards Track Content-Type: text/x-rst Created: 30-Apr-2007 Post-History: 30-Apr-2007

Abstract ======== This PEP proposes adding an enhanced version of the pkgresources module to the standard library. pkgresources is a module used to find and manage Python package/version dependencies and access bundled files and resources, including those inside of zipped .egg files. Currently, pkgresources is only available through installing the entire setuptools distribution, but it does not depend on any other part of setuptools; in effect, it comprises the entire runtime support library for Python Eggs, and is independently useful. In addition, with one feature addition, this module could support easy bootstrap installation of several Python package management tools, including setuptools, workingenv, and zc.buildout. Proposal ======== Rather than proposing to include setuptools in the standard library, this PEP proposes only that pkgresources be added to the standard library for Python 2.6 and 3.0. pkgresources is considerably more stable than the rest of setuptools, with virtually no new features being added in the last 12 months. However, this PEP also proposes that a new feature be added to pkgresources, before being added to the stdlib. Specifically, it should be possible to do something like:: python -m pkgresources SomePackage==1.2 to request downloading and installation of SomePackage from PyPI. This feature would not be a replacement for easyinstall; instead, it would rely on SomePackage having pure-Python .egg files listed for download via the PyPI XML-RPC API, and the eggs would be placed in the $PYTHONEGGS cache, where they would not be importable by default. (And no scripts would be installed) However, if the download egg contains installation bootstrap code, it will be given a chance to run. These restrictions would allow the code to be extremely simple, yet still powerful enough to support users downloading package management tools such as setuptools, workingenv and zc.buildout, simply by supplying the tool's name on the command line. Rationale ========= Many users have requested that setuptools be included in the standard library, to save users needing to go through the awkward process of bootstrapping it. However, most of the bootstrapping complexity comes from the fact that setuptools-installed code cannot use the pkgresources runtime module unless setuptools is already installed. Thus, installing setuptools requires (in a sense) that setuptools already be installed. Other Python package management tools, such as workingenv and zc.buildout, have similar bootstrapping issues, since they both make use of setuptools, but also want to provide users with something approaching a "one-step install". The complexity of creating bootstrap utilities for these and any other such tools that arise in future, is greatly reduced if pkgresources is already present, and is also able to download pre-packaged eggs from PyPI. (It would also mean that setuptools would not need to be installed in order to simply use eggs, as opposed to building them.) Finally, in addition to providing access to eggs built via setuptools or other packaging tools, it should be noted that since Python 2.5, the distutils install package metadata (aka PKG-INFO) files that can be read by pkgresources to identify what distributions are already on sys.path. In environments where Python packages are installed using system package tools (like RPM), the pkgresources module provides an API for detecting what versions of what packages are installed, even if those packages were installed via the distutils instead of setuptools. Implementation and Documentation ================================ The pkgresources implementation is maintained in the Python SVN repository under /sandbox/trunk/setuptools/; see pkgresources.py and pkgresources.txt. Documentation for the egg format(s) supported by pkgresources can be found in doc/formats.txt. HTML versions of these documents are available at: * http://peak.telecommunity.com/DevCenter/PkgResources and * http://peak.telecommunity.com/DevCenter/EggFormats (These HTML versions are for setuptools 0.6; they may not reflect all of the changes found in the Subversion trunk's .txt versions.) Copyright ========= This document has been placed in the public domain.


Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/mal%40egenix.com



More information about the Python-Dev mailing list