Pypi

Pages 43-45 of the Bitsmasher Lab Operations Manual (62 pages)

Internal PyPI Repository

The lab runs an internal PyPI package repository to provide Python packages to development machines without depending on external PyPI servers. This avoids network bottlenecks, supports offline development, and enables use of proprietary or lab-specific packages not available on PyPI.org.

Architecture

The PyPI directory lives at /mnt/storage1/LAB/pypi}. A symlink is created from the web server's document root (/var/www/html/pypi}) pointing to this directory, making packages accessible via HTTP.

Access URL pattern:

\begin{lstlisting}[style=mystyle]

http://<storage-host>/pypi/simple/

    \end{lstlisting}

This follows the P45 503 simple repository API structure expected by pip.

Configuration via Ansible

The pypi\_internal} role in the lab/franklin collection automates this setup:

Usage from Client Machines

Configure pip to use the internal PyPI server:

\begin{lstlisting}[style=mystyle]

# In ~/.pip/pip.conf or /etc/pip.conf:

[global]

index-url = http://<storage-host>/pypi/simple/

# Optionally trust host if not using HTTPS

trusted-host = <storage-host>

    \end{lstlisting}

Or use pip's \-\-index\-url} flag directly:

\begin{lstlisting}[style=mystyle]

pip install --index-url http://<storage-host>/pypi/simple/ some-package

    \end{lstlisting}

Package Maintenance

To add packages to the internal PyPI, place them in the pypi directory with P45 503-compliant directory structure:

Packages can be built and added using standard pip tools:

\begin{lstlisting}[style=mystyle]

pip install --no-index --find-links=/mnt/storage1/LAB/pypi/simple/ <package>

    \end{lstlisting}