<?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>12076</bug_id>
          
          <creation_ts>2017-09-13 10:25:22 +0000</creation_ts>
          <short_desc>PYTHONPATH pointing to python2.7 site-packages causes bmaptool to crash</short_desc>
          <delta_ts>2017-09-15 11:06:56 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>5</classification_id>
          <classification>Infrastructure</classification>
          <product>AutoBuilder</product>
          <component>autobuilder</component>
          <version>unspecified</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>High</priority>
          <bug_severity>major</bug_severity>
          <target_milestone>2.4 M4</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Ed Bartosh">eduard.bartosh</reporter>
          <assigned_to name="Joshua Lock">joshuagloe</assigned_to>
          <cc>infras.ab.watcher</cc>
    
    <cc>Infras.watcher</cc>
    
    <cc>pidge</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>76779</commentid>
    <comment_count>0</comment_count>
    <who name="Ed Bartosh">eduard.bartosh</who>
    <bug_when>2017-09-13 10:25:22 +0000</bug_when>
    <thetext>PYTHONPATH environment variable contains path to python 2.7 site-packages. This makes bmaptool (and probably any other python 3 program) to fail when importing pkg_resources module from python 2.7 site-packages directory:

File &quot;/home/pokybuild/yocto-autobuilder/yocto-worker/nightly-oe-selftest/build/build/tmp/work/core2-64-poky-linux/wic-tools/1.0-r0/recipe-sysroot-native/usr/bin/bmaptool&quot;, line 6, in &lt;module&gt;
    from pkg_resources import load_entry_point
  File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 969, in _find_and_load
  File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 954, in _find_and_load_unlocked
  File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 896, in _find_spec
  File &quot;&lt;frozen importlib._bootstrap_external&gt;&quot;, line 1147, in find_spec
  File &quot;&lt;frozen importlib._bootstrap_external&gt;&quot;, line 1123, in _get_spec
  File &quot;&lt;frozen importlib._bootstrap_external&gt;&quot;, line 1104, in _legacy_get_spec
  File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 444, in spec_from_loader
  File &quot;&lt;frozen importlib._bootstrap_external&gt;&quot;, line 541, in spec_from_file_location
  File &quot;/home/pokybuild/yocto-autobuilder/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py&quot;, line 29
    def _bypass_ensure_directory(name, mode=0777):
                                               ^
SyntaxError: invalid token

That makes wic test cases using bmaptool to fail on AB: https://autobuilder.yocto.io/builders/nightly-oe-selftest/builds/512/steps/Running%20oe-selftest/logs/stdio</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>76786</commentid>
    <comment_count>1</comment_count>
    <who name="Ed Bartosh">eduard.bartosh</who>
    <bug_when>2017-09-13 14:15:53 +0000</bug_when>
    <thetext>Reproduced on centos 7:

PYTHONPATH=/usr/lib/python2.7/site-packages/ python3.6 -c &apos;from pkg_resources import load_entry_point&apos;
Traceback (most recent call last):
  File &quot;&lt;string&gt;&quot;, line 1, in &lt;module&gt;
  File &quot;/usr/lib/python2.7/site-packages/pkg_resources.py&quot;, line 78
    def _bypass_ensure_directory(name, 0777):
                                          ^
SyntaxError: invalid token

The reason is that octal literals have different prefix in Python 3.
Anyway, it&apos;s not a good idea to even try to import modules from python 2 in Python 3 script.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>76788</commentid>
    <comment_count>2</comment_count>
    <who name="Joshua Lock">joshuagloe</who>
    <bug_when>2017-09-13 14:27:50 +0000</bug_when>
    <thetext>Early in the implementation of the yocto-autobuilder it was decided that rather than installing the software &amp; its dependencies it would be run directly from a clone of the repository. An environment setup script is used to set variables, including PYTHONPATH, required to support this workflow.

The problem therefore is how we support the existing &quot;run from a clone&quot; workflow without polluting the environment with a PYTHONPATH that adds Python 2.7 modules.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>76789</commentid>
    <comment_count>3</comment_count>
    <who name="Ed Bartosh">eduard.bartosh</who>
    <bug_when>2017-09-13 14:57:11 +0000</bug_when>
    <thetext>if we run python 3 and use python 3 libraries in PYTHONPATH we still can run from a clone.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>76790</commentid>
    <comment_count>4</comment_count>
    <who name="Joshua Lock">joshuagloe</who>
    <bug_when>2017-09-13 14:59:20 +0000</bug_when>
    <thetext>(In reply to comment #3)
&gt; if we run python 3 and use python 3 libraries in PYTHONPATH we still can run
&gt; from a clone.

That&apos;s certainly true, but we can&apos;t port yocto-autobuilder to Python 3 in time to stop this failure breaking M4 builds.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>76824</commentid>
    <comment_count>5</comment_count>
    <who name="Joshua Lock">joshuagloe</who>
    <bug_when>2017-09-14 11:18:06 +0000</bug_when>
    <thetext>1) add a .pth file to a location in site.getusersitepackages() i.e. ~/.local/lib/python2.7/site-packages that lists the modules we carry in our repository
2) Update each executable (i.e. bin/twistd) to add entries to sys.path
3) link the autobuilders lib/python2.7/site-packages contents into ~/.local/lib/python2.7/site-packages

I&apos;m leaning towards 1 as that&apos;s a little easier to track and undo. Any of these options are antithetical to the decision to not have the AB install and affect the host system, but that&apos;s not a decision I care to enforce moving forwards.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>76829</commentid>
    <comment_count>6</comment_count>
    <who name="Joshua Lock">joshuagloe</who>
    <bug_when>2017-09-14 12:46:26 +0000</bug_when>
    <thetext>Implementing solution which adds an autobuilder.pth to the site.getusersitepackages()</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>76831</commentid>
    <comment_count>7</comment_count>
    <who name="Joshua Lock">joshuagloe</who>
    <bug_when>2017-09-14 13:51:42 +0000</bug_when>
    <thetext>Implemented and in testing on the old cluster.

http://git.yoctoproject.org/clean/cgit.cgi/yocto-autobuilder/commit/?id=7c77c01d4818f0cdb9a325a865379bb673b26bcc

plus a couple of follow-ups:
http://git.yoctoproject.org/clean/cgit.cgi/yocto-autobuilder/commit/?id=4f0334e33e16bb8e407eb2da2e2988caa7d8b1f7
http://git.yoctoproject.org/clean/cgit.cgi/yocto-autobuilder/commit/?id=21f14553d10b60ed7fd926f7fc3f374c32e78e95</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>76885</commentid>
    <comment_count>8</comment_count>
    <who name="Joshua Lock">joshuagloe</who>
    <bug_when>2017-09-15 11:06:56 +0000</bug_when>
    <thetext>Changes now deployed to both clusters.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>