Skip to content

Commit

Permalink
optimize __init__ and add maixvision auto compleletion doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Neutree committed May 10, 2024
1 parent 508a0d8 commit fca9ab6
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_maixcam.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:
git init
git config user.name ${user_name}
git config user.email ${user_email}
remote_addr="https://${user_name}:${{ secrets.GITHUB_TOKEN }}@${remote_addr}"
remote_addr="https://Neutree:${{ secrets.GITHUB_TOKEN }}@${remote_addr}"
echo "-- user ${user_name}"
echo "-- remote addr: ${remote_addr}"
git remote add origin "${remote_addr}"
Expand Down
16 changes: 16 additions & 0 deletions docs/doc/en/basic/maixvision.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,19 @@ scp /path/to/your/file.py root@maixcam-xxxx.local:/root

* **Method 2**: Use tools like [FileZilla](https://filezilla-project.org/) to connect to the device, transfer the files to the device, choose the `SFTP` protocol, fill in the device and account information, and connect.



## Code Completion

Code completion depends on the Python packages installed locally on your computer. To enable code completion, you need to install Python on your computer and also the Python packages required for completion.

* To install Python, visit the [Python official website](https://python.org/) for installation.
* To install the packages required for completion, for instance, for MaixPy, you need to install the MaixPy package on your computer as well by using `pip install MaixPy`.
* Restart MaixVision to see the code completion.

> If the completion still does not work, you can manually set the path to the python executable in the settings and restart.
>! Note that installing Python packages on your computer is only for code completion purposes. The actual code still runs on the device (development board), and the device must also have the corresponding packages for proper operation.
> Additionally, although you have installed the MaixPy package on your computer, due to our limited resources, we do not guarantee that you will be able to directly import the maix package in Python on your computer for use. Please run it on supported devices.
14 changes: 14 additions & 0 deletions docs/doc/zh/basic/maixvision.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,22 @@ scp /path/to/your/file.py root@maixcam-xxxx.local:/root
* **方法二**:使用 [FileZilla](https://filezilla-project.org/) 等工具连接设备,将文件传输到设备上,选择 `SFTP` 协议填写设备和账号信息连接即可。


## 代码提示


代码提示依赖电脑本地的 Python 包,为了实现代码提示,我们需要在电脑中安装 Python,并且安装需要提示的 Python 包。

* 安装 Python 请访问 [Python 官网](https://python.org/)安装。
* 安装需要提示的包,比如对于 MaixPy, 你需要在电脑也安装一份 MaixPy 包,在电脑使用`pip install MaixPy`即可安装好。
> 中国国内用户可以使用国内镜像`pip install -i https://pypi.tuna.tsinghua.edu.cn/simple MaixPy`
* 重启 MaixVision 就能够看到代码提示了。
> 如果仍然不能提示,可以手动在设置中设置 python 可执行文件的路径后重启。
>! 注意在电脑安装 Python 包这里只是为了用作代码提示,实际代码运行还是在设备(开发板)上,设备上也要有对应的包才能正常运行。

> 另外,虽然你在电脑上安装了 MaixPy 包,但是由于我们精力有限,我们不确保你能直接在电脑的 Python 导入 maix 包进行使用,请在支持的设备上运行。



15 changes: 11 additions & 4 deletions maix/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,26 @@
for m in members:
if m[0].startswith("__"):
continue
new_members["maix." + m[0]] = m[1]
new_members["maix." + m[0]] = m

members = inspect.getmembers(_maix.peripheral)
for m in members:
if m[0].startswith("__"):
continue
new_members["maix." + m[0]] = m[1]
new_members["maix." + m[0]] = m

# clear all temp vars
del m, members, inspect

__all__ = []

import sys
for k, v in new_members.items():
sys.modules[k] = v
sys.modules[k] = v[1]
__all__.append(v[0])

del k, v, new_members, sys


del k, v, new_members
from ._maix import *
from ._maix.peripheral import *
4 changes: 2 additions & 2 deletions maix/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Versions should comply with PEP440: https://peps.python.org/pep-0440/

version_major = 4
version_minor = 0
version_patch = 11
version_minor = 1
version_patch = 0

__version__ = "{}.{}.{}".format(version_major, version_minor, version_patch)

0 comments on commit fca9ab6

Please sign in to comment.