Skip to content
This repository has been archived by the owner on Jul 21, 2022. It is now read-only.

Importing local relative paths does not work #18

Open
djacu opened this issue Jul 20, 2022 · 1 comment
Open

Importing local relative paths does not work #18

djacu opened this issue Jul 20, 2022 · 1 comment

Comments

@djacu
Copy link

djacu commented Jul 20, 2022

I am trying to use pythonix to import some local files and run some unit tests. However, it doesn't seem to parse relative paths properly. All of these methods work in the Nix REPL.

>>>import nix

>>> nix.eval('with import ./math.nix; isEven 2')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
nix.NixError: not an absolute path: '././math.nix'

>>> nix.eval('with import (./. + "math.nix"); isEven 2')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
nix.NixError: not an absolute path: '././.'

>>> nix.eval('with import (builtins.toString ./math.nix); isEven 2')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
nix.NixError: not an absolute path: '././math.nix'
@Mic92
Copy link
Owner

Mic92 commented Jul 20, 2022

I am not really using this project anymore and it would require some porting changes to newer nix apis.
You can also use the nix eval --json --expr to get json output from nix and use the python json library to parse it again.
This is how I actually end up doing it in all my python projects. https://github.com/Mic92/nix-update/blob/3143af043d4324ee4c6a91ff7294c5c34fe459b6/nix_update/eval.py#L77

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants