I have a Python script which I then ran through pyinstaller2.0 to generate its binary.
python pyinstaller -F /path/to/python/script
While running the binary, it uses the /tmp folder by default to save it's temporary files and run the installer. This works fine on normal servers and VPSes. However, when an install is attempted on a server where /tmp is disabled (/tmp noexec
), the installation fails.
My questions are as follows:
Web servers have a directory named /tmp used to store temporary files. Many programs use this /tmp directory for writing temporary data and generally remove the data when it is no longer needed. Otherwise the /tmp directory is cleared when the server restarts.
The tmp folder(s) are found at: File System/tmp & File System/var/tmp The /tmp contents could be deleted - if you know which files/folders are required/not required by various apps on an "as required" basis.
Since PyInstaller
V3.3 (2017-09-21) you can use the --runtime-tmpdir argument to change the default extracting path, i.e.:
--runtime-tmpdir PATH
Where to extract libraries and support files in onefile-mode. If this option is given, the
bootloader
will ignore any temp-folder location defined by the run-time OS. The_MEIxxxxxx-folder
will be created here. Please use this option only if you know what you are doing.
The solution as suggested by @devnull was indeed to make changes in pyinstaller's script. The script had the temporary location hardcoded so I made changes there. So here are the steps followed:
launch.c
file under /path/to/pyinstaller/sources/common
int getTempPath(char *buff)
static const char *envname[]
(which are, it's declaration and one for
loop within the same function)static const char *dirname[]
to to the values which you want.The function thus, looks like so:
int getTempPath(char *buff)
{
static const char *dirname[] = {
"/usr/local/src/temp", "/usr/local/src", "/usr/src", 0
};
int i;
char *p;
for ( i=0; dirname[i]; i++ ) {
strcpy(buff, dirname[i]);
if (testTempPath(buff))
return 1;
}
return 0;
}
Recompile the pyinstaller sources
using the following command:
python ./waf configure --no-lsb build install
To run this, first install python-devel
packages (yum install python-devel -y
) else it throws and error that Python.h isn't found
Now when we run the python script through pyinstaller, the new temp local is used. Thanks to @devnull for pointing me in the right direction.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With