Hi,

Am 22.02.2018 um 16:30 schrieb Ricardo Wurmus:
re 2): As soon as Python2 and Python3 are installed in the same profile,
we put both site-packages for both versions into PYTHONPATH, which
obviously is wrong.

$ PYTHONPATH= guix environment --ad-hoc python@2 python
[…]
[guix] $ echo $PYTHONPATH
/gnu/store/jkwp041kjy6li85n66ymxkfrr0hr2psj-profile/lib/python2.7/site-packages:/gnu/store/jkwp041kjy6li85n66ymxkfrr0hr2psj-profile/lib/python3.5/site-packages:

A simple work-around would be to make the profile a (pseudo) virtual
environment, which is a easy as creating a file
"/gnu/store/…-profile/pyvenv.cfg". This will trigger a mechanism in
site.py to insert /gnu/store/…-profile/lib/pythonX.Y/site-packages" into
sys.path - for the current python version only!
This is very good to know.  I haven’t tested this (as I’m not editing
the store by hand), but I suppose we could create an empty pyvenv.cfg in
a profile hook when Python packages are installed.

Below please find a simple package which adds this hack. After installing it, unset PYTHONPATH:
export PYTHONPATH=

In the long run both python@2 and python@3 could propagate this hack-package, thus is would be installed whenever python is installed. (This need further investigation or a guix guru to help.)

(This wouldn’t help us much for wrapper scripts, though.)

I have another hack in petto :) But one step at a time :-)


Now here is the

cat > guix-python-venv-hack.scm <<"EOF"
;;; Copyright © 2018 Hartmut Goebel <h.goebel@crazy-compilers.com>

(use-modules (guix)
             (guix build-system trivial)
             (guix licenses))

(package
  (name "guix-python-venv-hack")
  (version "0.1")
  (source #f)
  (build-system trivial-build-system)
  (arguments
   `(#:modules ((guix build utils))
     #:builder
     (begin
       (use-modules (guix build utils))
       (let* ((out       (assoc-ref %outputs "out"))
              (pyvenv.cfg (string-append out "/pyvenv.cfg")))
         (mkdir-p out)
         (call-with-output-file pyvenv.cfg
           (lambda (p)
             (format p "#")))
         ;;(chmod index.php #o555)
         ))))
  (synopsis "Python venc-hack for Guix")
  (description "See ...")
  (home-page #f)
  (license gpl3+))
EOF
guix package --install-from-file guix-python-venv-hack.scm
unset PYTHONPATH
-- 
Regards
Hartmut Goebel

| Hartmut Goebel          | h.goebel@crazy-compilers.com               |
| www.crazy-compilers.com | compilers which you thought are impossible |