Comcast.pypi

comcast.pypi

A role for setting up a basic PyPI server.

Role Variables

  • pypi_server_version: The version of the pypiserver to install. Default: 1.2.0.
  • pypi_user: The user that will run the pypi-server service. It will be created if it doesn't exist. Default: pypi.
  • pypi_group: The group that the pypi_user belongs to. Default: pypi.
  • pypi_server_port: The port where the pypi-server will listen. Default: 7974.
  • pypi_home_dir: The home directory for the pypi user. Default: /srv/pypi.
  • pypi_work_dir: The workspace directory for the pypi-server. Default: {{ pypi_home_dir }}.
  • pypi_packages_directory: The directory to store uploaded Python packages. Default: {{ pypi_work_dir }}/packages.
  • pypi_log_file: The log file for the pypi-server. Default: {{ pypi_work_dir }}/pypi-server.log.
  • pypi_init_script_dir: The directory for the pypi-server initialization script (sys-v only). Default: /etc/init.d.
  • pypi_server_pid_file: The location of the PID file. Default: {{ pypi_work_dir }}/pypi.pid.
  • pypi_requirements_template: The template listing required packages for the pypi-server. Default: templates/pypi-server-requirements.txt.j2.
  • pypi_server_authenticate: A comma-separated list of actions needed to authenticate a client, e.g., download,list,update. Default: update.
  • htaccess_dir: The location of the generated .htaccess file. Default: {{ pypi_home_dir }}.
  • enable_anonymous_auth: A boolean value that determines if username/password authentication is needed for uploads. Enabling this is not recommended as it allows anyone to upload packages. Default: false.
  • htaccess_username: The username for authenticating with the pypi-server (only for enable_anonymous_auth = false). Default: test.
  • htaccess_password: The password for authenticating with the pypi-server (only for enable_anonymous_auth = false). Default: test.

Dependencies

None required.

Example Playbook

Here's how to use your role:

    - hosts: servers
      roles:
         - role: comcast.pypi

Testing

To test this role, you need the following tools:

  1. Virtualbox
  2. Vagrant
  3. Python 2.7
  4. virtualenv

Create Test Environment

virtualenv --python=$(which python2.7) .venv
source .venv/bin/activate
pip install -r test-reqs.txt

Run Tests

molecule test

Test against Specific Platform

molecule test --platform centos/7
molecule test --platform debian/jessie64

Test Uploads

You can use any Python package to test uploads. We'll use BeautifulSoup4 as an example.

  1. Start the local pypi server:
molecule converge

This will run the pypi-server on http://localhost:8080 with no packages stored.

  1. Clone the BeautifulSoup4 source repository:
git clone https://github.com/getanewsletter/BeautifulSoup4.git
  1. Create/modify the .pypirc file in your home directory to include the htaccess_username and htaccess_password if authentication is used.

Your .pypirc should look like this:

Note: If using the default values in the playbook for htaccess_username and htaccess_password, those should match what's in playbook.yml.

[distutils]
index-servers =
  local

[local]
repository: http://localhost:8080
username: <htaccess_username>
password: <htaccess_password>
  1. Upload the Python package:

From the Python source directory, run:

python setup.py sdist upload -r local

This will upload the package to the pypi-server specified in the .pypirc file using the credentials from the [local] section.

Test Download

After uploading a package, you can test downloading it. For example, to download BeautifulSoup4:

Change version_number to the version you uploaded.

pip install --extra-index-url http://localhost:8080/ beautifulsoup4==<version_number>

License

Apache 2.0

Author Information

Informazioni sul progetto

A role to run a minimal pypi-server

Installa
ansible-galaxy install Comcast.pypi
Licenza
apache-2.0
Download
15.6k
Proprietario
Comcast brings together the best in media and technology to create the world's best entertainment and online experiences