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