You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/deployments/python-packages.md
+60Lines changed: 60 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,66 @@ You can install your required PyPI packages and import them in your Python files
16
16
17
17
Note that some packages are pre-installed by default (see "pre-installed packages" for your Predictor type in the [Predictor documentation](predictors.md)).
18
18
19
+
## `setup.py`
20
+
21
+
It is also possible to reference Python libraries that are packaged using `setup.py`.
22
+
23
+
Here is an example directory structure:
24
+
25
+
```text
26
+
./iris-classifier/
27
+
├── cortex.yaml
28
+
├── predictor.py
29
+
├── ...
30
+
├── mypkg
31
+
│ └── __init__.py
32
+
├── requirements.txt
33
+
└── setup.py
34
+
```
35
+
36
+
In this case, `requirements.txt` can include a single `.`:
37
+
38
+
```python
39
+
# requirements.txt
40
+
41
+
.
42
+
```
43
+
44
+
If this is the contents `setup.py`:
45
+
46
+
```python
47
+
# setup.py
48
+
49
+
from distutils.core import setup
50
+
51
+
setup(
52
+
name="mypkg",
53
+
version="0.0.1",
54
+
packages=["mypkg"],
55
+
)
56
+
```
57
+
58
+
And `__init__.py` looks like this:
59
+
60
+
```python
61
+
# mypkg/__init__.py
62
+
63
+
defhello():
64
+
print("hello")
65
+
```
66
+
67
+
You can reference your package in `predictor.py`:
68
+
69
+
```python
70
+
# predictor.py
71
+
72
+
import mypkg
73
+
74
+
classPythonPredictor:
75
+
defpredict(self, payload):
76
+
mypkg.hello()
77
+
```
78
+
19
79
## Private packages on GitHub
20
80
21
81
You can also install private packages hosed on GitHub by adding them to `requirements.txt` using this syntax:
0 commit comments