unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
From: Tanguy Le Carrour <tanguy@bioneland.org>
To: sirgazil <sirgazil@zoho.com>
Cc: Guix Help <help-guix@gnu.org>
Subject: Re: How can I replace Python venv and pip with Guix?
Date: Tue, 4 Feb 2020 08:59:25 +0100	[thread overview]
Message-ID: <20200204075925.mcfwd7gyzeko5lwz@rafflesia> (raw)
In-Reply-To: <170082257a9.bbf196a73697.871070894081541659@zoho.com>

Hi,

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.

[1]: https://github.com/pyenv/pyenv


> […] 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
`setup.py` 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:
> 
> #+BEGIN_EXAMPLE
> $ guix environment --pure --manifest=guix.scm --root=/path/to/my-guix-envs/my-project
> #+END_EXAMPLE

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][].

[2]: https://guix.gnu.org/cookbook/en/html_node/Guix-Profiles-in-Practice.html#Guix-Profiles-in-Practice


> 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 your
prompt in a config file: `~/.config/fish/functions/fish_prompt.fish`
and/or `~/.config/fish/functions/fish_right_prompt.fish`.

[3]: https://fishshell.com/docs/current/tutorial.html#tut_prompt


> • 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.

[4]: https://github.com/direnv/direnv/wiki/Python


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

Regards

-- 
Tanguy

  parent reply	other threads:[~2020-02-04  7:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-02 23:00 How can I replace Python venv and pip with Guix? sirgazil
2020-02-04  7:36 ` Moritz Lell
2020-02-04 13:00   ` sirgazil
2020-02-04 14:31     ` mlell
2020-02-04 18:09       ` sirgazil
2020-02-04  7:59 ` Tanguy Le Carrour [this message]
2020-02-04 14:26   ` sirgazil
2020-02-04 14:02 ` Ricardo Wurmus
2020-02-04 18:13   ` sirgazil
     [not found] <mailman.91.1580749212.18219.help-guix@gnu.org>
2020-02-03 21:09 ` Zelphir Kaltstahl
2020-02-03 22:56   ` sirgazil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200204075925.mcfwd7gyzeko5lwz@rafflesia \
    --to=tanguy@bioneland.org \
    --cc=help-guix@gnu.org \
    --cc=sirgazil@zoho.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).