From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id zmtbFAZyvV9XJAAA0tVLHw (envelope-from ) for ; Tue, 24 Nov 2020 20:50:14 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id EIu5DwZyvV8QNQAAB5/wlQ (envelope-from ) for ; Tue, 24 Nov 2020 20:50:14 +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 91B7B9404C8 for ; Tue, 24 Nov 2020 20:50:13 +0000 (UTC) Received: from localhost ([::1]:36170 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khfGN-0007SO-4f for larch@yhetil.org; Tue, 24 Nov 2020 15:50:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41152) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khfFu-0007SF-Sh for help-guix@gnu.org; Tue, 24 Nov 2020 15:49:42 -0500 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]:38613) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1khfFs-0008N2-U1 for help-guix@gnu.org; Tue, 24 Nov 2020 15:49:42 -0500 Received: by mail-wm1-x332.google.com with SMTP id 1so235138wme.3 for ; Tue, 24 Nov 2020 12:49:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:in-reply-to:references:date:message-id:mime-version :content-transfer-encoding; bh=WGrvcqMgysf1/IdPlSy/O58j0uAYFuBJKJHvMiO2F1E=; b=fyUtT6Z79LFxpGOQaQTksFgUm/x+KTiia5QXEvwk+18JGWFFPrvYNKXffntIFxLTmY 6WwvRQ2VrbX8QlCZfoFoZryx/gjRj4iuKf4MDNspsqgaA8mavergPkjSAER09XsGDiHV dwc9g0SluipP7WH1in2rcad/Sy/PrMNrqLe+I7vY82hCMaHQqOx8+Fif+z8i1jPMLR01 FmA5bP0wjWFnfpXGnJ6dj0YGoPyO/l6V31k1TmeXAzuKe9XZUUFEkPKz13o+sAF1Vg7P Y4wAockvQzEWOAbaolmYqTS259x8LSMnwED7/1cshaak6gtKeQs7/qqSYMcpggtkmYW7 P/XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:in-reply-to:references:date :message-id:mime-version:content-transfer-encoding; bh=WGrvcqMgysf1/IdPlSy/O58j0uAYFuBJKJHvMiO2F1E=; b=aPJ0SGME6pTImhdVkXLKHicMGIqG4XtAzoiybI3jTa8/FQlkCuylQlQfBxDMT00PHr BrXYv3gzwRjHz8TjsMz/6xwheMeQGLxuQ927UD9MgpecPeOiLakw+9IVY2DLFEwZGlHQ uLyUQzsQNQT+6fuaR60xD1I6XcziPU1HZakFEFNkMH44RTIIrWAn5dhK8PNvpkB06q7x ck1qrInOJ6JwSa0VTYu7AfJ97TQDMu8hQ2N+Yhwpxne7S5b3wvnaduew0JLB3WewXTro OuXwXgebvVhha931LNCgGl1clOilKWtC5/JMQ2fH5h3vgkUzhRPbfNA5NlhPzmPaEBfc 4LkA== X-Gm-Message-State: AOAM533aIRMu+Krq1IgRJ4FqWNwQvTP7cGCm39yETCdPjXJ0LdzVWa9a 6Qo3u+iG/c17EyERQ/y1QX6AxI3Lb93T9Q== X-Google-Smtp-Source: ABdhPJwH+vZNJ2ivgphf8ugg0fiTJqDtJxeoGIRphHUFI6XgiFAXICLZKCjVNeVkNBgUvs3bgj5tjQ== X-Received: by 2002:a1c:61c5:: with SMTP id v188mr205153wmb.141.1606250978750; Tue, 24 Nov 2020 12:49:38 -0800 (PST) Received: from lili ([2a01:e0a:59b:9120:65d2:2476:f637:db1e]) by smtp.gmail.com with ESMTPSA id s4sm93961wro.10.2020.11.24.12.49.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Nov 2020 12:49:38 -0800 (PST) From: zimoun To: Phil , help-guix@gnu.org Subject: Re: Replacing python venv - environment or profile? In-Reply-To: <85r1oifz56.fsf@beadling.co.uk> References: <85r1oifz56.fsf@beadling.co.uk> Date: Tue, 24 Nov 2020 21:44:50 +0100 Message-ID: <86ft4ytrgd.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=zimon.toutoune@gmail.com; helo=mail-wm1-x332.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, 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 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: , 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=pass header.d=gmail.com header.s=20161025 header.b=fyUtT6Z7; dmarc=pass (policy=none) header.from=gmail.com; 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: -0.71 X-TUID: wF1wyc3Jrcq4 Hi Phil, On Tue, 24 Nov 2020 at 17:22, Phil wrote: > 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. Nice! > 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, an= d I > want to make sure my use is correct from the get-go. Initially, coming from Python terminology, I was confused too. Well roughly, an environment is a temporary profile. So, in the Python terminology, the =E2=80=9Cenvironment=E2=80=9D corresponds to the Guix prof= ile. And the Guix environment does not have an equivalent in the Python terminology, AFAIK. > 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. No, it should change nothing. IIUC. > > As well as the manual cookbook I came across this blog: > https://trivialfis.github.io/linux/2018/06/10/Using-guix-for-development.= html Thanks for the pointer. I have not read it yet. > I understand that I can use the --pure switch to ensure no pollution To understand the difference between =E2=80=99--pure=E2=80=99 or not: $ guix environment --ad-hoc python [env] $ echo $PATH vs $ guix environment --ad-hoc python --pure [env] $ echo $PATH And this is done for all the environment variables. > This is great - but the manual points out that none of the > installed packages are marked such that they avoid garbage collection. The Guix environment are temporary. Compare: a $ guix environment --ad-hoc hello -- hello b $ guix gc --list-dead | grep hello c $ guix gc --list-live | grep hello d $ guix install hello e $ guix gc --list-dead | grep hello f $ guix gc --list-live | grep hello The a create a temporary profile (environment) containing the package hello and then the program hello is run inside. The b lists all the items in the store that are not used by any profile, so they could be garbage collected because nothing need them. The c lists all the live items, i.e, all the item used by one or more profile, so they cannot be garbage collected. The d installs hello in the default profile (~/.guix-profile), so now the e shows nothing because one profile uses it and the f shows. Does it make sense? The next point is that you can create any profile (as the Python environment). For example, guix install python python-mypy -p ~/my-first-profile The big difference is =E2=80=9Cguix pull=E2=80=9D. Well, imagine this sequ= ence: guix environment --ad-hoc python [..work..] guix pull guix environment --ad-hoc python Now, the first Python is not necessary the exact same than the second one. Considering the sequence, guix install python -p /my-profile [..work..] guix pull eval $(guix package --search-paths=3Dprefix -p ~/my-profile) The Python inside your profile ~/my-profile has not changed. > So I came up with something like the below - manifests do seem to be an > exact analogy to Python requirements.txt files: Yes, manifest.scm is equivalent to requirements.txt. The only difference is that power because it is possible to write Scheme inside this file and so apply package transformation, create on-the-fly package variant, etc. Well, another story. :-) > $ cat manifest.scm=20 > (specifications->manifest > '("coreutils" > "emacs@27.1" > "python" > "python-pytest" > "python-coverage" > "python-pytest-cov" > "python-black" > "python-mypy" > "python-flake8")) > $ guix environment --pure --manifest=3Dmanifest.scm --root=3D./test-profi= le I am not convinced you need the --root at first. > This creates a profile as a side-effect, I think. This create a environment, not a profile. For a profile, you should do: guix package -m manifest.scm -p ./test-profile > 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 Yes. > use of Python virtual environment? Useful, but different. The 'guix > environment' is accidentally providing a closer parallel. AFAIK, the Guix environment has no equivalent. For example, you can create a Guix environment in a container; --pure on steroids. :-) > 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? Profile and then the correct --search-paths. But if you want crazy isolation with container, you can do: guix describe -f channels > my-channels.scm then any point in time, you will have the exact same environment with: guix time-machine -C my-channels -- environment -C -m my-manifest.scm > 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 That=E2=80=99s a bigger story=E2=80=A6 > 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 f= eatures > of Guix to use to do this. =E2=80=A6so let=E2=80=99s discuss it once you are comfortable with Guix on = your local machine. ;-) All the best, simon