Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Gentoo Development (http://www.linux-archive.org/gentoo-development/)
-   -   Patch for python.eclass (http://www.linux-archive.org/gentoo-development/429266-patch-python-eclass.html)

Arfrever Frehtes Taifersar Arahesis 09-20-2010 01:18 AM

Patch for python.eclass
 
This patch for python.eclass has been divided into 3 subpatches to simplify review.

Subpatch #1 fixes preservation of whitespace.

Subpatch #2 renames 2 local arrays in python_mod_optimize() function:
site_packages_absolute_dirs -> dirs
site_packages_absolute_files -> files

Subpatch #3 adds --allow-evaluated-non-sitedir-paths option to python_mod_optimize() and
python_mod_cleanup() functions.
In rare cases, packages supporting installation for multiple Python ABIs install .py files
outside of site-packages directories. python_mod_optimize() and python_mod_cleanup()
functions currently don't support such paths. It's better to not allow such paths by
default, so this subpatch adds new --allow-evaluated-non-sitedir-paths option to these
functions. This option is disallowed in packages not supporting installation for multiple
Python ABIs. Such paths are internally evaluated inside these functions. Such paths work
correctly only if they contain '${PYTHON_ABI}' or '$(python_get_version)' (probably with
'$(python_get_implementation)') or '$(custom_function)' (where custom_function() uses
"${PYTHON_ABI}" or "$(python_get_version)" and prints appropriate output), so there are
sanity checks, which ensure that such paths contain '$'.

Example usage:

pkg_postinst() {
python_mod_optimize --allow-evaluated-non-sitedir-paths '/usr/share/package_name/${PYTHON_ABI}'
}

pkg_postrm() {
python_mod_cleanup --allow-evaluated-non-sitedir-paths '/usr/share/package_name/${PYTHON_ABI}'
}

This functionality is needed by Zope 2.12 / 2.13.

--
Arfrever Frehtes Taifersar Arahesis

Mike Frysinger 09-20-2010 01:45 AM

Patch for python.eclass
 
On Sunday, September 19, 2010 21:18:51 Arfrever Frehtes Taifersar Arahesis
wrote:
> -evaluated_PYTHONPATH="$(eval echo -n "${PYTHONPATH_template}")"
> +eval "evaluated_PYTHONPATH="${PYTHONPATH_template}" "

the quotes in the 2nd one are useless. this should work the same:
eval evaluated_PYTHONPATH="${PYTHONPATH_template}"

while you're in the process of cleaning things up, i know we dont have a rule
anywhere in terms of line length, but python.eclass has always struck me as a
file with incredibly excessive line length. comparing to other eclasses, it
has multiple lines in it longer than any single line in any other eclass.

i normally develop in a terminal with 170 cols (which i think is larger than
average), so i'm pretty lenient, but even python.eclass exceeds that multiple
times if not running close to it.
-mike

Arfrever Frehtes Taifersar Arahesis 09-20-2010 02:53 AM

Patch for python.eclass
 
2010-09-20 03:45:14 Mike Frysinger napisał(a):
> On Sunday, September 19, 2010 21:18:51 Arfrever Frehtes Taifersar Arahesis
> wrote:
> > -evaluated_PYTHONPATH="$(eval echo -n "${PYTHONPATH_template}")"
> > +eval "evaluated_PYTHONPATH="${PYTHONPATH_template}" "
>
> the quotes in the 2nd one are useless. this should work the same:
> eval evaluated_PYTHONPATH="${PYTHONPATH_template}"

The quotes are required:

$ PYTHONPATH_template="/usr/share/a b"
$ eval "evaluated_PYTHONPATH="${PYTHONPATH_template}" "
$ echo "${evaluated_PYTHONPATH}"
/usr/share/a b
$ eval evaluated_PYTHONPATH="${PYTHONPATH_template}"
$ echo "${evaluated_PYTHONPATH}"
/usr/share/a b

> while you're in the process of cleaning things up, i know we dont have a rule
> anywhere in terms of line length, but python.eclass has always struck me as a
> file with incredibly excessive line length. comparing to other eclasses, it
> has multiple lines in it longer than any single line in any other eclass.
>
> i normally develop in a terminal with 170 cols (which i think is larger than
> average), so i'm pretty lenient, but even python.eclass exceeds that multiple
> times if not running close to it.

python.eclass has many nested checks, loops etc.

--
Arfrever Frehtes Taifersar Arahesis

Mike Frysinger 09-20-2010 03:00 AM

Patch for python.eclass
 
On Sunday, September 19, 2010 22:53:31 Arfrever Frehtes Taifersar Arahesis
wrote:
> 2010-09-20 03:45:14 Mike Frysinger napisał(a):
> > while you're in the process of cleaning things up, i know we dont have a
> > rule anywhere in terms of line length, but python.eclass has always
> > struck me as a file with incredibly excessive line length. comparing to
> > other eclasses, it has multiple lines in it longer than any single line
> > in any other eclass.
> >
> > i normally develop in a terminal with 170 cols (which i think is larger
> > than average), so i'm pretty lenient, but even python.eclass exceeds
> > that multiple times if not running close to it.
>
> python.eclass has many nested checks, loops etc.

so what ? actually look at the long lines. none of them need to be so long:

lines 33 & 802 & 2226 - a large number of local variables that could easily be
line wrapped otherwise we get 344+ cols. good luck figuring out what vars are
at the tail end of that.

lines 274 & 290 - a lot of checks in a single if statement that too could
easily be line wrapped

line 2354 - a really long ebegin message that is shown to users

line 489 - a single sed statement that can easily be line wrapped

lines 1158 & 1184 - a single inline python command that can easily be line
wrapped
-mike

Peter Volkov 09-20-2010 06:10 AM

Patch for python.eclass
 
В Пнд, 20/09/2010 в 04:53 +0200, Arfrever Frehtes Taifersar Arahesis
пишет:
> > while you're in the process of cleaning things up, i know we dont have a rule
> > anywhere in terms of line length, but python.eclass has always struck me as a
> > file with incredibly excessive line length. comparing to other eclasses, it
> > has multiple lines in it longer than any single line in any other eclass.
> >
> > i normally develop in a terminal with 170 cols (which i think is larger than
> > average), so i'm pretty lenient, but even python.eclass exceeds that multiple
> > times if not running close to it.
>
> python.eclass has many nested checks, loops etc.

Although we don't write ebuilds in C there are useful bits in
/usr/src/linux/Documentation/CodingStyle:

1. Coding style is all about readability and maintainability using
commonly available tools.

2. Now, some people will claim that having 8-character indentations
makes the code move too far to the right, and makes it hard to read on a
80-character terminal screen. The answer to that is that if you need
more than 3 levels of indentation, you're screwed anyway, and should fix
your program.


In other words having many nested checks means that eclass needs
reorganization to avoid them.

--
Peter.

Arfrever Frehtes Taifersar Arahesis 09-24-2010 05:39 PM

Patch for python.eclass
 
I will commit this patch in 3 days, if there are no other suggestions about this patch.

--
Arfrever Frehtes Taifersar Arahesis

Arfrever Frehtes Taifersar Arahesis 10-18-2010 01:33 AM

Patch for python.eclass
 
This patch for python.eclass is divided into 10 subpatches.

Subpatch #1 adds section header, renames a private function for consistency with other private
functions and adds unsetting of this private function after its using.

Subpatch #2 causes that dev-lang/python and sys-apps/portage don't use deprecated parts of
python_mod_optimize() and python_mod_cleanup(). This change can be safely made, because these
packages install .py files outside of site-packages directories.

Subpatch #3 adds some comments in python_mod_optimize() and python_mod_cleanup() to simplify
future work on python.eclass.

Subpatch #4 adds initial support for using of USE flags for representation of Python ABIs
in EAPI >=4. Appropriate USE flags will be automatically added to IUSE when SUPPORT_PYTHON_ABIS
variable has been set before inheriting python.eclass. python_add_abi_dependencies() function
will be used inside DEPEND/RDEPEND/PDEPEND to get appropriate dependency atoms.

Example usage:
RDEPEND="net-libs/gnutls
$(python_add_abi_dependencies ">=dev-python/PyQt4-4.7.7[svg]")
$(python_add_abi_dependencies -e "2.7 3.[2-9]" dev-python/argparse)"
DEPEND="${RDEPEND}
$(python_add_abi_dependencies dev-python/setuptools)
$(python_add_abi_dependencies -i "3.*" net-zope/zope-fixers)
test? ( $(python_add_abi_dependencies dev-python/py) )"

argparse module is included in Python 2.7 and >=3.2, so dev-python/argparse is needed only with
older Python versions. net-zope/zope-fixers is needed only with Python 3.

Subpatch #5 improves some code used in older EAPIs.

Subpatch #6 bans python_mod_compile() function (in older EAPIs), which has been deprecated for
almost 5 months (since 2010-05-25). This function isn't used in the tree.

Subpatch #7 fixes a typo in python_mod_optimize().

Subpatch #8 bans NEED_PYTHON variable (in older EAPIs), which has been deprecated for over
3 months (since 2010-07-17). This variable isn't used in the tree.

Subpatch #9 disallows not passing of paths to Python modules to python_mod_optimize() and
python_mod_cleanup(). Not passing of paths to Python modules to these functions has been
deprecated for almost 5 months (since 2010-05-25). Paths to Python modules are passed to these
functions in all ebuilds in the tree. The change in python_mod_cleanup() results in some
reindentation.

Subpatch #10 fixes exporting of python_pkg_setup() in EAPI >=4.

There will be other changes in API of python.eclass in EAPI >=4, so python.eclass still doesn't
support EAPI="4".

I'm planning to commit this patch in 1 week.

--
Arfrever Frehtes Taifersar Arahesis

Mike Frysinger 10-18-2010 07:06 AM

Patch for python.eclass
 
On October 17, 2010 21:33:20 Arfrever Frehtes Taifersar Arahesis wrote:
> Example usage:
> RDEPEND="net-libs/gnutls
> $(python_add_abi_dependencies ">=dev-python/PyQt4-4.7.7[svg]")
> $(python_add_abi_dependencies -e "2.7 3.[2-9]" dev-python/argparse)"
> DEPEND="${RDEPEND}
> $(python_add_abi_dependencies dev-python/setuptools)
> $(python_add_abi_dependencies -i "3.*" net-zope/zope-fixers)
> test? ( $(python_add_abi_dependencies dev-python/py) )"

"dependencies" is overly verbose imo. why not just use "depend" ? plus,
"add" usually means the func is the one doing the addition when this is not
the case -- the user is the one doing the addition. "python_abi_depend"
should be sufficient.

> Subpatch #5 improves some code used in older EAPIs.

does this fix Bug 340395 ?
-mike

Arfrever Frehtes Taifersar Arahesis 10-18-2010 03:10 PM

Patch for python.eclass
 
2010-10-18 09:06:06 Mike Frysinger napisał(a):
> On October 17, 2010 21:33:20 Arfrever Frehtes Taifersar Arahesis wrote:
> > Subpatch #5 improves some code used in older EAPIs.
>
> does this fix Bug 340395 ?

No. It's not related to that bug.

--
Arfrever Frehtes Taifersar Arahesis

Diego Elio Pettenò 10-18-2010 03:15 PM

Patch for python.eclass
 
Il giorno lun, 18/10/2010 alle 17.10 +0200, Arfrever Frehtes Taifersar
Arahesis ha scritto:
>
> No. It's not related to that bug.

So I guess Mike's next reply is going to be "and what are you waiting
for, before fixing it?". Seriously.

--
Diego Elio Pettenò — Flameeyes
http://blog.flameeyes.eu/


All times are GMT. The time now is 10:11 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.