2.2 KiB
Python module
Archinstall supports running in module mode. The way the library is invoked in module mode is limited to executing scripts under the example folder.
It's there for important to place any script or profile you wish to invoke in the examples folder prior to building and installing.
Pre-requisits
We'll assume you've followed the `installing.python.manual`_ method. Before actually installing the library, you will need to place your custom installer-scripts under ./archinstall/examples/ as a python file.
More on how you create these in the next section.
Warning
This is subject to change in the future as this method is currently a bit stiff. The script path will become a parameter. But for now, this is by design.
Creating a script
Lets create a test_installer - installer as an example. This is assuming that the folder ./archinstall is a git-clone of the main repo. We begin by creating ./archinstall/examples/test_installer.py. The placement here is important later.
This script can now already be called using python -m archinstall test_installer after a successful installation of the library itself. But the script won't do much. So we'll do something simple like list all the harddrives as an example.
To do this, we'll begin by importing archinstall in our ./archinstall/examples/test_installer.py and call some functions.
System Message: WARNING/2 (<stdin>, line 34)
Cannot analyze code. Pygments package not found.
.. code-block:: python
import archinstall
all_drives = archinstall.list_drives()
print(all_drives)
This should print out a list of drives and some meta-information about them. As an example, this will do just fine.
Now, go ahead and install the library either as a user-module or system-wide.
Calling a module
Assuming you've followed the example in Creating a script, you can now safely call it with:
System Message: ERROR/3 (<stdin>, line 51)
Error in "code-block" directive: maximum 1 argument(s) allowed, 4 supplied.
.. code-block::
python -m archinstall test_installer
This should now print all available drives on your system.
Note
This should work on any system, not just Arch Linux based ones. But note that other functions in the library relies heavily on Arch Linux based commands to execute the installation steps. Such as arch-chroot.
Docutils System Messages
System Message: ERROR/3 (<stdin>, line 14); backlink
Unknown target name: "installing.python.manual".