Skip to content

Commit

Permalink
Merge pull request #1 from European-XFEL/index-url
Browse files Browse the repository at this point in the history
Allow installing packages from alternative index
  • Loading branch information
takluyver authored Dec 6, 2024
2 parents dde7a11 + 69e2117 commit 8ecfd7b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions env_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,10 @@ def make_env(self, env_dir, py_version):


class EnvsManager:
def __init__(self, path: Path, env_maker: EnvMaker):
def __init__(self, path: Path, env_maker: EnvMaker, index_url=None):
self.path = path
self.env_maker = env_maker
self.index_url = index_url

(path / '.envs').mkdir(parents=True, exist_ok=True)

Expand Down Expand Up @@ -148,7 +149,10 @@ def get_env(self, py_version, reqs: str):
reqs_txt.write_text(reqs, 'utf-8')
print("Installing packages with pip....")
env_python = real_env_dir / 'bin' / 'python'
run([env_python, '-m', 'pip', 'install', '-r', reqs_txt], check=True)
pip_cmd = [env_python, '-m', 'pip', 'install', '-r', reqs_txt]
if self.index_url is not None:
pip_cmd += ['--index-url', self.index_url]
run(pip_cmd, check=True)
new_link = real_env_dir.with_suffix('.link')
new_link.symlink_to(real_env_dir)
new_link.replace(env_dir)
Expand Down

0 comments on commit 8ecfd7b

Please sign in to comment.