Any way to run pip or easy_install within a PND ?


ekianjo

Hardcore Member
Joined
May 7, 2012
Messages
8,261
Location
神戸市、日本 (Japan)
I am wondering if one can package a PND including such instructions as pip or easy_install to be executed for the first time the PND runs... 

Would that even work ? Usually pip would install the necessary requirements in a specific folder, and running pip from a PND may prevent such a location to be specified -> and then preventing the software from launching after the installation of requirements...

ANy idea? Has anyone tried yet ? 
 
You want a PND just to install another PND? (Excuse my poor English, that was what I could understand.)

I think the pnd_run.sh has the option to start the PND and don't run the script completion of PND, leaving the files it indefinitely.

If this help you, welcome =)

MarTinazzI
 
MarTinazzl: No, ekianjo wants a PND to install a Python package.

ekianjo: Yes, this is doable. Neither pip nor easy_install are in the firmware though, so they would have to be in your PND. Those tools can do a user install, which will install the package in $HOME/.local - and for a PND, $HOME is redirected to the appdata directory. Once it's installed there, I think a Python program run from within the PND will be able to import the new libraries. If I'm wrong about that, you can always modify sys.path or set the PYTHONPATH environment variable to pick up the install directory to make it work.

But why do you want to do this? The only use-case I can imagine is for some kind of Python IDE. If your program needs certain libraries in order to run, just include those libraries in the PND, don't download them on first run. But maybe you have some super-cool reason that I am too dumb to consider. Can you explain your larger goal here?
 
MarTinazzl: No, ekianjo wants a PND to install a Python package.


ekianjo: Yes, this is doable. Neither pip nor easy_install are in the firmware though, so they would have to be in your PND. Those tools can do a user install, which will install the package in $HOME/.local - and for a PND, $HOME is redirected to the appdata directory. Once it's installed there, I think a Python program run from within the PND will be able to import the new libraries. If I'm wrong about that, you can always modify sys.path or set the PYTHONPATH environment variable to pick up the install directory to make it work.


But why do you want to do this? The only use-case I can imagine is for some kind of Python IDE. If your program needs certain libraries in order to run, just include those libraries in the PND, don't download them on first run. But maybe you have some super-cool reason that I am too dumb to consider. Can you explain your larger goal here?
Thanks for the answer - 

The reason I would want to do that is for faster packaging without having to get 6-7 libraries every single time I want to make a PND, and keeping the python software up to date as well with the latest versions of the libraries downloaded by pip. 
 
Instead of you downloading and installing libraries, you want to make your every one of your users download and install libraries? On a device known to have trouble with network connectivity? ;) Not to mention, putting the libraries into your PND is probably easier than implementing an automated first-run downloader. Also, getting the latest version could potentially break your application if you designed for an earlier version.

So yes, I don't think this is a good idea. You should just use pip with the --target option to install into the directory that will become your PND. If you don't want to download them for every PND, just copy and paste the packages from one PND folder into another.
 
Another problem: whilst you can put easy_install inside a PND in the same way that cdevtools & code:blocks include it, users of the PND wouldn't be able to use it if the PND is on a card formatted with FAT32
 
So yes, I don't think this is a good idea. You should just use pip with the --target option to install into the directory that will become your PND. If you don't want to download them for every PND, just copy and paste the packages from one PND folder into another.
Now that's interesting. I did not know about the --target option. I will try that. Thanks!

Another problem: whilst you can put easy_install inside a PND in the same way that cdevtools & code:blocks include it, users of the PND wouldn't be able to use it if the PND is on a card formatted with FAT32
Why is that? 
 
It's a bug in AUFS that affects all PNDs. You'll have experienced it in the past when Pogo and gPodder didn't work for you. If a PND is on a card formatted with fat32, you can create a directory on first-run, and write to that directory, but you can't write to directories that already exist inside the PND.

For easy_install, your PND would need to have something inside it like


$MOUNTPOINT/bin/easy_install
$MOUNTPOINT/lib/python2.6/site-packages/setup-tools
If your PND tried to run easy_install, it would try to create lib/python2.6/site-packages/<NEWPKG>.egg in appdata, but it would fail for fat32 cards (file permission error).

That doesn't mean it's impossible though, it's just something to be aware of. You could conceivably modify easy_install to import its modules from one directory (inside the PND), and write out new modules to another directory (that you create on the PND's first run).
 
Back
Top