Skip to content

Add docs about private PyPI indexes #1072

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 34 additions & 17 deletions docs/deployments/python-packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,28 @@ You can install your required PyPI packages and import them in your Python files
└── requirements.txt
```

If you want to use `conda` to install your python packages, see the [Conda section](#conda) below.
If you want to use `conda` to install your python packages, see the [Conda section](#conda-packages) below.

Note that some packages are pre-installed by default (see "pre-installed packages" for your Predictor type in the [Predictor documentation](predictors.md)).

## Installing with Setup
## Private PyPI packages

Python packages can also be installed by providing a `setup.py` that describes your project's modules. Here's an example directory structure:
To install packages from a private PyPI index, create a `pip.conf` inside the same directory as `requirements.txt`, and add the following contents:

```text
./iris-classifier/
├── cortex.yaml
├── predictor.py
├── ...
├── mypkg
│ └── __init__.py
├── requirements.txt
└── setup.py
[global]
extra-index-url = https://<username>:<password>@<my-private-index>.com/pip
```

In this case, `requirements.txt` will have this form:
```text
# requirements.txt
In same directory, create a [`dependencies.sh` script](system-packages.md#bash-script) and add the following contents:

.
```bash
cp pip.conf /etc/pip.conf
```

## Installing from GitHub
You may now add packages to `requirements.txt` which are found in the private index.

## GitHub packages

You can also install public/private packages from git registries (such as GitHub) by adding them to `requirements.txt`. Here's an example for GitHub:

Expand All @@ -56,7 +51,29 @@ git+https://<personal access token>@github.com/<username>/<repo name>.git@<tag o

On GitHub, you can generate a personal access token by following [these steps](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line).

## Conda
## Installing with Setup

Python packages can also be installed by providing a `setup.py` that describes your project's modules. Here's an example directory structure:

```text
./iris-classifier/
├── cortex.yaml
├── predictor.py
├── ...
├── mypkg
│ └── __init__.py
├── requirements.txt
└── setup.py
```

In this case, `requirements.txt` will have this form:
```text
# requirements.txt

.
```

## Conda packages

Cortex supports installing Conda packages. We recommend only using Conda when your required packages are not available in PyPI. Cortex looks for a `conda-packages.txt` file in the top level Cortex project directory (i.e. the directory which contains `cortex.yaml`):

Expand Down
3 changes: 1 addition & 2 deletions docs/deployments/system-packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ Cortex looks for a file named `dependencies.sh` in the top level Cortex project
└── dependencies.sh
```

`dependencies.sh` is executed during the initialization of each replica (before installing Python packages in `requirements.txt` or `conda-packages.txt`). Typical use cases include installing required system packages to be used in your Predictor, building Python packages from source, etc.
`dependencies.sh` is executed with `bash` shell during the initialization of each replica (before installing Python packages in `requirements.txt` or `conda-packages.txt`). Typical use cases include installing required system packages to be used in your Predictor, building Python packages from source, etc.

Here is an example `dependencies.sh`, which installs the `tree` utility:

```bash
#!/bin/bash
apt-get update && apt-get install -y tree
```

Expand Down