Skip to main content

Private package management tool for Python projects

Project description

pypiprivate is a command line tool for hosting a private PyPI-like package index or in other words, a manual python repository backed by a file based storage.

It’s implemented in a way that the storage backends are pluggable. At present, only AWS S3 and local file system are supported but more implementations can be added in future.

The backend can be protected behind a HTTP reverse proxy (eg. Nginx) to allow secure private access to the packages.

How it works?

Update: We have published a blog post that explains the usage, approach and rationale in detail - Private Python Package Index with Zero Hassle.

At present pypiprivate comes with only one command to publish a package (more utilities for package search and discoverability are coming soon).

A publish operation involves,

  1. Copying all the available package artifacts for a specific version under the ./dist directory to the storage backend

  2. Creating the index on the same storage backend

The file structure created on the backend conforms to the “Simple Repository API” specification defined in PEP 503.

The files can now be served securely by a webserver eg. by setting up a Nginx reverse proxy.

It’s important to note that although the name of the project is pypiprivate, it’s upto you to ensure that the access to both, the storage and the index is really private. If you are using S3 and Nginx, for example, then

  • package authors/owners will need read-write S3 creds to publish packages

  • nginx will authenticate with S3 using read-only S3 creds and protect the files via HTTP Basic authentication

  • package users will need HTTP Auth creds to install the packages using pip

Installation

pypi-private can be installed using pip as follows,

$ pip install pypiprivate

This will install pypiprivate with the additional dependency of boto3 for AWS S3 (compatible) backend.

In last master (to be released), Azure backend is also supported. If you wish to use that then for now you’ll need to additionally install the azure-storage-blob package

$ pip install azure-storage-blob==12.2.0

After installation, a script pypi-private which will be available at PATH.

You may choose to install it in a virtualenv, but it’s recommended to install it globally for all users (using sudo) so that it’s less confusing to build and publish projects that need to use their own virtualenvs.

Configuration

pypiprivate requires it’s own config file, the default location for which is ~/.pypi-private.cfg. This repo contains the example config file example.pypi-private.cfg, which can be simply copied to the home directory and renamed to .pypi-private.cfg.

The config file is NOT meant for specifying the auth credentials. Instead, they should be set as environment variables. This to ensure that creds are not stored in plain text.

Which env vars are to be set depends on the backend. More documentation about it can be found in the example config file.

AWS S3

For S3 there are 2 ways to specify the credentials

  1. Setting PP_S3_* env vars explicitly

    • PP_S3_ACCESS_KEY: required

    • PP_S3_SECRET_KEY: required

    • PP_S3_SESSION_TOKEN: optional

  2. Configuration methods supported by Boto3

    Since version: to be released

    This method is implicit but more convenient if you already use tools such as AWS-CLI. It’d also allow you to use profiles. However, note that only credentials will be picked up for the configured profile. The region and endpoint (if required) need to explicitly configured in the ~/.pypi-private.cfg file.

AZURE

Since version: to be released

  • PP_AZURE_CONN_STR: (required) Connection string of the storage account

Usage

First create the builds,

$ python setup.py sdist bdist_wheel

Then to publish the built artifacts run,

$ pypi-private -v publish <pkg-name> <pkg-version>

For other options, run

$ pypi-private -h

Fetching packages published using pypiprivate

Run pip with the --extra-index-url option,

$ pip install mypackage --extra-index-url=https://<user>:<password>@my.private.pypi.com/simple

Or, add the extra-index-url to pip config file at ~/.pip/pip.conf as follows

[install]
extra-index-url = https://<user>:<password>@my.private.pypi.com/simple

And then simply run,

$ pip install mypackage

License

MIT (See LICENSE)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pypiprivate-0.5.0.tar.gz (11.0 kB view details)

Uploaded Source

Built Distributions

pypiprivate-0.5.0-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

pypiprivate-0.5.0-py2-none-any.whl (12.4 kB view details)

Uploaded Python 2

File details

Details for the file pypiprivate-0.5.0.tar.gz.

File metadata

  • Download URL: pypiprivate-0.5.0.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/38.5.1 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.6.4

File hashes

Hashes for pypiprivate-0.5.0.tar.gz
Algorithm Hash digest
SHA256 ee626676313669c8a3e53085f178f7cc46a153100409ca8d3696b27a9663f66f
MD5 5f453463b9a385a8cc66adb69ba63743
BLAKE2b-256 9ca426471e35dae92995726ace51e4bcb35f7de108a7ba8a98261000a6347f2e

See more details on using hashes here.

File details

Details for the file pypiprivate-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: pypiprivate-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/38.5.1 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.6.4

File hashes

Hashes for pypiprivate-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7b58bc9cc88c302063eab7353731102d47a0d0ae11565058eaa0ae4625584c86
MD5 acc5fa9fd331da6f0888576511ff33fd
BLAKE2b-256 f7f9a013e0ef1c7c0f26645093ee6e0ce1674b29d784577fd611641c687d680d

See more details on using hashes here.

File details

Details for the file pypiprivate-0.5.0-py2-none-any.whl.

File metadata

  • Download URL: pypiprivate-0.5.0-py2-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/38.5.1 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.6.4

File hashes

Hashes for pypiprivate-0.5.0-py2-none-any.whl
Algorithm Hash digest
SHA256 8ec33115641186689ce01cd027b21a642a2ba22104e40c0f0e6d59774dd476ec
MD5 eb7036690b4c8c8e9b5c2a343c43ed2b
BLAKE2b-256 5217d7b394d47b9f84f8e177cade5170537e622b2f707ca1b4acdaeae6e2578e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page