guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: PYTHONPATH woes


From: Hartmut Goebel
Subject: Re: PYTHONPATH woes
Date: Thu, 22 Feb 2018 21:42:13 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0

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 address@hidden 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 address@hidden and address@hidden 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 <address@hidden>

(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          | address@hidden               |
| www.crazy-compilers.com | compilers which you thought are impossible |

reply via email to

[Prev in Thread] Current Thread [Next in Thread]