Gricad / nix-ciment-channel

The CIMENT (Gricad-calcul) Nix channel
20 stars 9 forks source link

gildas: Python bindings do not work #20

Closed smaret closed 6 years ago

smaret commented 6 years ago

I get the following error when I try to start a python interpreter within gildas:

% greg
GILDAS Version: dec17a (01dec17 10:51 cet) (libexec) executable tree
Fontconfig warning: line 146: blank doesn't take any effect anymore. please remove it from your fonts.conf

 * Welcome to GREG      

 * Loaded modules
    sic (J.Pety, S.Bardeau, S.Guilloteau, E.Reynier)
    greg (J.Pety, S.Bardeau, S.Guilloteau, E.Reynier)

 * In charge:              J.Pety, S.Bardeau
   Active developers:      S.Guilloteau, E.Reynier
   Main past contributors: F.Badia,D.Brogui?re,G.Buisson,G.Duvert,
                           T.Forveille,R.Gras,R.Lucas,G.Mella,P.Valiron

 * Questions? Comments? Bug reports? Mail to: gildas@iram.fr

GREG> py
Traceback (most recent call last):
  File "/usr/lib/python2.7/site.py", line 563, in <module>
    main()
  File "/usr/lib/python2.7/site.py", line 545, in main
    known_paths = addusersitepackages(known_paths)
  File "/usr/lib/python2.7/site.py", line 272, in addusersitepackages
    user_site = getusersitepackages()
  File "/usr/lib/python2.7/site.py", line 247, in getusersitepackages
    user_base = getuserbase() # this will also set USER_BASE
  File "/usr/lib/python2.7/site.py", line 237, in getuserbase
    USER_BASE = get_config_var('userbase')
  File "/usr/lib/python2.7/sysconfig.py", line 582, in get_config_var
    return get_config_vars().get(name)
  File "/usr/lib/python2.7/sysconfig.py", line 528, in get_config_vars
    _init_posix(_CONFIG_VARS)
  File "/usr/lib/python2.7/sysconfig.py", line 412, in _init_posix
    from _sysconfigdata import build_time_vars
  File "/usr/lib/python2.7/_sysconfigdata.py", line 6, in <module>
    from _sysconfigdata_nd import *
ImportError: No module named _sysconfigdata_nd

It looks like gildas peaks the system library instead of nix's one. All gildas versions seems to be affected by this bug (I rolled back to dec17a, but the bug is present in newer versions too).

mickours commented 6 years ago

It seems that the python interpreter and package is in the nativeBuildInputs (https://github.com/Gricad/nix-ciment-channel/blob/master/ciment/gildas/default.nix#L15) which means that they are not used at run time. They should be in the buildInputs so they are available at run time. (Or maybe PropagatedbuildInputs I'm not sure...)

smaret commented 6 years ago

Thanks @mickours. I tried both buildInputs and PropagatedBuildInputs, but I still get the error.

mickours commented 6 years ago

Ok my bad I didn't understand the real problem. I though that you tool was in python but it is executing a Python interpreter at runtime.

It seems that your tool is looking inside the system python installation /usr/lib/python2.7 and not the in the PATH. Maybe you have some hard-coded path in your code that you have to patch.

smaret commented 6 years ago

Are you sure? It works fine if I install python2.7 and numpy with nix-env.

smaret commented 6 years ago

To clarify my comment above: a quick fit is to create a python27-env.nix file containing the following lines:

with import <nixpkgs> {}; 
pkgs.python27.withPackages (ps: with ps; [ numpy ])

and then install python and numpy it in a profile with nix-env -i -f python27-env.nix. This allows gildas to find the correct python version (which means that the path is not hardcoded in gildas).

Ideally, this should be done in Gildas' nix package.