Bug 9791 - Python searches for packages in the user site directory
Summary: Python searches for packages in the user site directory
Status: VERIFIED FIXED
Alias: None
Product: buildroot
Classification: Unclassified
Component: Other (show other bugs)
Version: unspecified
Hardware: All Linux
: P5 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-04-04 16:55 UTC by Anton Leontiev
Modified: 2017-04-08 15:15 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments
Log for `LANG=C PYTHONVERBOSE=1 make python-serial` (58.24 KB, text/x-log)
2017-04-04 16:55 UTC, Anton Leontiev
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Anton Leontiev 2017-04-04 16:55:12 UTC
Created attachment 7006 [details]
Log for `LANG=C PYTHONVERBOSE=1 make python-serial`

I receive the following error with Buildroot 2017.02:

> $ LANG=C make python-serial
> >>> python-serial 3.1 Installing to target
> (cd /home/aleontiev/projects/mcom/firmware/buildroot/output/build/python-serial-3.1//; PATH="/home/aleontiev/projects/mcom/firmware/buildroot/output/host/bin:/home/aleontiev/projects/mcom/firmware/buildroot/output/host/sbin:/home/aleontiev/projects/mcom/firmware/buildroot/output/host/usr/bin:/home/aleontiev/projects/mcom/firmware/buildroot/output/host/usr/sbin:/home/aleontiev/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin" PYTHONPATH="/home/aleontiev/projects/mcom/firmware/buildroot/output/target/usr/lib/python2.7/sysconfigdata/:/home/aleontiev/projects/mcom/firmware/buildroot/output/target/usr/lib/python2.7/site-packages/" _python_sysroot=/home/aleontiev/projects/mcom/firmware/buildroot/output/host/usr/arm-buildroot-linux-gnueabi/sysroot _python_prefix=/usr _python_exec_prefix=/usr  /home/aleontiev/projects/mcom/firmware/buildroot/output/host/usr/bin/python setup.py install --no-compile --prefix=/home/aleontiev/projects/mcom/firmware/buildroot/output/target/usr --executable=/usr/bin/python --single-version-externally-managed --root=/ )
> usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
>    or: setup.py --help [cmd1 cmd2 ...]
>    or: setup.py --help-commands
>    or: setup.py cmd --help
> 
> error: option --executable not recognized
> make: *** [/home/aleontiev/projects/mcom/firmware/buildroot/output/build/python-serial-3.1/.stamp_target_installed] Error 1

I've found that this happens because host Python built by Buildroot is still looking for packages in user site directiry. See full log for `LANG=C PYTHONVERBOSE=1 make python-serial` in the attachment.

I think Python should not search user site directory to allow reproducible builds that does not depend on user-installed packages. A possible solution would be to export PYTHONNOUSERSITE=1 for all or just Python packages.
Comment 2 Anton Leontiev 2017-04-08 15:15:17 UTC
I've tested the patch on my setup. The issue is fixed.