用于管理/更新CircuitPython设备上库的工具。
项目描述
用于管理和更新CircuitPython设备上库(模块)的工具。
安装
Circup需要Python 3.5或更高版本。
在virtualenv中,pip install circup应该可以解决问题。这是使其工作最简单的方法。
如果您不知道什么是virtualenv,请尝试以下命令,pip3 install --user circup。
Circup能做什么?
设备上的每个CircuitPython库通常在模块中包含一个版本号作为元数据。
此实用程序会检查设备上的所有库,并确定它们是否是最新的(与最新版本的Adafruit CircuitPython Bundle和Circuitpython Community Bundle中找到的版本进行比较)。如果库已过时,实用程序会帮助您更新它们。
Adafruit CircuitPython Bundle可以在以下位置找到
https://github.com/adafruit/Adafruit_CircuitPython_Bundle/releases/latest
有关这些库的详细信息、它们的功能以及如何获取它们的详细信息,请在此处查看
https://circuitpython.org/libraries
Circuitpython Community Bundle可以在以下位置找到
https://github.com/adafruit/CircuitPython_Community_Bundle/releases/latest
使用方法
如果您需要更多关于使用Circup的帮助,请参阅学习指南文章“使用CircUp轻松保持您的CircuitPython库更新”。
首先,插入一个运行CircuitPython的设备。这应该会显示为一个名为CIRCUITPY的挂载存储设备。
要获取帮助,只需输入以下命令
$ circup Usage: circup [OPTIONS] COMMAND [ARGS]... A tool to manage and update libraries on a CircuitPython device. Options: --verbose Comprehensive logging is sent to stdout. --path DIRECTORY Path to CircuitPython directory. Overrides automatic path detection. --host TEXT Hostname or IP address of a device. Overrides automatic path detection. --password TEXT Password to use for authentication when --host is used. --timeout INTEGER Specify the timeout in seconds for any network operations. --board-id TEXT Manual Board ID of the CircuitPython device. If provided in combination with --cpy-version, it overrides the detected board ID. --cpy-version TEXT Manual CircuitPython version. If provided in combination with --board-id, it overrides the detected CPy version. --version Show the version and exit. --help Show this message and exit. Commands: bundle-add Add bundles to the local bundles list, by "user/repo"... bundle-remove Remove one or more bundles from the local bundles list. bundle-show Show the list of bundles, default and local, with URL,... example Copy named example(s) from a bundle onto the device. freeze Output details of all the modules found on the connected... install Install a named module(s) onto the device. list Lists all out of date modules found on the connected... show Show a list of available modules in the bundle. uninstall Uninstall a named module(s) from the connected device. update Update modules on the device. Use --all to automatically update all modules without Major Version warnings.
要自动安装由code.py导入的所有模块,请使用$ circup install --auto
$ circup install --auto Found device at /Volumes/CIRCUITPY, running CircuitPython 7.0.0-alpha.5. Searching for dependencies for: ['adafruit_bmp280'] Ready to install: ['adafruit_bmp280', 'adafruit_bus_device', 'adafruit_register'] Installed 'adafruit_bmp280'. Installed 'adafruit_bus_device'. Installed 'adafruit_register'.
要搜索包含名称bme的特定模块,请使用$ circup show bme
$ circup show bme Found device at /Volumes/CIRCUITPY, running CircuitPython 6.1.0-beta.2. adafruit_bme280 adafruit_bme680 2 shown of 257 packages.
要显示连接的CIRCUITPYTHON设备上所有模块的版本信息
$ circup freeze adafruit_binascii==v1.0 adafruit_bme280==2.3.1 adafruit_ble==1.0.2
使用$ circup freeze -r
,Circup将保存当前工作目录中的requirements.txt文件,其中包含连接设备上当前安装的所有模块的列表。
要列出所有需要更新的模块
$ circup list The following modules are out of date or probably need an update. Module Version Latest ------------------ -------- -------- adafruit_binascii v1.0 1.0.1 adafruit_ble 1.0.2 4.0
要交互式更新过时的模块
$ circup update Found 3 module[s] needing update. Please indicate which modules you wish to update: Update 'adafruit_binascii'? [y/N]: Y OK Update 'adafruit_ble'? [y/N]: Y OK
使用以下命令将模块或多个模块安装到连接的设备上
$ circup install adafruit_thermal_printer Installed 'adafruit_thermal_printer'. $ circup install adafruit_thermal_printer adafruit_bus_io Installed 'adafruit_thermal_printer'. Installed 'adafruit_bus_io'.
如果您需要使用模块的原始.py版本,请使用–py标志。
$ circup install –py adafruit_thermal_printer 已安装‘adafruit_thermal_printer’。
您还可以使用当前工作目录中的requirements.txt文件安装模块列表
$ circup install -r requirements.txt Installed 'adafruit_bmp280'. Installed 'adafruit_lis3mdl'. Installed 'adafruit_lsm6ds'. Installed 'adafruit_sht31d'. Installed 'neopixel'.
像这样卸载模块或多个模块
$ circup uninstall adafruit_thermal_printer Uninstalled 'adafruit_thermal_printer'. $ circup uninstall adafruit_thermal_printer adafruit_bus_io Uninstalled 'adafruit_thermal_printer'. Uninstalled 'adafruit_bus_io'.
使用--verbose标志查看命令执行过程中的日志
$ circup --verbose freeze Logging to /home/ntoll/.cache/circup/log/circup.log 10/18/2020 00:54:43 INFO: ### Started Circup ### 10/18/2020 00:54:43 INFO: Found device: /Volumes/CIRCUITPY Found device at /Volumes/CIRCUITPY, running CircuitPython 6.0.0-alpha.1-1352-gf0b37313c. 10/18/2020 00:54:44 INFO: Freeze 10/18/2020 00:54:44 INFO: Found device: /Volumes/CIRCUITPY ... etc ...
--path标志允许您传递不同的路径到CircuitPython挂载卷。当您已重命名或连接了多个CircuitPython设备时,这很有用。
$ circup --path /run/media/user/CIRCUITPY1 list
--version标志将告诉您circup命令的当前版本
$ circup --version CircUp, A CircuitPython module updater. Version 0.0.1
要使用支持Web Workflow的设备上的circup,请使用--host和--password参数在circup命令之前。
$ circup --host 192.168.1.119 --password s3cr3t install adafruit_hid $ circup --host cpy-9573b2.local --password s3cr3t install adafruit_hid
就是这样!
库名称自动完成
启用后,circup将与其他命令行工具类似,自动完成库名称。
例如
circup install n + tab -circup install neopixel (+tab:提供neopixel和neopixel_spi的补全)
circup install a + tab -circup install adafruit\_ + m a g + tab -circup install adafruit_magtag
如何激活库名称自动完成
为了激活shell补全,您需要通知您的shell您的脚本中提供了补全功能。任何Click应用程序都会自动提供对该功能的支持。
对于Bash,将以下内容添加到~/.bashrc
eval "$(_CIRCUP_COMPLETE=bash_source circup)"
对于Zsh,将以下内容添加到~/.zshrc
eval "$(_CIRCUP_COMPLETE=zsh_source circup)"
对于Fish,将以下内容添加到~/.config/fish/completions/foo-bar.fish
eval (env _CIRCUP_COMPLETE=fish_source circup)
打开一个新的shell以启用补全。或者,直接在当前shell中运行eval命令以临时启用它。### 激活脚本
上面的eval示例将在每次启动shell时调用您的应用程序。这可能会显着减慢shell启动时间。
或者,将生成的补全代码作为静态脚本导出以执行。您可以将此文件与您的构建一起分发;例如,Git会这样做。至少Zsh也会缓存补全文件的结果,但不会缓存eval脚本。
适用于Bash
_CIRCUP_COMPLETE=bash_source circup circup-complete.sh
适用于Zsh
_CIRCUP_COMPLETE=zsh_source circup circup-complete.sh
适用于Fish
_CIRCUP_COMPLETE=fish_source circup circup-complete.sh
在 .bashrc 或 .zshrc 中,使用 source 命令代替 eval 命令来引用脚本
. /path/to/circup-complete.sh
对于Fish,将文件添加到补全目录
_CIRCUP_COMPLETE=fish_source circup ~/.config/fish/completions/circup-complete.fish
有关此工具的讨论发生在 Adafruit CircuitPython Discord 频道。
项目详情
下载文件
下载适用于您平台的文件。如果您不确定选择哪个,请了解有关 安装包 的更多信息。