public inbox for gentoo-python@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-python] Replacing python-wrapper with python-exec
@ 2012-10-31  9:17 Michał Górny
  2012-10-31 17:07 ` Mike Gilbert
  0 siblings, 1 reply; 3+ messages in thread
From: Michał Górny @ 2012-10-31  9:17 UTC (permalink / raw
  To: gentoo-python

[-- Attachment #1: Type: text/plain, Size: 1793 bytes --]

Hello,

Now that python-exec spawns random Python scripts happily, I think we
can consider replacing python-wrapper (the one that spawns Python
itself) with it as well. The idea is similar, and the code is much
simpler here.

However, a bit of hackery would need to be done to change python-exec's
behavior. Right now, it spawns "$0-$EPYTHON" but it will need to just
spawn "$EPYTHON" when run as 'python'. I think we can do it in one
of the following ways:


1) add an 'if' clause to the code, looking for argv[0]~=python.

Simply saying, if python-exec is run as python, just run $EPYTHON,
without prepending $0-. As simple as it can be.

Pros:

- a simple solution.

Cons:

- potentially fragile -- check relies on argv[0]; someone symlinks it
  to a different name -- boom;

- the 'if' check done for every other script where it is irrelevant.


2) add '-$EPYTHON' symlinks to the python interpreters.

So:
  /usr/bin/python-python2.7 -> python2.7
  /usr/bin/python-python2.6 -> python2.6
  /usr/bin/python-pypy-c1.9 -> pypy-c1.9

Pros:

- will work with python-exec as-is.

Cons:

- $PATH pollution.

Note: if we ever wanted to replace Python implementations with
additional wrappers (e.g. trying to fix bug #438984[1]) the 'long
names' could carry the actual Python executables. But that's probably
a bad idea anyway.

[1]:https://bugs.gentoo.org/show_bug.cgi?id=438984


3) add an '#if' clause and build the Python-relevant code conditionally.

In other words, let python-exec install both regular 'python-exec'
and the 'python' binary built from the same code with '#if' switched.

Pros:

- still simple, and clean.

Cons:

- two executables installed.


What are your thoughts?

-- 
Best regards,
Michał Górny

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 316 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [gentoo-python] Replacing python-wrapper with python-exec
  2012-10-31  9:17 [gentoo-python] Replacing python-wrapper with python-exec Michał Górny
@ 2012-10-31 17:07 ` Mike Gilbert
  2012-11-01 22:09   ` Michał Górny
  0 siblings, 1 reply; 3+ messages in thread
From: Mike Gilbert @ 2012-10-31 17:07 UTC (permalink / raw
  To: Michał Górny; +Cc: gentoo-python

On Wed, Oct 31, 2012 at 5:17 AM, Michał Górny <mgorny@gentoo.org> wrote:
> 3) add an '#if' clause and build the Python-relevant code conditionally.
>
> In other words, let python-exec install both regular 'python-exec'
> and the 'python' binary built from the same code with '#if' switched.
>
> Pros:
>
> - still simple, and clean.
>
> Cons:
>
> - two executables installed.
>
>
> What are your thoughts?
>

If others agree that replacing python-wrapper is a good idea to begin
with, this option would be my choice.

FYI, bypassing the setenv(GENTOO_PYTHON_PROCESS_NAME, ...) that is set
in python-wrapper.c could cause issues with python-based daemons
called from init scripts. If a pidfile is not used, openrc might not
be able to find the right process. However, a pidfile seems to be a
better solution for that anyway.

I'm sure djc would love to drop that patch from our dev-lang/python patchset.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [gentoo-python] Replacing python-wrapper with python-exec
  2012-10-31 17:07 ` Mike Gilbert
@ 2012-11-01 22:09   ` Michał Górny
  0 siblings, 0 replies; 3+ messages in thread
From: Michał Górny @ 2012-11-01 22:09 UTC (permalink / raw
  To: Mike Gilbert; +Cc: gentoo-python

[-- Attachment #1: Type: text/plain, Size: 1721 bytes --]

On Wed, 31 Oct 2012 13:07:17 -0400
Mike Gilbert <floppym@gentoo.org> wrote:

> On Wed, Oct 31, 2012 at 5:17 AM, Michał Górny <mgorny@gentoo.org> wrote:
> > 3) add an '#if' clause and build the Python-relevant code conditionally.
> >
> > In other words, let python-exec install both regular 'python-exec'
> > and the 'python' binary built from the same code with '#if' switched.
> >
> > Pros:
> >
> > - still simple, and clean.
> >
> > Cons:
> >
> > - two executables installed.
> >
> >
> > What are your thoughts?
> >
> 
> If others agree that replacing python-wrapper is a good idea to begin
> with, this option would be my choice.

Well, I don't see much of a point to have two wrappers which serve
almost the same purpose with the main difference being that one does it
the simple almost-dumb way, and the other implementing a piece of
package manager inside.

> FYI, bypassing the setenv(GENTOO_PYTHON_PROCESS_NAME, ...) that is set
> in python-wrapper.c could cause issues with python-based daemons
> called from init scripts. If a pidfile is not used, openrc might not
> be able to find the right process. However, a pidfile seems to be a
> better solution for that anyway.
> 
> I'm sure djc would love to drop that patch from our dev-lang/python patchset.

I'd love to get rid of all that GENTOO_* stuff as well. If they serve
a real purpose, that means we're doing something just horribly wrong.

In any case, do I understand correctly that python-exec does break all
those packages anyway? We may simply decide to wait till it gets more
wide-spread (and thus packages get fixed to work with it) before
replacing python-wrapper.

-- 
Best regards,
Michał Górny

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 316 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-11-01 22:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-31  9:17 [gentoo-python] Replacing python-wrapper with python-exec Michał Górny
2012-10-31 17:07 ` Mike Gilbert
2012-11-01 22:09   ` Michał Górny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox