14. Package manager and module management

14.1. Click to download Package Manager

14.2. PikaPackage package manager

PikaScript 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.

The directory where PikaPcakge is located is https://gitee.com/Lyon1998/pikascript/tree/master/tools/pikaPackageManager

14.3. Workflow of PikaPackage

_images/59aa08a00bc1ea6d0fede3e80091f0bd.svg

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.

The following is an example of a requestment.txt file. The format of this file is the same as that of the mainstream python pip package manager. Fill in the module name and version number to pull the corresponding module. Currently only the == symbol is supported, which means strictly matching the version number. There is also a special version of latest, which means to pull the latest module. This latest refers to the latest version of the master branch in the pikascript repository. **If you are a user of a module rather than a developer, please be careful to avoid using the latest version whenever possible. Because the latest version is constantly changing, newer versions of modules may cause compatibility issues. **

  1. pikascript-core==v1.6.1
  2. PikaStdLib==v1.6.1
  3. PikaStdDevice==v1.6.0
  4. STM32G0==v1.2.0
  5. PikaPiZero==v1.1.3
  • 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 “ ”. Fill in the corresponding version name in request.txt to pull the corresponding version of the module.

**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. **

  1. [[packages]]
  2. name = "pikascript-core"
  3. releases = [
  4. "v0.8.1 af42fd61884dc7048628b0d3bafaa42697f6e8ea",
  5. "v0.8.2 af42fd61884dc7048628b0d3bafaa42697f6e8ea",
  6. "v0.8.3 af42fd61884dc7048628b0d3bafaa42697f6e8ea",
  7. "v0.9.0 332ef8afb0692cddd194782a07e30f2688d0f813",
  8. "v0.10.0 c86eaefa4516dd82b1050fa74a7d85399459d5ed",
  9. "v1.0.0 7b816b1546ef91a03f77760d4b10806ab956d452",
  10. "v1.1.0 845d1fc6520237e2238087800f72608dcb81afa6",
  11. "v1.1.1 c77e42450ed0eb09fcd7bb2b7d7c2b7eeeb55a2e",
  12. "v1.1.2 f6ad2c78f49162ab3f898abc6a0a4d87777ce655",
  13. "v1.1.3 6539072bf7bebb242ea40f8595bfb5c9aae3de7f",
  14. "v1.2.0 ce3df083b68fbfc85e64e6793fe07a6736d6f29f",
  15. "v1.2.1 e29a77527fd753c4eb811b047899534472bfc8ec",
  16. "v1.2.2 5316ede928b01a20571103616a64666abbc40e0a",
  17. "v1.2.3 5ae86929851ff6a62342a7072b77e9cf5be85f1c",
  18. "v1.2.4 b7ac057d75e88736cc844de0bafb447a48f2fb6d",
  19. "v1.2.5 db51f0520a673074a14ef0f5c4434da0d5c3425f",
  20. "v1.2.6 044a2a8f0905c6ca90c633759f397323ce57eefd",
  21. ]
  22. [[packages]]
  23. name = "PikaStdLib"
  24. releases = [
  25. "v1.0.1 af42fd61884dc7048628b0d3bafaa42697f6e8ea",
  26. "v1.1.0 0b3b866dbacc363c7b6b3899faa0cbcaccd59d5e",
  27. "v1.2.0 ca29e112687525ee7511bd30418d368754627a00",
  28. "v1.2.1 5ae86929851ff6a62342a7072b77e9cf5be85f1c",
  29. "v1.2.2 b7ac057d75e88736cc844de0bafb447a48f2fb6d",
  30. ]
  31. [[packages]]
  32. name = "PikaStdDevice"
  33. releases = [
  34. "v1.3.0 af42fd61884dc7048628b0d3bafaa42697f6e8ea",
  35. "v1.4.0 29c3c5b3b0cb4d3e41e6a2a0aef9e2826bc6f7ba",
  36. "v1.4.1 6539072bf7bebb242ea40f8595bfb5c9aae3de7f",
  37. "v1.4.2 5ae86929851ff6a62342a7072b77e9cf5be85f1c",
  38. ]
  39. [[packages]]
  40. name = "STM32"
  41. releases = [
  42. "v1.0.0 af42fd61884dc7048628b0d3bafaa42697f6e8ea",
  43. "v1.0.1 af42fd61884dc7048628b0d3bafaa42697f6e8ea",
  44. "v1.0.2 af42fd61884dc7048628b0d3bafaa42697f6e8ea",
  45. "v1.1.0 a18910b5dc349c64297bba3a13b7044f41d48e5f",
  46. "v1.1.1 91818aab0fa87b007e84866d479af5ac507339fe",
  47. "v1.2.0 6bd4aac6e9aba2a603da602be8583021da1272c0",
  48. "v1.3.0 7b816b1546ef91a03f77760d4b10806ab956d452",
  49. "v1.4.0 29c3c5b3b0cb4d3e41e6a2a0aef9e2826bc6f7ba",
  50. "v1.4.1 6539072bf7bebb242ea40f8595bfb5c9aae3de7f",
  51. "v1.4.2 8866710f653ad005f5c3edc5e6417ad31075b7d5",
  52. "v2.0.0 e29a77527fd753c4eb811b047899534472bfc8ec",
  53. "v2.0.1 5ae86929851ff6a62342a7072b77e9cf5be85f1c",
  54. ]
  • 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 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.)

14.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. _images/1639382545595-8a1bdb35-f995-4fc2-a23d-f60b0d3cc9aa.pngimage.png _images/1639382594452-b9ab5fa4-3712-4852-8ce0-42cee9345ac9.pngimage.png