Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create virtual environment with python interpreter #30

Open
mschneiderwng opened this issue Feb 8, 2022 · 1 comment
Open

Create virtual environment with python interpreter #30

mschneiderwng opened this issue Feb 8, 2022 · 1 comment

Comments

@mschneiderwng
Copy link

For PyCharm I need a (pseudo) virtual env which includes the python interpreter. For example, with mach-nix I can create an environment with the following content:

 venv
├──  bin
│  ├──  python3.9
│  └──  python3.9-config
├──  include -> /nix/store/dn4fwp0yx6nsa85cr20cwvdmg64xwmcy-python3-3.9.9/include
├──  lib
│  ├──  pkgconfig -> /nix/store/dn4fwp0yx6nsa85cr20cwvdmg64xwmcy-python3-3.9.9/lib/pkgconfig
│  ├──  python3.9
│  ├──  libpython3.9.so -> /nix/store/dn4fwp0yx6nsa85cr20cwvdmg64xwmcy-python3-3.9.9/lib/libpython3.9.so
│  ├──  libpython3.9.so.1.0 -> /nix/store/dn4fwp0yx6nsa85cr20cwvdmg64xwmcy-python3-3.9.9
│  └──  libpython3.so -> /nix/store/dn4fwp0yx6nsa85cr20cwvdmg64xwmcy-python3-3.9.9/lib/libpython3.so
└──  share -> /nix/store/dn4fwp0yx6nsa85cr20cwvdmg64xwmcy-python3-3.9.9/share

However, env.out only contains the python-packages, e.g.

 result
├──  matplotlib -> /nix/store/sk6yh7jm14l20i5yvq7s1i42llj818l4-matplotlib-3.4.3-python38-out
├──  numpy -> /nix/store/rwsiy56hgljf7qm50havh22bx18g0b4l-numpy-1.21.2-python38-out
└──  threadpoolctl -> /nix/store/xqpc4pdcil4i80myf8s6yghjrli0zpn6-threadpoolctl-2.2.0-python38-out

Is it possible to create a derivation with a kind of virtual environment (interpreter and structure as expected from a venv) usable with IDEs like PyCharm?

@kamadorueda
Copy link
Member

@mschneiderwng thanks for the suggestion

Now the out output contains the virtual environment, like this:

[nix-shell:/data/python]$ nix build github:on-nix/python#pytest-latest-python39-out

[nix-shell:/data/python]$ tree -L 4 result
result
├── bin
│   ├── py.test -> /nix/store/ksnk8d5rj6cc8awji39nx64llzx5n4ix-pytest-latest-python39-out/bin/py.test
│   ├── pytest -> /nix/store/ksnk8d5rj6cc8awji39nx64llzx5n4ix-pytest-latest-python39-out/bin/pytest
│   ├── python -> /nix/store/aabk6mghmkzfnvlmlx4f2s6h1280gnmi-pytest-latest-python39-out-python/bin/python
│   ├── python3.9 -> /nix/store/aabk6mghmkzfnvlmlx4f2s6h1280gnmi-pytest-latest-python39-out-python/bin/python3.9
│   └── python3.9-config -> /nix/store/aabk6mghmkzfnvlmlx4f2s6h1280gnmi-pytest-latest-python39-out-python/bin/python3.9-config
└── lib
    └── python3.9
        └── site-packages
            ├── atomicwrites
            ├── atomicwrites-1.4.0.dist-info
            ├── attr
            ├── attrs-21.2.0.dist-info
            ├── colorama
            ├── colorama-0.4.4.dist-info
            ├── iniconfig
            ├── iniconfig-1.1.1.dist-info
            ├── packaging
            ├── packaging-21.0.dist-info
            ├── pluggy
            ├── pluggy-1.0.0.dist-info
            ├── py
            ├── py-1.10.0.dist-info
            ├── pyparsing-2.4.7.dist-info
            ├── pyparsing.py -> /nix/store/vs5dwbmni40z91kiz4pynp86jw01q87v-pyparsing-2.4.7-python39-out/lib/python3.9/site-packages/pyparsing.py
            ├── _pytest
            ├── pytest
            ├── pytest-6.2.5.dist-info
            ├── toml
            └── toml-0.10.2.dist-info

24 directories, 6 files

can you help me confirm if it works as you expected?

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

No branches or pull requests

2 participants