From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id SNpcDe5svl9mXAAA0tVLHw (envelope-from ) for ; Wed, 25 Nov 2020 14:40:46 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id mNwsCe5svl98LAAAbx9fmQ (envelope-from ) for ; Wed, 25 Nov 2020 14:40:46 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 6C34594023A for ; Wed, 25 Nov 2020 14:40:45 +0000 (UTC) Received: from localhost ([::1]:36930 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khvyO-0002GN-6D for larch@yhetil.org; Wed, 25 Nov 2020 09:40:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60182) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khvw0-0000KN-CA for help-guix@gnu.org; Wed, 25 Nov 2020 09:38:17 -0500 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]:38773) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1khvvx-00011L-8m for help-guix@gnu.org; Wed, 25 Nov 2020 09:38:16 -0500 Received: by mail-ej1-x62b.google.com with SMTP id a16so3328360ejj.5 for ; Wed, 25 Nov 2020 06:38:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=btuaufuW4sX5lB73ZXjgyb+xlcSDCsfDWQixaH1zADE=; b=mvtB5qhRs1WUwvN8YQMCUi7aVYxY0fktRk2cdn8eaCjHq35LVwmz8Cv7Yk98x24pvy TbGRbWN5KtfWy728ZWBmr83xOoVoQyBbNgZwwvYaUu2uMTkghzmP6fVYWY8D/dSTFjGT cQTy7ZLJhcJUN7bACczgrPdsDEOaIEVjJqk1wLbbvD+b/XFd+V13ilPzhrB7TNyjxSFG ohbX0zGhqhDaoqCwoLqqq0oOLcMVdQHAtBRugJuKUZDAOIOqXOWymz/p18Ia13LKFzla qQ8HrBIvFRXqYlhvwk5bfStpC5TBLTxM59L6Ysg4HXqnDDKJDjrUN19vP1rDoRQ2o+hc iMUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=btuaufuW4sX5lB73ZXjgyb+xlcSDCsfDWQixaH1zADE=; b=t/TURAnMRmlIbx+OvECZKFwA+w4Aj+euD7xjv/BWYtRmhdeksyLFRQpuQ0fkPiCGuh BHpn1GOWB9svb8IaRU/qse9jo+A3wpkxM+n5s4KTNoRwQ45MPDqDHfios9juni0tLMcP HUmSsQ2jXXWs5CzN/MUpM7ggwRF8yWPTSmgxmhtvMOCAktHGihdo9V6Bu43oZazF/UKv bMGW1YOY/ufPKgXb6czvBTpE7s8pEBxGMaT+vqzMQjEyE7z3aPASImdcp6YBz0TiYCjM oZRLGz2JuAkZUWZvTAcahdkPe3nJXSCvLRC9BFQ62L3YENrN3oyoqo+FNnukYF/Zl8OK HsNQ== X-Gm-Message-State: AOAM5329boJfIqKxQj6lo00OY63cE1VR0Gd+MJZTZNbztk2pbm2h1ryW gCI8VsobmlnQ4eGcWwEDiakLM5pwTOXy3kcTtm4= X-Google-Smtp-Source: ABdhPJxowRl2yG+/XN3tOzCDQIORgcKO0uzCDE+QJFZvNAM3HZof2wyuxk6R2m2xpp2vBFNgDo2f4MxurZnSoV4QEkk= X-Received: by 2002:a17:906:892:: with SMTP id n18mr3395350eje.1.1606315090990; Wed, 25 Nov 2020 06:38:10 -0800 (PST) MIME-Version: 1.0 References: <85r1oifz56.fsf@beadling.co.uk> In-Reply-To: <85r1oifz56.fsf@beadling.co.uk> From: Christopher Lam Date: Wed, 25 Nov 2020 14:37:44 +0000 Message-ID: Subject: Re: Replacing python venv - environment or profile? To: Phil Received-SPF: pass client-ip=2a00:1450:4864:20::62b; envelope-from=christopher.lck@gmail.com; helo=mail-ej1-x62b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: help-guix@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: help-guix@gnu.org Errors-To: help-guix-bounces+larch=yhetil.org@gnu.org Sender: "Help-Guix" X-Scanner: ns3122888.ip-94-23-21.eu Authentication-Results: aspmx1.migadu.com; dkim=fail (body hash did not verify) header.d=gmail.com header.s=20161025 header.b=mvtB5qhR; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of help-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=help-guix-bounces@gnu.org X-Spam-Score: 1.09 X-TUID: POt5HX9GgR14 No constructive comments here, except a thank you for sharing an incremental tutorial on using guix. Sorely needed: - similar incremental tutorial for C based projects. - similar tutorial for other text editors eg vscode On Tue, 24 Nov 2020 at 18:35, Phil wrote: > Hi all, > > Apologies this is a bit longer than I anticipated, but I wanted to record > all the steps I'd taken to explain my reasoning - in case it's wrong! > > I'm new the Guix and considering adopting it as an expansion to my > current use of Python virtual environments in development and > production, to include other non-Python packages too. > > The potential of the software is very exciting! > > I've read the manual/cookbook and I get the gist of the tool. One thing > I'm getting a bit stuck on is the appropriate use of environment vs > profile; different sources give slightly different takes on the theme, and > I > want to make sure my use is correct from the get-go. > > I'll be using Guix on a foreign OS, I suspect the answers might be > slightly different if I was able to adopt the Guix System OS, but for > now I can't. > > As well as the manual cookbook I came across this blog: > > https://trivialfis.github.io/linux/2018/06/10/Using-guix-for-development.html > > This is describing the use of 'guix environment' and manifests to create a > structure very similar to a python virtual environment, but including > the python package itself too. Which is exactly the starting point I had > in mind. > > I understand that I can use the --pure switch to ensure no pollution > from the foreign OS programs - just like the default behaviour of python > venv, eg: > > ubuntu@primary:~$ guix environment --ad-hoc coreutils --pure > > ubuntu@primary:~$ ls > dev > ubuntu@primary:~$ nano > Command 'nano' is available in the following places > * /bin/nano > * /usr/bin/nano > The command could not be located because '/bin:/usr/bin' is not included > in the PATH environment variable. > nano: command not found > > > This is great - but the manual points out that none of the > installed packages are marked such that they avoid garbage collection. > > So I came up with something like the below - manifests do seem to be an > exact analogy to Python requirements.txt files: > > $ cat manifest.scm > (specifications->manifest > '("coreutils" > "emacs@27.1" > "python" > "python-pytest" > "python-coverage" > "python-pytest-cov" > "python-black" > "python-mypy" > "python-flake8")) > $ guix environment --pure --manifest=manifest.scm --root=./test-profile > > This creates a profile as a side-effect, I think. > > This would be all well and good but both the manual and the cookbook, > and a few other sources I've found online seem to equate a *profile* with > a virtualenv rather than use of the *guix environment* command. > > To test this as an alternative, I source the profile created by the > manifest above: > > $ export GUIX_PROFILE=/home/ubuntu/dev/test-profile > $ . $GUIX_PROFILE/etc/profile > > I note that unlike the environment which creates what I assume is its > own temporary profile, eg: > > $ echo $PATH > /gnu/store/hchmga9ybpdc4zph9cs8jr7m1k8gxw9f-profile/bin > > Sourcing the created profile references both it, the default profile, > and guix's profile, followed by the foreign OS PATH variables: > > $ echo $PATH > > /home/ubuntu/dev/test-profile/bin:/home/ubuntu/.guix-profile/bin:/home/ubuntu/.config/guix/current/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin > > > I'm keen to avoid accidentally calling anything in the foreign OS, > something the 'guix environment' command gives me, but obviously the > foreign > OS will serve as a fallback given the above PATH construction under a > sourced > profile. So if my profile doesn't have python installed, but it is part > of the foreign OS, I would silently pick that up, which would be bad. > > > As per 4.1.1 in the cookbook I can avoid setting other profiles using: > > $ env -i $(which bash) --login --noprofile --norc > $ export GUIX_PROFILE=/home/ubuntu/dev/test-profile > $ . $GUIX_PROFILE/etc/profile > > But the foreign OS variables remain: > > $ echo $PATH > > /home/ubuntu/dev/test-profile/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin > $ > > So to my mind Guix profiles are more like Python virtual environments with > the with the non-standard --system-site-packages switch than the classic > use of Python virtual environment? Useful, but different. The 'guix > environment' is accidentally providing a closer parallel. > > I'm guessing that if I used the Guix System OS the profile analogy would > be much > more accurate as there would be no foreign OS to fallback onto? > > Finally.... I get to my question! So in light of the above (assuming I > haven't missed the point completely!), what is the canonical way of > isolating a virtual environment using Guix on a foreign OS installation? > > Is the use of 'guix environment' as per the blog referenced above > considered good practice, or is this as I now suspect, inappropriate > re-purposing of a > feature designed to create transient environments for building/debugging > specific > programs packaged in Guix? > > Links such as this suggest this might be the case: > > https://yhetil.org/guix-user/1700d451826.11317682011034.4058430466276292306@zoho.com/T/ > > Of course I could probably write a script that scrubs my own > environment variables of all references to the foreign OS, but this feels > like I'm doing what I thought I'd get for free with Guix in the first > place? > > Last point - ultimately as well as using Guix to provide a consistent > profile/environment to do Python work in, I'd ultimately > like to hook Guix up to Jenkins so that it can package and deploy a repo > to a > production server. This probably involves setting-up a private Guix > Channel and importing built wheels, and to then pull the new Guix package > from the > production server. Ultimately tho I'd want the same thing - a pure > environment in production which has access to exactly and only the > software as described in the manifest. This feels like it should be > possible too, but again, just looking for any initial guidance on which > features > of Guix to use to do this. > > Sorry for the long e-mail, and thanks in advance for any guidance > or advice on the matter! > > > Cheers, > Phil. > >