uranusjr commented on a change in pull request #16954:
URL: https://github.com/apache/airflow/pull/16954#discussion_r670870392
##########
File path: airflow/utils/python_virtualenv.py
##########
@@ -35,12 +38,44 @@ def _generate_virtualenv_cmd(tmp_dir: str, python_bin: str,
system_site_packages
return cmd
-def _generate_pip_install_cmd(tmp_dir: str, requirements: List[str]) ->
Optional[List[str]]:
+def _generate_pip_install_cmd(tmp_dir: str,
+ requirements: List[str],
+ connection_id: Optional[str] = None
+ ) -> Optional[List[str]]:
if not requirements:
return None
- # direct path alleviates need to activate
- cmd = [f'{tmp_dir}/bin/pip', 'install']
- return cmd + requirements
+
+ if connection_id:
+ con: Connection = BaseHook.get_connection(connection_id)
+ user = con.login
+ schema = con.schema or 'https'
+ password = con.get_password()
+ port = con.port or ''
+ host = con.host
+ path = con.extra_dejson.get('path', '')
+ pypi_as_fallback = con.extra_dejson.get('pypi_as_fallback', False)
+
+ if user:
+ netloc = f'{user}:{password}@{host}'
+ else:
+ netloc = host
+
+ netloc = netloc + f':{port}' if port else netloc
+
+ index_url = SplitResult(scheme=schema,
+ netloc=netloc, path=path, query='',
fragment='').geturl()
+
+ private_cmd = [f'{tmp_dir}/bin/pip',
+ 'install',
+ f'--index-url', index_url]
+
+ if pypi_as_fallback:
+ private_cmd.extend([f'--extra-index-url',
'https://pypi.org/simple'])
Review comment:
I don’t quite understand your last message, but what I can say is the
PR, as it currently stands, does not provide a good approach to set
`--extra-index-url`, and I would like Airflow to not encourage the approach.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]