Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add option to relocate prefix. #2385

Merged
merged 9 commits into from
Mar 27, 2023
Merged

Conversation

DerThorsten
Copy link
Collaborator

@DerThorsten DerThorsten commented Mar 16, 2023

Problem

Let's say we have two machines:

Alice with a homedir: /home/alice
Bob: /home/bob
Bob wants a new env at /home/bob/myenv
but we cannot create conda/mamba envs on bobs machine directly.
So we need to create the env at Alice's machine, zip it and send it to Bob.

So alice tries

  • micromamba create -p /home/bob/myenv
    But this does not work because creating /home/bob/myenv on Alice's machine is impossible.

Solution

add relocate-prefix option to the create command.

micromamba create -p /home/alice/myenv --relocate-prefix /home/bob/myenv will create all files at /home/alice/myenv but they are relocated to /home/bob/myenv
st. we can send this to Bob, and on Bob's machine, the env would behave like an env created on his machine.

Tentative "test"

This script creates and env at prefix and uses the relocate-prefix option
to relocate to prefix_relocated.
After micromamba we copy prefix to prefix_relocated

PREFIX=$(pwd)/prefix
RELOCATE_PREFIX=$(pwd)/prefix_relocated
MICROMAMBA=./bld/micromamba/micromamba

$MICROMAMBA create  \
	--prefix $PREFIX \
	--relocate-prefix=$RELOCATE_PREFIX \
	--log-level=2 --yes --verbose \
	python numpy

cp -r $PREFIX $RELOCATE_PREFIX

We then activate the env at prefix_reloacted

micromamba activate $(pwd)/prefix_relocated

this env seems to be valid and python runs fine. The prefix in python is also using the relocated path.

Python 3.11.0 | packaged by conda-forge | (main, Jan 14 2023, 12:26:40) [Clang 14.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.executable
'/Users/thorstenbeier/src/mamba/prefix_relocated/bin/python'
>>> sys.prefix
'/Users/thorstenbeier/src/mamba/prefix_relocated'
>>> import numpy
>>>

@DerThorsten DerThorsten marked this pull request as ready for review March 16, 2023 08:04
wolfv
wolfv previously requested changes Mar 16, 2023
libmamba/include/mamba/core/transaction_context.hpp Outdated Show resolved Hide resolved
@DerThorsten DerThorsten force-pushed the relocate_to branch 3 times, most recently from 9a6e2ca to caac3ff Compare March 16, 2023 09:25
@DerThorsten DerThorsten requested a review from wolfv March 16, 2023 09:26
@JohanMabille JohanMabille enabled auto-merge (squash) March 27, 2023 08:24
@JohanMabille JohanMabille dismissed wolfv’s stale review March 27, 2023 08:26

Changes required in the review have been implemented

@JohanMabille JohanMabille merged commit b7a6059 into mamba-org:main Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants