Not saying we shouldn't fix the underlying problem, but this will make the ones we miss go away
From: David Shea dshea@redhat.com
This adds a copy of sitecustomize.py to a directory that can be added to PYTHONPATH, and adds that directory to PYTHONPATH when running liveinst. This way anaconda do perform early sys changes while not affecting python globally and not messing up regular imports too badly.
This does not fix unicode problems for all cases (image/dir install are still affected), but it papers over them for live installs. --- anaconda.spec.in | 4 ++++ data/liveinst/liveinst | 1 + 2 files changed, 5 insertions(+)
diff --git a/anaconda.spec.in b/anaconda.spec.in index ce56390..c5df111 100644 --- a/anaconda.spec.in +++ b/anaconda.spec.in @@ -237,6 +237,10 @@ find %{buildroot} -type f -name "*.la" | xargs %{__rm}
%ifarch %livearches desktop-file-install ---dir=%{buildroot}%{_datadir}/applications %{buildroot}%{_datadir}/applications/liveinst.desktop + +# Add a sitecustomize.py to be loaded by liveinst +mkdir -p %{buildroot}%{_datadir}/anaconda/site-python +install -m 0644 pyanaconda/sitecustomize.py %{buildroot}%{_datadir}/anaconda/site-python/ %endif # NOTE: If you see "error: Installed (but unpackaged) file(s) found" that include liveinst files, # check the IS_LIVEINST_ARCH in configure.ac to make sure your architecture is properly defined diff --git a/data/liveinst/liveinst b/data/liveinst/liveinst index cbbd5ae..e26619d 100755 --- a/data/liveinst/liveinst +++ b/data/liveinst/liveinst @@ -85,6 +85,7 @@ else fi
export PATH=/sbin:/usr/sbin:$PATH +export PYTHONPATH=/usr/share/anaconda/site-python
if [ -x /usr/sbin/getenforce ]; then current=$(/usr/sbin/getenforce)
This seems less hacky than the `reload(sys)` approach - and very similar to how we do it for non-lives, which is good. I'm very much +1 to this or *some* kind of 'force utf-8 for lives' approach - it's not strictly speaking the 'right thing to do' but in practice it's this or herd `UnicodeDecodeError`s until whenever we get anaconda to py3.
I checked this (by manually stuffing the changes into a live env before running liveinst) and it seems to do the trick - tested that a couple of the known bugs in Final TC1 - RHBZ#1217411 and RHBZ#1217610 - do not occur when the hack is in place.
Also note that this should be dropped with a switch to Python 3 (adding a label so that we don't forget to check it) or pushed only to the *f22-branch* with master being expected to do the switch right after F22 release.
Added label: check Python 3.
@@ -237,6 +237,10 @@ find %{buildroot} -type f -name "*.la" | xargs %{__rm}
%ifarch %livearches desktop-file-install ---dir=%{buildroot}%{_datadir}/applications %{buildroot}%{_datadir}/applications/liveinst.desktop
+# Add a sitecustomize.py to be loaded by liveinst +mkdir -p %{buildroot}%{_datadir}/anaconda/site-python +install -m 0644 pyanaconda/sitecustomize.py %{buildroot}%{_datadir}/anaconda/site-python/
This should also be added to %files section.
@@ -237,6 +237,10 @@ find %{buildroot} -type f -name "*.la" | xargs %{__rm}
%ifarch %livearches desktop-file-install ---dir=%{buildroot}%{_datadir}/applications %{buildroot}%{_datadir}/applications/liveinst.desktop
+# Add a sitecustomize.py to be loaded by liveinst +mkdir -p %{buildroot}%{_datadir}/anaconda/site-python +install -m 0644 pyanaconda/sitecustomize.py %{buildroot}%{_datadir}/anaconda/site-python/
This should also be added to %files section.
AFAICT, we include everything from %{_datadir}/anaconda.
Also note that this should be dropped with a switch to Python 3 (adding a label so that we don't forget to check it) or pushed only to the f22-branch with master being expected to do the switch right after F22 release.
I figured I'd only push it to f22-branch. We need to actually handle the string type disagreements since sitecustomize isn't going to handle cases like dirinstall or livemedia-creator, so I see this as just a temporary fix for F22 live.
@@ -237,6 +237,10 @@ find %{buildroot} -type f -name "*.la" | xargs %{__rm}
%ifarch %livearches desktop-file-install ---dir=%{buildroot}%{_datadir}/applications %{buildroot}%{_datadir}/applications/liveinst.desktop
+# Add a sitecustomize.py to be loaded by liveinst +mkdir -p %{buildroot}%{_datadir}/anaconda/site-python +install -m 0644 pyanaconda/sitecustomize.py %{buildroot}%{_datadir}/anaconda/site-python/
This should also be added to %files section.
AFAICT, we include everything from %{_datadir}/anaconda.
Yes, the directory ends up in anaconda-core without any extra help.
Closed.
Pushed to f22-branch
:smile: :+1:
anaconda-patches@lists.fedorahosted.org