SPADS Inline::Python installation guide: Difference between revisions
No edit summary |
|||
| Line 45: | Line 45: | ||
<br> | <br> | ||
If for some reason the installation from my fork fails, you can try to install the stable release of <code>Inline::Python</code> instead. Unfortunately, the current stable release of <code>Inline::Python</code> doesn't install automatically on Windows due to broken Python | If for some reason the installation from my fork fails, you can try to install the stable release of <code>Inline::Python</code> instead. Unfortunately, the current stable release of <code>Inline::Python</code> doesn't install automatically on Windows due to broken Python installation detection and one test which is coded for Linux system only and which must be skipped. Consequently, <code>cpanminus</code> must be run in interactive mode and with a flag to force installation despite the failing test, using this command:<br> | ||
<code>cpanm --interactive -f Inline::Python</code> | <code>cpanm --interactive -f Inline::Python</code> | ||
Revision as of 10:25, 28 January 2021
Introduction
Inline::Python is a Perl module which allows interactions between Perl code and Python code. SPADS uses it to communicate with plugins coded in Python.
Unfortunately the current stable release of this module suffers from a bug which makes Perl strings appear as byte strings when used with Python 3 (Python 2 is unaffected). This is not a blocking problem, as Python can easily convert these data if needed and SPADS plugin API offers dedicated functions to deal with the problem (cf the PYTHON SPECIFIC NOTES - Perl strings conversions section of the Plugin API documentation). However, a cleaner way to solve this problem is to install a fixed version of the module, directly from the official module maintainer repository. The remaining of this document will detail the different ways to install Inline::Python, on Linux and Windows.
Installing Inline::Python on Linux
Method 1: Using cpanminus to install latest version from GitHub
cpanminus is a lightweight package manager for Perl, which is able to install Perl modules directly from Git repositories. This is very useful for Inline::Python installation because only the latest version from the module maintainer repository includes the fix for Perl string conversions with Python 3.
The first step consists in installing cpanminus (if not already installed on your system). To do that you can usually use the package manager of your Linux distribution. For example, for Debian based distributions: apt-get install cpanminus, or for Red Hat based distributions: dnf install perl-App-cpanminus (for other cases, check the INSTALLATION section of cpanminus documentation).
Once cpanminus is installed, it can be used to install the latest version of Inline::Python from module maintainer's repository. This can be done simply by entering following command (with root privileges if you are using the system Perl):
cpanm https://github.com/niner/inline-python-pm.git
Method 2: Using the package manager of your Linux distribution
This is the easiest way to install Inline::Python (if your distribution supports it), as it automatically downloads and installs a package specifically prepared for your distribution. However, this method installs the stable release of Inline::Python, which suffers from the string conversion bug with Python 3 explained in introduction. So this method is only recommended if you don't plan to use Python 3 or if the installation method based on cpanminus failed.
For this method you just need to find the name of the system package containing the Inline::Python Perl module and install it on your system.
For example, for Debian based distributions: apt-get install libinline-python-perl
For Red Hat based distributions: dnf install perl-Inline-Python
Method 3: Using cpan
cpan is the standard tool included with Perl to install modules from the Comprehensive Perl Archive Network. Unfortunately, only the current stable releases of the modules can easily be installed this way, so this method should only be reserved to cases where all other installation methods failed.
To install Inline::Python using cpan, simply enter following command (with root privileges if you are using the system Perl):
cpan Inline::Python
Installing Inline::Python on Windows
Step 1: Installing cpanminus
cpanminus is a lightweight module manager for Perl, which is able to install Perl modules directly from Git repositories and allows interactive mode installations.
If your are using Strawberry Perl, cpanminus should be pre-installed (you can check it by trying the cpanm command in a console windows). If you are using another Perl distribution and cpanminus isn't pre-installed, you should be able to use the packet manager of your Perl distribution (ppm for example for old ActiveState Perl releases) to install cpanminus. You can also use the generic default Perl module manager cpan to install it using following command: cpan cpanminus
Step 2: Using cpanminus to install Inline::Python
As explained in introduction, the current stable release of Inline::Python suffers from the string conversion bug with Python 3, so it is recommended to install the latest version instead. Unfortunately, the installation script included in the latest version on the module maintainer repository has some problems when installing on Windows. I created my own fork on GitHub to fix these installation problems. As long as the module maintainer didn't merge my fixes in his repository, I recommend using my fork to install the latest version of Inline::Python on Windows, using following command:
cpanm https://github.com/Yaribz/inline-python-pm.git
If for some reason the installation from my fork fails, you can try to install the stable release of Inline::Python instead. Unfortunately, the current stable release of Inline::Python doesn't install automatically on Windows due to broken Python installation detection and one test which is coded for Linux system only and which must be skipped. Consequently, cpanminus must be run in interactive mode and with a flag to force installation despite the failing test, using this command:
cpanm --interactive -f Inline::Python
The install script will then ask 4 questions:
Use which? [1]Here you must enter the full path of yourpython.exefile from your Python installation (warning: paths containing spaces are not supported by the installer). For example:C:\Python\python.exeEnter extra libraries (e.g. -lfoo -lbar) [None]Here you can press enter, as no additional library should be needed for standard Python installation.Which? Or enter another. [1]Here you need to enter the digit corresponding to the library with 2 digits in its name. For example:2(to select entry2) C:/Python/libs/python39.lib)Which? Or enter another. [1]Here you can press enter as the install script should have auto-detected the include location of your Python installation correctly.