Skip to content

Commit

Permalink
(chore) Use pbr for packaging for automated versioning with git tag, …
Browse files Browse the repository at this point in the history
…move to setup.cfg (#427)

* move to setup.cfg with pbr, version from git tag
* make compatible with Python-flavored SemVer
  • Loading branch information
guenp committed Aug 19, 2024
1 parent 566648f commit 39c51cf
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 55 deletions.
10 changes: 9 additions & 1 deletion dbt/adapters/duckdb/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
version = "1.8.2"
from importlib.metadata import version as get_version

_package_name = "dbt-duckdb"
version = get_version(_package_name)
# This is to get around SemVer 2 (dbt_common) vs Linux/Python compatible SemVer 3 (pbr) conflicting
# See: https://docs.openstack.org/pbr/latest/user/semver.html
_prerelease_tags = ["dev", "a", "b", "c"]
for tag in _prerelease_tags:
version = version.replace(f".{tag}", f"-{tag}")
50 changes: 50 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[metadata]
name = dbt-duckdb
author = Josh Wills
author-email = [email protected]
url = https://github.com/jwills/dbt-duckdb
summary = The duckdb adapter plugin for dbt (data build tool)
description_file = README.md
long_description_content_type = text/markdown
license = Apache-2
classifier =
Development Status :: 5 - Production/Stable
License :: OSI Approved :: Apache Software License
Operating System :: Microsoft :: Windows
Operating System :: MacOS :: MacOS X
Operating System :: POSIX :: Linux
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
keywords =
setup
distutils

[options]
install_requires=
dbt-common>=1,<2
dbt-adapters>=1,<2
duckdb>=1.0.0
# add dbt-core to ensure backwards compatibility of installation, this is not a functional dependency
dbt-core>=1.8.0
python_requires = >=3.8
include_package_data = True
packages = find_namespace:

[options.packages.find]
include =
dbt
dbt.*

[build-system]
requires = ["setuptools >= 61.2", "pbr>=1.9"]

[extras]
glue =
boto3
mypy-boto3-glue

[files]
packages =
dbt-duckdb
56 changes: 2 additions & 54 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,59 +1,7 @@
#!/usr/bin/env python
import os
import re

from setuptools import find_namespace_packages
from setuptools import setup

this_directory = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(this_directory, "README.md")) as f:
long_description = f.read()

package_name = "dbt-duckdb"


def _dbt_duckdb_version():
_version_path = os.path.join(this_directory, "dbt", "adapters", "duckdb", "__version__.py")
_version_pattern = r"""version\s*=\s*["'](.+)["']"""
with open(_version_path) as f:
match = re.search(_version_pattern, f.read().strip())
if match is None:
raise ValueError(f"invalid version at {_version_path}")
return match.group(1)


package_version = _dbt_duckdb_version()
description = """The duckdb adapter plugin for dbt (data build tool)"""

setup(
name=package_name,
version=package_version,
description=description,
long_description=long_description,
long_description_content_type="text/markdown",
author="Josh Wills",
author_email="[email protected]",
url="https://github.com/jwills/dbt-duckdb",
packages=find_namespace_packages(include=["dbt", "dbt.*"]),
include_package_data=True,
install_requires=[
"dbt-common>=1,<2",
"dbt-adapters>=1,<2",
"duckdb>=1.0.0",
# add dbt-core to ensure backwards compatibility of installation, this is not a functional dependency
"dbt-core>=1.8.0",
],
extras_require={"glue": ["boto3", "mypy-boto3-glue"], "md": ["duckdb==1.0.0"]},
classifiers=[
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: Apache Software License",
"Operating System :: Microsoft :: Windows",
"Operating System :: MacOS :: MacOS X",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
],
python_requires=">=3.8",
setup_requires=["pbr"],
pbr=True,
)

0 comments on commit 39c51cf

Please sign in to comment.