Skip to content

Commit

Permalink
DOCS-1051: Add guidance on requirements.txt (#1712)
Browse files Browse the repository at this point in the history
  • Loading branch information
andf-viam authored Sep 5, 2023
1 parent e4017ee commit 3915280
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
13 changes: 11 additions & 2 deletions docs/extend/modular-resources/create/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -502,9 +502,18 @@ Your options for completing this step are flexible, as this file does not need t
One option is to create and save a new shell script (<file>.sh</file>) that runs your module at your entry point (main program) file.

Make sure that you set up a Python virtual environment in the directory your module is in to compile your resource properly at execution.
See the [Python Documentation](https://docs.python-guide.org/dev/virtualenvs/) for help with this.
See the [Python virtual environment documentation](https://docs.python-guide.org/dev/virtualenvs/) for more information.

Include `venv` set-up and manage dependencies in your script as in the following template:
You will also need to create a `requirements.txt` file containing a list of all the dependencies your module relies on.
For example, a `requirements.txt` file with the following contents ensures that the Viam Python SDK (`viam-sdk`) is installed. You may also add additional dependencies as needed:

``` sh {id="terminal-prompt" class="command-line" data-prompt="$"}
viam-sdk
```

See the [pip `requirements.txt` file documentation](https://pip.pypa.io/en/stable/reference/requirements-file-format/) for more information.

The following template sets up a new virtual enviroment (`venv`), installs the dependencies listed in `requirements.txt`, and runs the module entry point file `main.py`:

``` sh {id="terminal-prompt" class="command-line" data-prompt="$"}
#!/bin/sh
Expand Down
4 changes: 2 additions & 2 deletions docs/extend/modular-resources/upload/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ To upload your custom module to the Viam Registry, either as a public or private
tar -czf module.tar.gz run.sh requirements.txt src
```
Where `run.sh` is your [entrypoint file](/extend/modular-resources/create/#compile-the-module-into-an-executable), `requirements.txt` is your Python dependency list, and `src` is the source directory of your module.
Where `run.sh` is your [entrypoint file](/extend/modular-resources/create/#compile-the-module-into-an-executable), `requirements.txt` is your [pip dependency list file](/extend/modular-resources/create/#compile-the-module-into-an-executable), and `src` is the source directory of your module.
1. Run `viam module upload` to upload the updated custom module to the Viam Registry:
Expand Down Expand Up @@ -214,7 +214,7 @@ You can also use the [Viam CLI](/manage/cli/) to update an existing custom modul
tar -czf module.tar.gz run.sh requirements.txt src
```
Where `run.sh` is your [entrypoint file](/extend/modular-resources/create/#compile-the-module-into-an-executable), `requirements.txt` is your Python dependency list, and `src` is the source directory of your module.
Where `run.sh` is your [entrypoint file](/extend/modular-resources/create/#compile-the-module-into-an-executable), `requirements.txt` is your [pip dependency list file](/extend/modular-resources/create/#compile-the-module-into-an-executable), and `src` is the source directory of your module.
1. Run `viam module upload` to upload the updated custom module to the Viam Registry:
Expand Down

0 comments on commit 3915280

Please sign in to comment.