WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: piCore 7 alex iot python  (Read 11916 times)

Offline njs

  • Newbie
  • *
  • Posts: 25
Re: piCore 7 alex iot python
« Reply #30 on: October 13, 2017, 07:17:02 PM »
However if you use pip/setuptools to install a bunch of python packages, you will soon run into problems making them persistant within the RPi ram and speed constraints.

Can you elaborate on what you mean by that and how building from source is different?

Offline njs

  • Newbie
  • *
  • Posts: 25
Re: piCore 7 alex iot python
« Reply #31 on: October 13, 2017, 10:43:53 PM »
okay here's what I tried based on your examples...

Code: [Select]
tce-load -i compiletc python-dev setuptools python-olefile tiff-dev freetype-dev libtiff-dev
cd /tmp
tar -xf Pillow-4.3.0.tar.gz
cd Pillow-4.3.0/
python setup.py build_ext --enable-jpeg
touch mymarker
sudo python setup.py build_ext --enable-jpeg install
sudo find / -not -type 'd' -cnewer mymarker | grep -v "\/proc\/" | grep -v "^\/sys\/" | tee python2.7-Pillow-files.lst

The resulting file list is attached.

However when I tested the install there seems to be a problem  :(...

Code: [Select]
python
Python 2.7.13 (default, Dec 23 2016, 18:28:09)
[GCC 6.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from PIL import Image
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "PIL/Image.py", line 56, in <module>
    from . import _imaging as core
ImportError: cannot import name _imaging

Any suggestions?

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14800
Re: piCore 7 alex iot python
« Reply #32 on: October 14, 2017, 03:59:59 AM »
Here are the files from your list that you need:
Code: [Select]
/usr/local/bin/pilprint.py
/usr/local/bin/painter.py
/usr/local/bin/thresholder.py
/usr/local/bin/player.py
/usr/local/bin/enhancer.py
/usr/local/bin/explode.py
/usr/local/bin/pilconvert.py
/usr/local/bin/pilfont.py
/usr/local/bin/pilfile.py
/usr/local/bin/gifmaker.py
/usr/local/bin/viewer.py
/usr/local/bin/pildriver.py
/usr/local/lib/python2.7/site-packages/olefile-0.44-py2.7.egg
/usr/local/lib/python2.7/site-packages/Pillow-4.3.0-py2.7-linux-armv6l.egg

The *egg files are zip archives, which makes things difficult to figure out and tends to waste space as they often contain unneeded *.pyc files, unstripped libs, text files, etc.

With reference to:

http://tinycorelinux.net/8.x/x86_64/tcz/python-pillow.tcz.list

..Pillow-4.3.0-py2.7-linux-armv6l.egg should contain _imaging.so, the lack of which causes the "cannot import name _imaging" error. You can check for this using the unzip command.

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14800
Re: piCore 7 alex iot python
« Reply #33 on: October 14, 2017, 04:12:06 AM »
Can you elaborate on what you mean by that and how building from source is different?

I presumed (perhaps wrongly) that you were planning to add the pip/setuptools installed packages to your backup, which would use a lot of ram and make booting slower. You could however make personal extensions out of the packages (as long as you could figure out which files were needed).

Another problem with pip/setuptools installed packages is that they always seem to use *egg files, which usually contain unneeded bloat. If you compile from source, it often does not result in *egg files (as is the case with olefile) or, can be prevented with "--old-and-unmanageable". This being said, with pillow, I had to manually unzip the *egg file to strip the libs and remove bloat.

Offline njs

  • Newbie
  • *
  • Posts: 25
Re: piCore 7 alex iot python
« Reply #34 on: October 14, 2017, 10:24:55 AM »
I presumed (perhaps wrongly) that you were planning to add the pip/setuptools installed packages to your backup, which would use a lot of ram and make booting slower. You could however make personal extensions out of the packages (as long as you could figure out which files were needed).

Another problem with pip/setuptools installed packages is that they always seem to use *egg files, which usually contain unneeded bloat. If you compile from source, it often does not result in *egg files (as is the case with olefile) or, can be prevented with "--old-and-unmanageable". This being said, with pillow, I had to manually unzip the *egg file to strip the libs and remove bloat.

Yes, I'm trying to make extensions for each package to be loop mounted as I am trying to minimize boot time.

I guess I don't understand why "sudo python setup.py build_ext --enable-jpeg
Code: [Select]
install" does a half job leaving stuff in egg files not available for import by my application.  The whole purpose of this command would seem to be to to create a functioning installation, although I've always used pip (or a few times apt get blah)...

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14800
Re: piCore 7 alex iot python
« Reply #35 on: October 15, 2017, 02:35:47 AM »
Normally python packages installed with pip/setuptools that contain *egg files do work.

Did you make your test directly after installing pillow or after having made an extension of it?

Edit: Using an RPi3 and piCore 9.x armv7, I got the following:
Code: [Select]
$ tce-load -i compiletc python3.6-dev tk-dev libtiff-dev freetype-dev
$ sudo pip3.6 install pillow
...
  Running setup.py install for pillow ... done
Successfully installed pillow-4.3.0

$ ls  /usr/local/lib/python3.6/site-packages
OleFileIO_PL.py              README.txt                   olefile-0.44-py3.6.egg-info/ setuptools/
PIL/                         __pycache__/                 pip/                         setuptools-28.8.0.dist-info/
Pillow-4.3.0-py3.6.egg-info/ easy_install.py              pip-9.0.1.dist-info/
README                       olefile/                     pkg_resources/

$ viewer.py
Syntax: python viewer.py imagefile

..so pip did not install the *egg files, but installed the packages in the old way instead.

With reference to:

http://tinycorelinux.net/8.x/x86_64/tcz/python-pillow.tcz.list

..what I don't see are files analagous to /usr/local/lib/python2.7/site-packages/Pillow-4.2.1-py2.7-linux-x86_64.egg-info/scripts/*, but maybe that is due to using python-2.7.x or an earlier version of pillow.
« Last Edit: October 15, 2017, 03:05:17 AM by Juanito »