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

Allow installing packages from alternative index #1

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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