From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id iE51GMm+vl+yZQAA0tVLHw (envelope-from ) for ; Wed, 25 Nov 2020 20:30:01 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id cE5kFMm+vl8DNwAA1q6Kng (envelope-from ) for ; Wed, 25 Nov 2020 20:30:01 +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 BA234940363 for ; Wed, 25 Nov 2020 20:30:00 +0000 (UTC) Received: from localhost ([::1]:36946 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ki1QN-0007t5-My for larch@yhetil.org; Wed, 25 Nov 2020 15:29:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43676) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ki1Id-0005xd-Jw for help-guix@gnu.org; Wed, 25 Nov 2020 15:21:59 -0500 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:34886) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ki1IV-0007ti-Tg for help-guix@gnu.org; Wed, 25 Nov 2020 15:21:59 -0500 Received: by mail-wr1-x42d.google.com with SMTP id r3so3187404wrt.2 for ; Wed, 25 Nov 2020 12:21:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=beadling-co-uk.20150623.gappssmtp.com; s=20150623; h=references:user-agent:from:to:subject:in-reply-to:date:message-id :mime-version:content-transfer-encoding; bh=+Q4Eq+gQ5R1XIwEKfCRdbgyz0u89UpM3PhVzXd0MlV0=; b=nHGWKCDYYA9Bs1fIBFiTNSZemLgQMN9yVDKDt686vYWcM+iCOKKVsDZZtXmhrhWG/k 5eKyXqDXvFAHTsW4PqaSx77hqRGMWbzEXRtLa8Ny1C6qXNHQkkj/RKpnGl9i4nLz/mjz OQqyOtrleS7uZoCl/Zafxt9ORMOZRsZvipUnzlL3XflmaoxkJpiqEkGYIC89LYdG7owQ 9VVB1Zc/vq+EWCym3ur57DKlLvWPNxdwbNU8lUoSMRYR8XXqvdNerdKKRDv8PjZVPeSV N3/X2bx3SYBeelKAP87lGTKoLn0dmZWTvN+S7WLrhmpmINOaWybomS/lGvtrSildRm9A S3bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:subject :in-reply-to:date:message-id:mime-version:content-transfer-encoding; bh=+Q4Eq+gQ5R1XIwEKfCRdbgyz0u89UpM3PhVzXd0MlV0=; b=B2eax/zbY6XAQaJ+vhQS+Frc9fqS3QdvmUjcY4E/1n3g+WMCLMHOY8oAOSwBrSRgKQ bZmc65nKMuBlMQy9D3Z2gCdeI4ruyNFHzi6tD4dKXfqJTJP21LiGUMZeUqhSiL5xciXD Dk38j5Pojo4Imsq5qC8vuNHGSD89/pKrbdzBJk0UpmJacoPIdtlTm9NMnn0b7s8vNO3i 7jYdgJe26y9qVa+gc9wRB4pOiGMXQPc9gZrCzvp2URl/VaWjqT3i42vGyijBjcs2Cg0s NVVUb5+Z2hZqmbCWNr3iSeZpQNCiCWh6g+j5RcU1DLzbCSfI8zXH+KY4ggZNu7ZkP5ub 06Gg== X-Gm-Message-State: AOAM530JfNm2AoRn+sKVDZdZujRbNDd9YcnqFWySnpbq3miJDMOFAzpV MfIq2eYUAgIl5/8Q+ZHXGVvi5Pxyl5dMaWgFWT8= X-Google-Smtp-Source: ABdhPJx/osGhqQp06HH8sZHjcSu2oRjRC6KUqoEf8yqck8wkYO9LgB9ntpfWhhWfHhzrCszW5hIw4A== X-Received: by 2002:adf:f98a:: with SMTP id f10mr6091497wrr.154.1606335703996; Wed, 25 Nov 2020 12:21:43 -0800 (PST) Received: from phil-XPS-13-9360 (88-111-129-212.dynamic.dsl.as9105.com. [88.111.129.212]) by smtp.gmail.com with ESMTPSA id u81sm6328209wmb.27.2020.11.25.12.21.42 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Nov 2020 12:21:42 -0800 (PST) References: <85r1oifz56.fsf@beadling.co.uk> <86ft4ytrgd.fsf@gmail.com> User-agent: mu4e 1.2.0; emacs 26.3 From: Phil To: zimoun , help-guix@gnu.org Subject: Re: Replacing python venv - environment or profile? In-reply-to: <86ft4ytrgd.fsf@gmail.com> Date: Wed, 25 Nov 2020 20:21:41 +0000 Message-ID: <858sapqjai.fsf@beadling.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: none client-ip=2a00:1450:4864:20::42d; envelope-from=phil@beadling.co.uk; helo=mail-wr1-x42d.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 25 Nov 2020 15:29:52 -0500 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=beadling-co-uk.20150623.gappssmtp.com header.s=20150623 header.b=nHGWKCDY; dmarc=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: -0.21 X-TUID: 86LJ/YOgHLQ6 Thanks Simon for the helpful comments - everything's hopefully clicked now = - some comments inline. zimoun writes: > Well roughly, an environment is a temporary profile. So, in the Python > terminology, the =E2=80=9Cenvironment=E2=80=9D corresponds to the Guix pr= ofile. And the > Guix environment does not have an equivalent in the Python terminology, > AFAIK. Yes - I think it was the fact 'guix environment' had the '--pure' flag that initially drew me in to consider this to be the parallel with Python's virtual environment (and the original blog nudged me in that direction too). > 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. Yes this makes perfect sense to me, I guess what I was missing was that a 'guix environment' is just a temporary and special case of sourcing a Guix profile. However the "--pure" switch means it has a useful feature that originally I didn't appreciate was available when sourcing a profile by using "--search-paths=3Dexact" - note: the penny dropped for me below when = reading your e-mail, I've removed some of my own comments here about "--pure" now that I understand it is not the only way to get a clean environment from a profile! > guix install python python-mypy -p ~/my-first-profile > > > The big difference is =E2=80=9Cguix pull=E2=80=9D. Well, imagine this se= quence: > > 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, Yep you're creating two separate environments each taken from the current 'latest' python version. Which may have been updated by guix pull for example. > > 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. Yes - I get this now. The eval trick is nice. >> $ guix environment --pure --manifest=3Dmanifest.scm --root=3D./test-prof= ile > > I am not convinced you need the --root at first. This is purely a way of creating a pure environment from a manifest, and creating a profile from that same manifest as a one-liner (to pin the packages in the store). If you'd previously created a profile with the same manifest this would be unnecessary. > This create a environment, not a profile. For a profile, you should do: > > guix package -m manifest.scm -p ./test-profile Yep - so this does the same thing as the above, but doesn't then put me into a 'guix environment' referencing the same pacakges as the test-profile does. > >> 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. Ah-ha! Now the penny has dropped - this was the piece of the puzzle I had missed! $ guix package --search-paths=3Dexact -p ./test-profile export PATH=3D"./test-profile/bin" export EMACSLOADPATH=3D"./test-profile/share/emacs/site-lisp:./test-profile= /share/emacs/27.1/lisp" export INFOPATH=3D"./test-profile/share/info" export PYTHONPATH=3D"./test-profile/lib/python3.8/site-packages" So, if I instantiate the environment using "--search-paths=3Dexact" then I get *pure* environment variables, rather than appending or prepending to the current variables. So using this I don't need "guix environment --pure" anymore! Which was what I wanted. > 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 This is snapshotting not just my manifest, but also the exact state of the Guix commands themselves - so the environment and the tooling for that environment are both replicated? > >> 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 Yes agreed - let's discuss later, I just wanted to give the group a vague idea of where I'm hopefully ultimately heading with my Guix use, but I must walk before I run!