[Nix-dev] Re: Python 3

Peter Simons simons at cryp.to
Fri Feb 20 13:42:22 CET 2009


Hi Marc,

 >>  (b) Patch libA to extend "sys.path" as required before trying to import
 >>      libB. It's not pretty -- particularly if libA consists of a large
 >>      number of individual files --, but it does solve the problem and
 >>      requires no user action whatsoever.
 >
 > Than we do have implicit imports.

What do you mean by "implicit imports"? My understanding is that those
libraries import each other quite explicitly, we simply add the glue
code that's necessary to ensure that those imports succeed.

 > Nicolas Pierron told us that he'd like to do
 >
 >   $ nix-env -i python python-lib-A python-lib-C # I don't want B
 >
 > which would be impossible.

Why would that be impossible? Where is the problem?


 >>  (c) Have libA create a file $out/etc/profile.d/libA.sh that sets
 >>      PYTHONPATH to include libB. This solution is rather non-intrusive
 >>      and lightweight, but it does require the user to source those
 >>      profiles to ensure that her environment is set up correctly.
 >
 > And I'm not sure wether you got the difference between PYTHONPATH
 > (unsatisfactory) and NIX_PYTHON_SITES (which does include the .pth
 > files as well).

I probably didn't. What is the difference? What exactly is it that those
*.pth files do?


  > Where is the difference making libA "import" libB compared to the
  > script doing this by setting NIX_PYTHON_SITES?

Um, we don't make libA import libB. The author of libA made it import
libB. All we need to do is to ensure that this import succeeds reliably
and deterministically. Now, adding the necessary directories to sys.path
accomplishes that, and the solution doesn't require any changes to
Python itself. The NIX_PYTHON_SITES variable, however, is not a part of
Python; it's a Nix-specific patch. I feel it's okay to patch packages if
it is necessary, but in case of Python I don't think it's necessary.
What do these *.pth files accomplish that we can't do with PYTHONPATH?

Take care,
Peter




More information about the nix-dev mailing list