Skip to content

Add setup.py documentation #868

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 1 commit into from
Mar 13, 2020
Merged
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
60 changes: 60 additions & 0 deletions docs/deployments/python-packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,66 @@ You can install your required PyPI packages and import them in your Python files

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

## `setup.py`

It is also possible to reference Python libraries that are packaged using `setup.py`.

Here is an example directory structure:

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

In this case, `requirements.txt` can include a single `.`:

```python
# requirements.txt

.
```

If this is the contents `setup.py`:

```python
# setup.py

from distutils.core import setup

setup(
name="mypkg",
version="0.0.1",
packages=["mypkg"],
)
```

And `__init__.py` looks like this:

```python
# mypkg/__init__.py

def hello():
print("hello")
```

You can reference your package in `predictor.py`:

```python
# predictor.py

import mypkg

class PythonPredictor:
def predict(self, payload):
mypkg.hello()
```

## Private packages on GitHub

You can also install private packages hosed on GitHub by adding them to `requirements.txt` using this syntax:
Expand Down