提交 2c025ef3 编写于 作者: C changsh726 提交者: Liu Jiaming

Docs: update cyber/python/README.md

上级 09d8a674
......@@ -2,13 +2,12 @@
## Usage
Make sure you have built Apollo successfully, which should also have added
`/apollo/cyber/python` to the PYTHONPATH for you. Then in Python code:
Make sure you have built Apollo successfully. Then in Python code:
```python3
import sys
from cyber_py3 import cyber
from cyber.python.cyber_py3 import cyber
cyber.init()
......@@ -24,3 +23,6 @@ cyber.shutdown()
Learn more usage from the [examples](cyber_py3/examples/) and
[tests](cyber_py3/test/).
**Note:** Like C++ files, Python files are also managed by Bazel since Apollo 6.0. You can take
[how_to_build_and_run_python_app.md](../../docs/howto/how_to_build_and_run_python_app.md)
as reference.
# How to Build and Run(Test) your Python Application
# How to Build, Test and Run your Python Application
Everything managed by pure [Bazel](https://docs.bazel.build/versions/master/be/python.html) in Apollo 6.0.
Starting from Apollo 6.0, building and testing Python applications in Apollo is
done using [Bazel](https://docs.bazel.build/versions/master/be/python.html)
exclusively. We use Bazel Python rules to build, run, and test Python programs.
This not only frees us from hand-crafting Protobuf dependencies and managing
Python related Env variables manually, but also helps with managing third party
Python module dependency.
## Create the BUILD file
Generally you need a BUILD target for each python file, which could be one of
* `py_library(name="lib_target", ...)`
* `py_binary(name="bin_target", ...)`
* `py_test(name="test_target", ...)`
- `py_library(name="lib_target", ...)`
- `py_binary(name="bin_target", ...)`
- `py_test(name="test_target", ...)`
### Example
......@@ -48,7 +53,12 @@ py_test(
)
```
## Build & Run commands
Above is a BUILD file template, you can also use the
[BUILD](https://github.com/ApolloAuto/apollo/blob/master/cyber/python/BUILD) and
[BUILD](https://github.com/ApolloAuto/apollo/blob/master/cyber/python/examples/BUILD)
file as examples.
## Build, Test and Run commands
1. To build any target:
......@@ -65,5 +75,5 @@ py_test(
1. To run a unit test target:
```bash
bazel test //path/to:test_target
bazel test //path/to:target_test
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册