pypicache: Generate and maintain easy_install compatible package index

Copyright: Copyright (c) 2007 Robin Bryce
License:MIT
Name:pypicache
Project-Label:pypicache
Version: 0.2
Author: Robin Bryce
Author-email:robinbryce@gmail.com
Description:Generate and maintain an easy_install compatible package index.
Classifiers:Programming Language :: Python

Abstract

The main script provides a relatively painless way to convert a single directory of python packages into an easy_install compatible package archive. A typical use would be to expose the contents of your PYTHON_EGG_CACHE directory, or your zc.buildout download_cache, to other people or computers on your local area network.

Contents

pypicache: roll your own python package index

The main script provides a relatively painless way to convert a single directory of python packages into an easy_install compatible package archive. A typical use would be to expose the contents of your PYTHON_EGG_CACHE directory, or your zc.buildout download_cache, to other people or computers on your local area network.

The tool does the following:

There is limited - simple %()s - string template support for the index and project page generation.

See indexpackages-man

NOTICE:

Usage: indexpackages.py [-T title][-U url] [--enable-htaccess] [OPTIONS] archive/dir

Build a python package index based on the egg files in the directory specified by the archive/dir argument. This argument specifies the file system root directory in which the distributions are stored and where the index will be built.

Options-Summary:

Don't write anything to disk: --dry-run, -N

Page generation:

--index-url --index-pagename --downloads-path
--master-template --project-template

Logging (use -N --log-content=INFO to preview generated config files):

--log-level --log-content

Config filename control:

--project-uri-remap
Options:
-h, --help show this help message and exit
--log-level=LOG_LEVEL
 [default:INFO] Sets the logging level for messages issued by this package. It can be a number, or any one of the standard logging level strings "CRITICAL ERROR WARNING INFO DEBUG NOTSET". The level strings correspond, respectively, to the numbers [50, 40, 30, 20, 10, 0]. NOTE: Set this options to 50 for most quiet or 10 for most verbose. Note that NOTSET will cause the logging level to be taken from the first parent handler that does set a level - usualy this will be the root logger
--log-content=LOG_CONTENT
 [default:DEBUG] Sets the logging level at which the content of generated pages and files will be logged. Valid values are exactly as per the --log-level option, except that value of NOTSET or 0 will have no effect
--log-config=LOG_CONFIG
 [default:DEBUG] Exactly as per --log-content. But applies, exclusively, to content that represents site/host configuration necessary for the full functionality of the index. (apache, etc)
--print-log-conf
 [default:False] Set this flag to print out information reflecting the application of the --log options. Use if you are not seeing the messages you expect.
-T INDEX_TITLE, --index-title=INDEX_TITLE
 [default:generated via gethostname] The title of the package index. This will be used as the <title>CONTENT</title> for the master index page. By default this option value is generated using gethostname like this 'cheeseboard.%s' % gethostname()
-U INDEX_URL, --index-url=INDEX_URL
 [default:generated via gethostname] The public url of the package index main page. By default this option value is generated using gethostname like this 'http://cheeseboard.%s/' % gethostname(). The supplied url must end with / (trailing slash).
--downloads-path=DOWNLOADS_PATH
 [default:] Generate download uris with a path that is distinct from the project-path implied by the --index-url option. If a non empty download-path is supplied then it is joined to the path component of the index-url. For a definition of path component see uriparse
--index-pagename=INDEX_PAGENAME
 [default:index.html] Sets the name of the master index page.
--project-uri-remap=PROJECT_URI_REMAP
 [default:project-index.txt] Sets the name of the mod_rewrite RewriteMap compatible text file that will contain the necessary safe_name re-mappings from project uris to the appropriate project page for the version implied in the uri. If there is no version information in the uri then the remap directs to the BEST VERSION as defined by setuptools semantics for version string interpretation.
--master-template=MASTER_TEMPLATE
 [default:] Use this option to set the file from which the master index page template will be read. If a relative path is provided it must be relative to --index-root. The file should be a plain text file providing standard %(key)s substitutions for the following keys: index_title, PACKAGE_INDEX_URLS. Note that the keys indicated in this help text may be incorrect if you are running a version of this program that customise the replacement keys. The template file is checked for the presence of the actual keys needed at runtime by the class that generates the page.
--project-template=PROJECT_TEMPLATE
 [default:] Use this option to set the file from which the project-version page template will be read. If a relative path is provided it must be relative to --index-root. The file should be a plain text file providing standard %(key)s substitutions for the following keys: index_name, project_name, latest_version, DOWNLOAD_LINKS. Note that the keys indicated in this help text may be incorrect if you are running a version of this program that customise the replacement keys. The template file is checked for the presence of the actual keys needed at runtime by the class that generates the page.
-N, --dry-run [default:False] Set this option to prevent this program from writing anything to disc. This option can be combined with logging options to re-direct most content production to standard out.
--apache-vhost-file=APACHE_VHOST_FILE
 [default:apache2-vhost.directives.conf] The name of the file to which all server/host level directives are written. These represent the minimum necessary server/host level directives needed in order for the index to work. NOTE: If the path is relative then it is relative to the directory specified as the index/root by the first non option argument.
--apache-dirdirect-file=APACHE_DIRDIRECT_FILE
 [default:apache2-dir.directives.conf] The name of the file to which all <Directory> context directives are written. These represent the minimum necessary </Directory> directives required in order for the index to work. NOTE This program always generates both a directory context config and the equivelent .haccess file. If .htaccess support is enabled (--enable-htaccess) then directives that duplicate the .htaccess functionality are commented out. To disable .htaccess at any time, simply make the usual arrangements at the server config level and uncomment the directory context directives.
--htaccess-file=HTACCESS_FILE
 [default:.htaccess] The name of the file to which the .htaccess configuration directives are written. If --enable-htaccess is NOT also specified then the given file name will be decorated with the prefix NOTENABLED.
--enable-htaccess
 [default:False] Set this flag to make .htaccess on by default. This script allways generates configuration directives appropriate for use with or without htaccess support enabled. If htaccess support is disabled (this is the default) then all server/host and <Directory> directives pertaining to htaccess support are commented out and the generated htaccess file is prefixed with NOTENABLED.

Changes

2007-04-21 Robin Bryce robinbryce@gmail.com

  • Support fully automated generation of indexes hosted under non root uris. see tickets/#6,#7
  • All distribution formats supported by setuptools can be indexed. See ticket/#5
  • Provide explicit control over the generated apache config filenames. See ticket/#9
  • Explicit options to enable/disable .htaccess support in the generated apache configuration. Set ticket/#10

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.