[Top][All Lists]

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

Re: How can I replace Python venv and pip with Guix?

From: Tanguy Le Carrour
Subject: Re: How can I replace Python venv and pip with Guix?
Date: Tue, 4 Feb 2020 08:59:25 +0100


Le 02/02, sirgazil a écrit :
> I'm currently using two package managers when working on my projects
> written in Python. I use Guix to install Python,

Depending on your OS, you can also use Pyenv [1][] to install what
ever version of Python you like. I haven't figured out how to package it
for Guix, though.


> […] and Python pip to install

As Zelphir mentioned, you should definitively use Poetry to manage your
Python dependencies! Poetry 0.12.17 is available in Guix and version 1.0.3 is on
it's way!
Poetry manages the dependencies and the packaging. It will create the
`` with the appropriate `install_requires`.

> […]
> Emacs Elpy detects the virtual environments I create in this way, so I can
> activate and deactivate them from Emacs with an easy to use interface and
> have code completion that depends on the packages available in the active
> environment.
> I'd like to use Guix and its environments to replace this functionality and
> to make my development environments easier to reproduce, but I don't
> understand how to that exactly.
> So far I have tried the "guix environment" command as follows, trying to
> create a persistent environment I can activate/deactivate whenever I want:
> $ guix environment --pure --manifest=guix.scm 
> --root=/path/to/my-guix-envs/my-project

If you want to create a persistent environment, you should use a profile,
not the `environment` command.
There's a good cookbook entry for that [2][].


> After running that command, I can see the prompt adds a "[env]" label
> indicating that I'm in the environment, and I can use the packages specified
> in the manifest file. But
> • How could one make the prompt add "[my-project]" instead of the generic
>   "[env]"?

I would say this depends on the shell you are using. If you are a Bash
user, you have to set the PS1 variable. If you use Fish [3][], you have to set 
prompt in a config file: `~/.config/fish/functions/`
and/or `~/.config/fish/functions/`.


> • Once I deactivate this environment (Ctrl+D), how can I activate it again?

I personally use Direnv [4][] to manage this. Whenever I `cd` to a
project folder, it creates and/or activates the venv and deactivates it
when you `cd` out of it.


Using poetry + pyenv + direnv might be a bit confusing at first, but it's
really worth a try!



reply via email to

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