Skip to content

Commit

Permalink
Fix deprecated provider aliases (#15465)
Browse files Browse the repository at this point in the history
Deprecated provider aliases (e.g. kubernetes -> cncf.kubernetes) should
install the provider package (e.g.  apache-airflow-provider-cncf-kubernetes)
by default, not the requirements for the provider package. This behavior
was accidentally broken.
  • Loading branch information
jedcunningham authored Apr 21, 2021
1 parent 5da74f6 commit fdea622
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from distutils import log
from os.path import dirname, relpath
from textwrap import wrap
from typing import Dict, List, Tuple
from typing import Dict, List

from setuptools import Command, Distribution, find_namespace_packages, setup
from setuptools.command.develop import develop as develop_orig
Expand Down Expand Up @@ -669,17 +669,10 @@ def add_additional_extras() -> None:
'winrm': 'microsoft.winrm',
}


def find_requirements_for_alias(alias_to_look_for: Tuple[str, str]) -> List[str]:
"""Finds requirements for an alias"""
deprecated_extra = alias_to_look_for[0]
new_extra = alias_to_look_for[1]
if new_extra == '': # Handle case for crypto
return []
try:
return EXTRAS_REQUIREMENTS[new_extra]
except KeyError: # noqa
raise Exception(f"The extra {new_extra} is missing for alias {deprecated_extra}")
EXTRAS_DEPRECATED_ALIASES_NOT_PROVIDERS: List[str] = [
"crypto",
"webhdfs",
]


def add_extras_for_all_deprecated_aliases() -> None:
Expand All @@ -696,6 +689,20 @@ def add_extras_for_all_deprecated_aliases() -> None:
EXTRAS_REQUIREMENTS[alias] = requirements


def add_all_deprecated_provider_packages() -> None:
"""
For deprecated aliases that are providers, we will swap the providers requirements to instead
be the provider itself.
e.g. {"kubernetes": ["kubernetes>=3.0.0, <12.0.0", ...]} becomes
{"kubernetes": ["apache-airflow-provider-cncf-kubernetes"]}
"""
for alias, provider in EXTRAS_DEPRECATED_ALIASES.items():
if alias in EXTRAS_DEPRECATED_ALIASES_NOT_PROVIDERS:
continue
replace_extra_requirement_with_provider_packages(alias, [provider])


add_extras_for_all_deprecated_aliases()

#############################################################################################################
Expand Down Expand Up @@ -939,6 +946,7 @@ def add_all_provider_packages() -> None:
add_provider_packages_to_extra_requirements(
"devel_hadoop", ["apache.hdfs", "apache.hive", "presto", "trino"]
)
add_all_deprecated_provider_packages()


class Develop(develop_orig):
Expand Down

0 comments on commit fdea622

Please sign in to comment.