-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path03-requirements.py
43 lines (31 loc) · 1.49 KB
/
03-requirements.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"""How to use Python dependencies with rx.
This script imports two packages: absl and art. If you take a look at
requirements.txt in this repository, you'll see that it defines `absl-py`
(which makes "absl" available), but not the `art` package.
Try running this script with rx:
$ rx python 03-requirements.py 'more cowbell'
This will print a ModuleNotFoundError, because `art` isn't found.
rx uses your requirements.txt to figure out which packages to install on the
remote machine. Thus, to install the `art` package remotely, open up
requirements.txt (locally) and add a line:
art==5.8
Then save requirements.txt and go back to the command line. Try running this
script again and now rx has all of the packages it needs:
$ rx python 03-requirements.py 'more cowbell'
_ _ _
_ __ ___ ___ _ __ ___ ___ ___ __ __| |__ ___ | || |
| '_ ` _ \ / _ \ | '__| / _ \ / __| / _ \ \ \ /\ / /| '_ \ / _ \| || |
| | | | | || (_) || | | __/ | (__ | (_) | \ V V / | |_) || __/| || |
|_| |_| |_| \___/ |_| \___| \___| \___/ \_/\_/ |_.__/ \___||_||_|
Note that you did not even need to install the package locally: rx took care of
installing packages based on the contents of requirements.txt.
"""
from absl import app
import art
def main(argv):
if len(argv) < 2:
print('You must pass in a string to print.')
return
art.tprint(' '.join(argv[1:]))
if __name__ == '__main__':
app.run(main)