pypi_redirect

nawkboy edited this page Oct 14, 2014 · 3 revisions

Artifactory Now Supports PyPI

Artifactory recently added support for PyPI repositories. http://www.jfrog.com/confluence/display/RTF/PyPI+Repositories

Many of the continuous delivery challenges in Python build tooling probably still exist. PyPI Redirect might still be useful if working with the open source version of Artifactory. It may also be relevant if trying to leverage another repository manager such as Nexus.

PyPI Redirect

The "pypi_redirect" package makes it possible for Artifactory to treat pypi.python.org as a remote repository. It has only been tested on Windows.

Installation

  1. This package requires some binary dependencies which are not easily installed via pip:

    • The first is pywin32; download and install the latest build from here. This is required so that the package can be installed as a Windows service.

    • The second is lxml, which can be installed via easy_install:

        > easy_install lxml
      
  2. Now that the binary dependencies are taken care of, install pypi_redirect via pip:

     > pip install pypi_redirect
    

Configuration

The configuration and logs are stored in the pypi_redirect directory in the Python home directory (e.g., C:\Python27\pypi_redirect\). If a virtualenv is used, this directory will be at the root of the virtualenv.

The initial layout looks like this:

PYTHONHOME/
    pypi_redirect/
        config/
            pypi_redirect.conf.template

The above configuration template is provided upon installation. When pypi_redirect runs, it will be looking for pypi_redirect.conf in this same directory. If this config file does not exist, it will be created from the template automatically.

Run

There are two ways to run pypi_redirect: as a script, or as a Windows service.

  1. As a script (in the foreground):

     > python -m pypi_redirect
    
  2. As a Windows service (in the background):

     > pypi_redirect_service install
     > pypi_redirect_service start
    

    The pypi_redirect_service script is installed into the Python scripts directory. For example, a typical Python 2.7 installation on Windows would place it at "C:\Python27\Scripts".

    When run as a service, it will record access and error logs to a location specified in the configuration file. Logs are also rotated according to the configuration file.

    Unless the location is changed, these logs are stored in the log subdirectory of pypi_redirect:

     PYTHONHOME/
         pypi_redirect/
             config/
                 pypi_redirect.conf.template
                 pypi_redirect.conf
             log/
                 access.log
                 error.log
    

Quick Test

See if pypi_redirect is operational by opening a web browser and navigating to http://localhost:9292/python/pypi_redirect/. You should see a list of pypi_redirect releases.

The default port is 9292; if running on a different port, enter that one into the address bar instead.

Use as a Remote Repository

Once you have installed the pypi_redirect proxy, you'll need to tell Artifactory about it. Details on how to do this can be found in the How-To page.