From 7937d00373392ad4d5b57f7d28b5d807197ac7cf Mon Sep 17 00:00:00 2001 From: Niall Woodward Date: Fri, 3 Dec 2021 12:02:44 +0000 Subject: [PATCH] Add 1.0.0 compatibility --- dbtenv/__init__.py | 2 ++ dbtenv/pip.py | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/dbtenv/__init__.py b/dbtenv/__init__.py index 49c52aa..a62c521 100644 --- a/dbtenv/__init__.py +++ b/dbtenv/__init__.py @@ -86,6 +86,8 @@ def __init__(self, version: str, source: Optional[str] = None, source_descriptio version_match = re.match(r'(?P\d+\.\d+\.\d+)(-?(?P[a-z].*))?', self.raw_version) self.is_semantic = version_match is not None self.is_stable = version_match is not None and not version_match['prerelease'] + self.major_minor_patch = version_match['version'] if version_match is not None else None + self.prerelease = version_match['prerelease'] if version_match is not None else None # dbt pre-release versions are formatted slightly differently in PyPI and Homebrew. if version_match and version_match['prerelease']: diff --git a/dbtenv/pip.py b/dbtenv/pip.py index 5031586..b27e5b1 100644 --- a/dbtenv/pip.py +++ b/dbtenv/pip.py @@ -84,7 +84,18 @@ class ReleaseDateFilterPyPIRequestHandler(BaseDateFilterPyPIRequestHandler): # Versions prior to 0.19.1 just specified agate>=1.6, but agate 1.6.2 introduced a dependency on PyICU # which causes installation problems, so exclude that like versions 0.19.1 and above do. pip_args.append('agate>=1.6,<1.6.2') - pip_args.append(f'dbt=={self.version.pypi_version}') + + # Use correct dbt package name depending on version + if self.version < Version('1.0.0'): + pip_args.append(f'dbt=={self.version.pypi_version}') + else: + # See comment on adapter - dbt-core version coordination + # https://getdbt.slack.com/archives/C02HM9AAXL4/p1637345945047100?thread_ts=1637323222.046100&cid=C02HM9AAXL4 + pip_args.append(f'dbt-core=={self.version.pypi_version}') + pip_args.append(f'dbt-postgres~={self.version.major_minor_patch}') + pip_args.append(f'dbt-redshift~={self.version.major_minor_patch}') + pip_args.append(f'dbt-snowflake~={self.version.major_minor_patch}') + pip_args.append(f'dbt-bigquery~={self.version.major_minor_patch}') logger.info(f"Installing dbt {self.version.pypi_version} from {package_source} into `{self.venv_directory}`.") logger.debug(f"Running `{pip}` with arguments {pip_args}.")