5.2. Package manager
5.2.2. PikaPackage package manager
PikaPython has an officially supported package manager, PikaPackage, which is used for module management. It can provide kernel, module download, module release, kernel, and module version switching functions, which is convenient for distributing developed modules and managing module versions.
PikaPackage is a monolithic application for the windows platform. Based on the development of the go language, it integrates the go-git component, which can realize the pull, update and version switching functions of the git repository without installing git.
5.2.3. Workflow of PikaPackage
PikaPackage will automatically complete the series of processes shown in the figure above.
The first is to check whether the /tmp/pikascript folder exists. If not, it will clone a pikascript repository first.
The /tmp directory refers to the tmp folder in the root directory of the disk where pikaPackage.exe is currently located. For example, if pikaPackage.exe is on drive C, then /tmp is C:/tmp, and if it is on drive D, then /tmp is D:/tmp. The clone repository uses the gitee source, so don’t worry about the network connection problem, and it is also very fast in China.
Update repository to latest state.
Read the modules in the current request.txt file.
Here is an example of a requestment.txt file, the format of this file is the same as the mainstream python pip package manager format, fill in the module name and version number to pull the corresponding module.
pikascript-core PikaStdLib PikaStdDevice==v1.6.0 STM32G0==v1.2.0 PikaPiZero==v1.1.3
You can write the module name directly, e.g.
Or specify the version number, e.g.
PikaStdDeivce==v1.6.0, currently only the
== symbol is supported, which means the version number is strictly matched.
There is also a special version
latest, which means pulling the latest module, which refers to the latest version of the master branch in the pikascript repository
If you are a module user and not a developer, please be careful to avoid using the latest version at all costs. Because the latest version is constantly changing, newer versions of the module may cause compatibility issues.
pikaPackage.exe checks /tmp/pikascript/packages.toml file, which is a module description file in a repository, this file describes all available modules and their versions. The following is the intercepted part of the packages.toml file. In this file, there are four modules, pikascript-core, PikaStdLib, PikaStdDevice, and STM32, which can be pulled, and the release section under each module describes the version that can be used.
The format of the module version is “
If you also want to publish the module, you can fill in the packages.toml file in the same way, and the package manager can recognize the module you published.
[[packages]] name = "pikascript-core" releases = [ "v0.8.1 af42fd61884dc7048628b0d3bafaa42697f6e8ea", "v0.8.2 af42fd61884dc7048628b0d3bafaa42697f6e8ea", "v0.8.3 af42fd61884dc7048628b0d3bafaa42697f6e8ea", "v0.9.0 332ef8afb0692cddd194782a07e30f2688d0f813", "v0.10.0 c86eaefa4516dd82b1050fa74a7d85399459d5ed", "v1.0.0 7b816b1546ef91a03f77760d4b10806ab956d452", "v1.1.0 845d1fc6520237e2238087800f72608dcb81afa6", "v1.1.1 c77e42450ed0eb09fcd7bb2b7d7c2b7eeeb55a2e", "v1.1.2 f6ad2c78f49162ab3f898abc6a0a4d87777ce655", "v1.1.3 6539072bf7bebb242ea40f8595bfb5c9aae3de7f", "v1.2.0 ce3df083b68fbfc85e64e6793fe07a6736d6f29f", "v1.2.1 e29a77527fd753c4eb811b047899534472bfc8ec", "v1.2.2 5316ede928b01a20571103616a64666abbc40e0a", "v1.2.3 5ae86929851ff6a62342a7072b77e9cf5be85f1c", "v1.2.4 b7ac057d75e88736cc844de0bafb447a48f2fb6d", "v1.2.5 db51f0520a673074a14ef0f5c4434da0d5c3425f", "v1.2.6 044a2a8f0905c6ca90c633759f397323ce57eefd", ] [[packages]] name = "PikaStdLib" releases = [ "v1.0.1 af42fd61884dc7048628b0d3bafaa42697f6e8ea", "v1.1.0 0b3b866dbacc363c7b6b3899faa0cbcaccd59d5e", "v1.2.0 ca29e112687525ee7511bd30418d368754627a00", "v1.2.1 5ae86929851ff6a62342a7072b77e9cf5be85f1c", "v1.2.2 b7ac057d75e88736cc844de0bafb447a48f2fb6d", ] [[packages]] name = "PikaStdDevice" releases = [ "v1.3.0 af42fd61884dc7048628b0d3bafaa42697f6e8ea", "v1.4.0 29c3c5b3b0cb4d3e41e6a2a0aef9e2826bc6f7ba", "v1.4.1 6539072bf7bebb242ea40f8595bfb5c9aae3de7f", "v1.4.2 5ae86929851ff6a62342a7072b77e9cf5be85f1c", ] [[packages]] name = "STM32" releases = [ "v1.0.0 af42fd61884dc7048628b0d3bafaa42697f6e8ea", "v1.0.1 af42fd61884dc7048628b0d3bafaa42697f6e8ea", "v1.0.2 af42fd61884dc7048628b0d3bafaa42697f6e8ea", "v1.1.0 a18910b5dc349c64297bba3a13b7044f41d48e5f", "v1.1.1 91818aab0fa87b007e84866d479af5ac507339fe", "v1.2.0 6bd4aac6e9aba2a603da602be8583021da1272c0", "v1.3.0 7b816b1546ef91a03f77760d4b10806ab956d452", "v1.4.0 29c3c5b3b0cb4d3e41e6a2a0aef9e2826bc6f7ba", "v1.4.1 6539072bf7bebb242ea40f8595bfb5c9aae3de7f", "v1.4.2 8866710f653ad005f5c3edc5e6417ad31075b7d5", "v2.0.0 e29a77527fd753c4eb811b047899534472bfc8ec", "v2.0.1 5ae86929851ff6a62342a7072b77e9cf5be85f1c", ]
pikaPackage.exe go to the /tmp/pikascript/pacakge folder to find the folder with the same name as packages.toml, then switch to the specified commit id, and then copy the folder to the current pikascript-lib folder.
If you want to publish a module, create a new folder with the same name as the module in the pikascript/package directory, and then copy all the files contained in the module to this folder. After submitting the folder and obtaining the commit id, fill in the commit id into the packages.toml description file.
Note: To limit the complexity of modules and improve maintainability, nested folders are not supported in module folders.
The *.py and *.pyi files contained in the module folder will be automatically copied to the current folder, in order to be able to recognize the python module (python only recognizes the module files in the current folder when importing a module.)
5.2.4. Error troubleshooting
If you are suspected of encountering problems during use, you can run pikaPackage.exe in cmd to view the complete log information.