[devel] python-modules-encodings

Alexey Tourbin =?iso-8859-1?q?at_=CE=C1_altlinux=2Eru?=
Пн Мар 19 21:24:04 MSK 2007


On Tue, Mar 20, 2007 at 01:53:24AM +0800, Ivan Fedorov wrote:
> Alexey Tourbin пишет:
> > Наверное, нужно захачить питон, чтобы он не загружал encodings, если
> > запущен под buildreq'ом.
> 
> Ну вот такого зверства не надо!!!

Хорошо.
Я придумал промежуточное решение на уровне rpm-build-python и buildreq.

commit 80cc60b7525cd1fcbb85df6f91a02e2e09ef0a6e
Author: Alexey Tourbin <at на altlinux>
Date:   Mon Mar 19 21:12:54 2007 +0300

    deal with build dependencies on python-modules-encodings
    
    If you run buildreq and if you have python-modules-encodings installed,
    buildreq will always yield python-modules-encodings.  However, if
    python-modules-encodings is missing, that's okay (most of the time).
    
    $ packagereq -o /dev/stdout rpm --eval %__python_version
    2.4
    packagereq: building requires list: python-modules-encodings
    python-modules-encodings
    $
    
    The problem is in the following code:
    
    Python/Python/codecs.c
       834      mod = PyImport_ImportModuleEx("encodings", NULL, NULL, NULL);
       835      if (mod == NULL) {
       836          if (PyErr_ExceptionMatches(PyExc_ImportError)) {
       837              /* Ignore ImportErrors... this is done so that
       838                 distributions can disable the encodings package. Note
       839                 that other errors are not masked, e.g. SystemErrors
       840                 raised to inform the user of an error in the Python
       841                 configuration are still reported back to the user. */
       842              PyErr_Clear();
       843              return 0;
       844          }
       845          return -1;
       846      }
    
    And there's no switch like "assume no encodings available at startup".
    
    Now I still don't want buildreq to yield python-modules-encodings
    only because I evaluate %__python_version macro.
    
    The solution is as follows:
    
    1) everywhere from rpm-build-python run python with LC_ALL=C.
    2) add encoding files loaded under LC_ALL=C to buildreq skiplist.
    
    New behaviour:
    
    $ packagereq -o /dev/stdout rpm --eval %__python_version
    2.4
    packagereq: building requires list: python-base
    python-base
    $

diff --git a/rpm-build-python.spec b/rpm-build-python.spec
index a3da4b1..cf5c5aa 100644
--- a/rpm-build-python.spec
+++ b/rpm-build-python.spec
@@ -39,6 +39,7 @@ subst 's/@PYTHON_VERSION@/%__python_version/g' python
 %install
 install -pD -m644 python %buildroot%_sysconfdir/rpm/macros.d/python
 install -pD -m644 python.env %buildroot%_sysconfdir/rpm/macros.d/python.env
+install -pD -m644 python.buildreq %buildroot%_sysconfdir/buildreqs/files/ignore.d/%name
 install -pD -m755 python.prov %buildroot%_target_libdir/rpm/python.prov
 install -pD -m755 python.prov.py %buildroot%_target_libdir/rpm/python.prov.py
 install -pD -m755 python.prov.files %buildroot%_target_libdir/rpm/python.prov.files
@@ -62,6 +63,7 @@ unset RPM_PYTHON
 %files
 %_sysconfdir/rpm/macros.d/python
 %_sysconfdir/rpm/macros.d/python.env
+%_sysconfdir/buildreqs/files/ignore.d/%name
 %_target_libdir/rpm/python.compileall.py
 %_target_libdir/rpm/python.req
 %_target_libdir/rpm/python.req.py
diff --git a/rpm-build-python/python b/rpm-build-python/python
index 8b49990..af9a622 100644
--- a/rpm-build-python/python
+++ b/rpm-build-python/python
@@ -2,7 +2,7 @@
 # -*- coding: utf-8 -*-
 
 # Override __python_version macro provided by rpm-build 
-%__python_version	%(%__python -c 'import sys; print "%%u.%%u" %% sys.version_info[0:2]' 2>/dev/null || echo @PYTHON_VERSION@)
+%__python_version	%(LC_ALL=C %__python -c 'import sys; print "%%u.%%u" %% sys.version_info[0:2]' 2>/dev/null || echo @PYTHON_VERSION@)
 
 %_python_lib_path	""
 %_python_req_method	slight
diff --git a/rpm-build-python/python.buildreq b/rpm-build-python/python.buildreq
new file mode 100644
index 0000000..4e323a7
--- /dev/null
+++ b/rpm-build-python/python.buildreq
@@ -0,0 +1,3 @@
+^/usr/.*/python.*/encodings/__init__\.py
+^/usr/.*/python.*/encodings/aliases\.py
+^/usr/.*/python.*/encodings/ascii\.py
diff --git a/rpm-build-python/python.prov b/rpm-build-python/python.prov
index cdca9e4..309a1fd 100755
--- a/rpm-build-python/python.prov
+++ b/rpm-build-python/python.prov
@@ -1,2 +1,2 @@
 #!/bin/sh
-exec "${RPM_PYTHON:-python}" "$0".py ${1+"$@"}
+LC_ALL=C exec "${RPM_PYTHON:-python}" "$0".py ${1+"$@"}
diff --git a/rpm-build-python/python.req b/rpm-build-python/python.req
index cdca9e4..309a1fd 100755
--- a/rpm-build-python/python.req
+++ b/rpm-build-python/python.req
@@ -1,2 +1,2 @@
 #!/bin/sh
-exec "${RPM_PYTHON:-python}" "$0".py ${1+"$@"}
+LC_ALL=C exec "${RPM_PYTHON:-python}" "$0".py ${1+"$@"}
----------- следующая часть -----------
Было удалено вложение не в текстовом формате...
Имя     : =?iso-8859-1?q?=CF=D4=D3=D5=D4=D3=D4=D7=D5=C5=D4?=
Тип     : application/pgp-signature
Размер  : 189 байтов
Описание: =?iso-8859-1?q?=CF=D4=D3=D5=D4=D3=D4=D7=D5=C5=D4?=
Url     : <http://lists.altlinux.org/pipermail/devel/attachments/20070319/5e839d5c/attachment-0001.bin>


Подробная информация о списке рассылки Devel