Preparing Software
Make sure the following procedures are performed:
Note: The python project, VisionFive.gpio, is
applicable for VisionFive, VisionFive
2 and JH-7110 EVB.
- Flash Debian OS into a Micro-SD card as described in the Flashing Fedora OS to a Micro-SD Card section in the VisionFive 2 Single Board Computer Quick Start Guide.
- Log into the Debian and make sure VisionFive 2 is connected to the Internet. For detailed instructions, refer to the Using SSH over Ethernet or Using a USB to Serial Converter section in the VisionFive 2 Single Board Computer Quick Start Guide.
- Extend the partition on Debian as described in Extend Partition in the VisionFive 2 Single Board Computer Quick Start Guide.
- Execute the following command to install and create a Python3 Virtual Environment on
Debian:
sudo apt install python3-venv python3 -m venv myvenv
Note:You may rename “myvenv” according to your preference.
- Execute the
pip
command on VisionFive 2 Debian to install the VisionFive.gpio package:Note: Due to the fact that pypi.org official website does not yet support uploading whl installation packages for the RISC-V platform, so it cannot directly executepython3 -m pip install VisionFive.gpio
command to install online.Please follow the steps below to install the VisionFive.gpio package.
- Execute the following command to install dependent package within the
newly created virtual
environment:
sudo apt install libxml2-dev libxslt-dev source ./myvenv/bin/activate python3 -m pip install requests wget bs4
- Execute the following command to run the installation script
Install_VisionFive_gpio.py
:python3 Install_VisionFive_gpio.py
The installation script codes are as follows:import requests import wget import sys import os from bs4 import BeautifulSoup def parse_data(link_addr, class_type, key_str): req = requests.get(url=link_addr) req.encoding = "utf-8" html = req.text soup = BeautifulSoup(req.text, features="html.parser") package_version = soup.find(class_type, class_=key_str) dd = package_version.text.strip() data = dd.split() return data def parse_link(link_addr, class_type, key_str): version_list = [] req = requests.get(url=link_addr) req.encoding = "utf-8" html = req.text soup = BeautifulSoup(req.text, features="html.parser") search_data = soup.find_all(class_type, class_=key_str) for i in range(0, len(search_data)): search_data[i] = search_data[i].find("a").get("href) version_list.append(search_data[i].split("cp")[-1].split("-")[0]) python_version = sys.version python_version = python_version.split(".")[0] + python_version.split(".")[1] for i in range(0, len(search_data)): if python_version == version_list[i]: return search_data[i] return search_data[0] def get_dl_addr_page(): link_address = "https://pypi.org/project/VisionFive.gpio/#history" key_str = "release version" class_key = "p" data_get = parse_data(link_address, class_key, key_str) latest_version = data_get[0] dl_addr_page = "https://pypi.org/project/VisionFive.gpio/{}/#files".format(latest_version) return dl_addr_page def get_dl_addr_of_latest_version(link_addr): key_str = "card file card" class_key = "div" addr_get = parse_link(link_addr, class_key, key_str) return addr_get def main(): dl_addr_p = get_dl_addr_page() whl_dl_addr = get_dl_addr_of_latest_version(dl_addr_p) whl_name = whl_dl_addr.split("/")[-1] whl_name_suffix = os.path.splitext(whl_name)[-1] whl_name_prefix = os.path.splitext(whl_name)[0] whl_name_prefix_no_platform = whl_name_prefix[0: len(whl_name_prefix) - 3] new_platform = "linux_riscv64" rename_whl_name = "{}{}{}".format(whl_name_prefix_no_platform, new_platform, whl_name_suffix) wget.download(whl_dl_addr, out=rename_whl_name) os.system("pip install " + rename_whl_name) os.system("rm -rf " + rename_whl_name) if __name__ == '__main__': sys.exit(main())
- (Optional) Exit the Python3 Virtual
Environment.
deactivate
- Execute the following command to install dependent package within the
newly created virtual
environment: