<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>8673</bug_id>
          
          <creation_ts>2015-11-11 06:47:48 +0000</creation_ts>
          <short_desc>distutils3 packages installed via an egg file cannot be imported by the python3 interpreter</short_desc>
          <delta_ts>2017-05-29 17:04:54 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>OE-Core</product>
          <component>devtools / tool chain</component>
          <version>2.0</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>NOTABUG</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium+</priority>
          <bug_severity>enhancement</bug_severity>
          <target_milestone>2.4 M1</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Alejandro Hernandez">alejandro.hernandez</reporter>
          <assigned_to name="Jose Lamego">jose.a.lamego</assigned_to>
          <cc>leonardo.sandoval.gonzalez</cc>
    
    <cc>meta.mr.watcher</cc>
    
    <cc>meta.watcher</cc>
    
    <cc>ross.burton</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>56373</commentid>
    <comment_count>0</comment_count>
    <who name="Alejandro Hernandez">alejandro.hernandez</who>
    <bug_when>2015-11-11 06:47:48 +0000</bug_when>
    <thetext>When installing packages that use .egg files, such as python3-pip or python3-setuptools, these cannot be imported when opening a python3 interpreter/ pip3 for example is installed using an egg file:

# ls /usr/lib/python3.5/site-packages/ | grep pip
pip-6.1.1-py3.5.egg

But, when trying to import it, the following error is shown:

Python 3.5.0 (default, Nov 11 2015, 00:30:30) 
[GCC 5.2.0] on linux
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
&gt;&gt;&gt; import pip
Traceback (most recent call last):
  File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;
ImportError: No module named &apos;pip&apos;


We can see that the .egg file isn&apos;t part of sys.path:
&gt;&gt;&gt; import sys
&gt;&gt;&gt; print (sys.path)
[&apos;&apos;, &apos;/usr/lib/python35.zip&apos;, &apos;/usr/lib/python3.5&apos;, &apos;/usr/lib/python3.5/plat-linux&apos;, &apos;/usr/lib/python3.5/lib-dynload&apos;, &apos;/usr/lib/python3.5/site-packages&apos;, &apos;/usr/lib/python3.5/site-packages/setuptools-18.2-py3.5.egg&apos;]

but, if we add it, we&apos;re now able to import pip without trouble:
&gt;&gt;&gt; sys.path.append(&apos;/usr/lib/python3.5/site-packages/pip-6.1.1-py3.5.egg&apos;)
&gt;&gt;&gt; import pip
&gt;&gt;&gt;

We need to add a .pth file to /usr/lib/python3.5/site-packages/ containing the path to the installed egg file, like python3-setuptools package does.

I suggest we should add this functionality to the distutils3.bbclass, so this doesn&apos;t have to be done by every recipe, its likely this affects distutils on python2 as well, we should check that too.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>56433</commentid>
    <comment_count>1</comment_count>
    <who name="Ross Burton">ross.burton</who>
    <bug_when>2015-11-12 16:00:42 +0000</bug_when>
    <thetext>Should we ship packages that contain eggs?  The python 2 setuptools code disables eggs and packages get installed with the egg metadata but not inside an actual egg.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>56446</commentid>
    <comment_count>2</comment_count>
    <who name="Alejandro Hernandez">alejandro.hernandez</who>
    <bug_when>2015-11-12 17:47:07 +0000</bug_when>
    <thetext>(In reply to comment #1)
&gt; Should we ship packages that contain eggs?  The python 2 setuptools code
&gt; disables eggs and packages get installed with the egg metadata but not
&gt; inside an actual egg.

I would agree, I don&apos;t see any reason to install them as eggs, but the code to disable this behavior is there on the setuptools3.bbclass too, perhaps when setuptools was merged with distribute upstream this option was deprecated, there might be another way of doing it, it&apos;s definitely worth checking</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>56451</commentid>
    <comment_count>3</comment_count>
    <who name="Alejandro Hernandez">alejandro.hernandez</who>
    <bug_when>2015-11-12 21:53:13 +0000</bug_when>
    <thetext>(In reply to comment #2)
&gt; (In reply to comment #1)
&gt; &gt; Should we ship packages that contain eggs?  The python 2 setuptools code
&gt; &gt; disables eggs and packages get installed with the egg metadata but not
&gt; &gt; inside an actual egg.
&gt; 
&gt; I would agree, I don&apos;t see any reason to install them as eggs, but the code
&gt; to disable this behavior is there on the setuptools3.bbclass too, perhaps
&gt; when setuptools was merged with distribute upstream this option was
&gt; deprecated, there might be another way of doing it, it&apos;s definitely worth
&gt; checking

Actually the code its working just fine, it is extracting the metadata correctly, as we can see here, the pip-6.1.1-py3.5.egg is a directory, and it contains the metadata.

root@qemux86:/usr/lib/python3.5/site-packages# ls -l
total 360
-rw-r--r-- 1 root root    119 Nov 11 21:07 README
drwxr-xr-x 2 root root   1024 Nov 12 18:19 __pycache__
drwxr-xr-x 4 root root   1024 Nov 12 18:20 pip-6.1.1-py3.5.egg
-rw-r--r-- 1 root root 361195 Nov 12 18:19 setuptools-18.2-py3.5.egg
-rw-r--r-- 1 root root     28 Nov 12 18:19 setuptools.pth
-rw-r--r-- 1 root root   2389 Nov 12 18:19 site.py

So, apparently the problem is that when checking sys.path it doesn&apos;t work recursively, hence why pip in this case, cannot be imported.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61662</commentid>
    <comment_count>4</comment_count>
    <who name="Humberto Ibarra">humberto.ibarra.lopez</who>
    <bug_when>2016-04-25 20:57:02 +0000</bug_when>
    <thetext>Tried to reproduce this on other python modules from meta, but the only two recipes that presented this issue were the ones mentioned here (pip &amp; setuptools).

These two cases were already fixed in the specific recipes for pip &amp; setuptools. Thought about moving this code to distutils, but I believe that it is better as it is right now since that alternative only puts unneeded files for modules that do not show this problem.

Made a wider search with a great number of python modules from all kind of places and only saw this problem in 2 more modules, but those are out of this scope since they belong to the meta-openembedded layer. These two modules were python-pyparsing and python-simplejson.

I&apos;m closing this for now since there is no work to do in the meta/ folder. Will keep an eye open for this happening in some other recipe.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>62739</commentid>
    <comment_count>5</comment_count>
    <who name="Alejandro Hernandez">alejandro.hernandez</who>
    <bug_when>2016-06-07 23:11:37 +0000</bug_when>
    <thetext>I can confirm I see this same issue on python-numpy:

root@qemux86:~# python
Python 2.7.11 (default, Jun  6 2016, 18:29:07) 
[GCC 6.1.1 20160511] on linux2
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
&gt;&gt;&gt; import numpy
Traceback (most recent call last):
  File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;
ImportError: No module named numpy


and again, doing:


root@qemux86:~# echo /usr/lib/python2.7/site-packages/numpy-1.11.0-py2.7-linux-x86_64.egg &gt; /usr/lib/python2.7/site-packages/numpy.pth

Fixes the problem

root@qemux86:~# python
Python 2.7.11 (default, Jun  6 2016, 18:29:07) 
[GCC 6.1.1 20160511] on linux2
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
&gt;&gt;&gt; import numpy
&gt;&gt;&gt; 


This should be done automatically from the distutils class.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>63179</commentid>
    <comment_count>6</comment_count>
    <who name="Ross Burton">ross.burton</who>
    <bug_when>2016-06-21 11:09:42 +0000</bug_when>
    <thetext>Was this fixed by dd756bb8fdff676dba312e38ebc90c4c89dfe855 or was that just a workaround?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>63222</commentid>
    <comment_count>7</comment_count>
    <who name="Alejandro Hernandez">alejandro.hernandez</who>
    <bug_when>2016-06-21 20:02:38 +0000</bug_when>
    <thetext>It was a workaround only for python-numpy,it could still happen to any package using distutils, I changed most of them to setuptools for now though.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>63305</commentid>
    <comment_count>8</comment_count>
    <who name="Leonardo Sandoval Gonzalez">leonardo.sandoval.gonzalez</who>
    <bug_when>2016-06-23 19:48:36 +0000</bug_when>
    <thetext>My fault, moving it to M1 again. CCB should agree on any milestone movement.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>63547</commentid>
    <comment_count>9</comment_count>
    <who name="Leonardo Sandoval Gonzalez">leonardo.sandoval.gonzalez</who>
    <bug_when>2016-06-30 20:19:44 +0000</bug_when>
    <thetext>This is not affecting master branch. Moving it to M2.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65515</commentid>
    <comment_count>10</comment_count>
    <who name="Leonardo Sandoval Gonzalez">leonardo.sandoval.gonzalez</who>
    <bug_when>2016-08-25 17:13:54 +0000</bug_when>
    <thetext>This is an enhancement and due to time constrains, it won&apos;t be ready for M3. Moving it to first milestone for next release (2.3).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>69805</commentid>
    <comment_count>11</comment_count>
    <who name="Jose Lamego">jose.a.lamego</who>
    <bug_when>2017-01-13 17:28:05 +0000</bug_when>
    <thetext>I&apos;ve pushed a patch to poky-contrib at:
http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/commit/?h=lamego/bug8673&amp;id=80014962b523005717d1a562cca77849fa4f551b

please provide feedback.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>69806</commentid>
    <comment_count>12</comment_count>
    <who name="Alejandro Hernandez">alejandro.hernandez</who>
    <bug_when>2017-01-13 18:07:33 +0000</bug_when>
    <thetext>(In reply to comment #11)
&gt; I&apos;ve pushed a patch to poky-contrib at:
&gt; http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/commit/?h=lamego/
&gt; bug8673&amp;id=80014962b523005717d1a562cca77849fa4f551b
&gt; 
&gt; please provide feedback.

While I believe the naming of the egg file will always comply with what you wrote on your patch, I still think a better way would be to find the name of the creted egg file instead of checking for the name we assume it&apos;ll have, and then add that path to the pth file, also, it should be worth checking if this happens on python2 as well (distutils class), I see that python-numpy (py2) had issues but I can&apos;t recall exactly</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>69840</commentid>
    <comment_count>13</comment_count>
    <who name="Jose Lamego">jose.a.lamego</who>
    <bug_when>2017-01-16 21:08:16 +0000</bug_when>
    <thetext>Alex, I&apos;ve pushed a revised version to contrib. please provide feedback:

http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/commit/?h=lamego/bug8673

Also, I did test python-setuptools and python-numpy but this behavior was not detected.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>69844</commentid>
    <comment_count>14</comment_count>
    <who name="Alejandro Hernandez">alejandro.hernandez</who>
    <bug_when>2017-01-16 22:56:24 +0000</bug_when>
    <thetext>(In reply to comment #13)
&gt; Alex, I&apos;ve pushed a revised version to contrib. please provide feedback:
&gt; 
&gt; http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/commit/?h=lamego/
&gt; bug8673
&gt; 
&gt; Also, I did test python-setuptools and python-numpy but this behavior was
&gt; not detected.

Looks good in my opinion, the only thing I would do is separate into 3 or at least 2 patches, one with the change to the distutils class, and the other(s) fixing the recipes after the class has that functionality</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>69858</commentid>
    <comment_count>15</comment_count>
    <who name="Jose Lamego">jose.a.lamego</who>
    <bug_when>2017-01-17 15:47:04 +0000</bug_when>
    <thetext>Patches sent to the mailing list can be seen at:

https://patchwork.openembedded.org/series/4820/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>70133</commentid>
    <comment_count>16</comment_count>
    <who name="Leonardo Sandoval Gonzalez">leonardo.sandoval.gonzalez</who>
    <bug_when>2017-01-25 17:14:52 +0000</bug_when>
    <thetext>I believe the patches have not landed to master but will be soon at M3.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>70570</commentid>
    <comment_count>17</comment_count>
    <who name="Jose Lamego">jose.a.lamego</who>
    <bug_when>2017-02-08 22:45:43 +0000</bug_when>
    <thetext>A reminder was sent to the mailing list. Waiting for comments/merging.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>71221</commentid>
    <comment_count>18</comment_count>
    <who name="Jose Lamego">jose.a.lamego</who>
    <bug_when>2017-03-13 20:32:58 +0000</bug_when>
    <thetext>A reminder was sent to the ML. Moving to 2.4, waiting for merging.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>73547</commentid>
    <comment_count>19</comment_count>
    <who name="Jose Lamego">jose.a.lamego</who>
    <bug_when>2017-05-29 17:04:54 +0000</bug_when>
    <thetext>The created .egg files/directories are now being appropriately added to PATH, allowing both the python3-pip and python3-setuptools modules to be imported at the python3 interpreter. Reported behavior cannot be reproduced, so I&apos;m closing this as not a bug.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>