Skip to content

Commit d3a1e87

Browse files
authored
Publish to PyPI (#3)
* feat: Ensure tests pass on SQLAlchemy v1.4 and v2 * chore: Remove psycopg2cffi as it is unmaintained * feat: Use uv for packaging * chore: Copy over _get_column_info implementation from SQLAlchemy 1.4 * fix: Ensure there are no warnings emitted * chore: Remove deprecated redshift_sqlalchemy package * feat: Use dynamic versioning * fix: Linting * fix: Wrong import * chore: Test SQLAlchemy v1.4 and v2 for Python 3.10 - 3.13 * fix: Warnings when generating docs * chore: Remove psycopg2cffi from docs * feat: Prepare release action * chore: Incorporate PR review suggestions * fix: Packaging dependency and version resolution after name change * chore: Incorporate PR review suggestions * fix: Don't parse already parsed package version
1 parent f194bd2 commit d3a1e87

27 files changed

+554
-219
lines changed

.github/workflows/release.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
push:
5+
tags:
6+
- '[0-9]+.[0-9]+.[0-9]+*'
7+
8+
jobs:
9+
publish:
10+
name: Build and publish to PyPI
11+
runs-on: ubuntu-latest
12+
permissions:
13+
id-token: write
14+
contents: read
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@v7
23+
with:
24+
enable-cache: true
25+
26+
- name: Set up Python
27+
run: uv python install 3.12
28+
29+
- name: Build package
30+
run: uv build
31+
32+
- name: Smoke test wheel
33+
run: |
34+
uv run --isolated --no-project --with dist/*.whl python -c "import sqlalchemy_redshift; print(sqlalchemy_redshift.__version__)"
35+
36+
- name: Publish to PyPI
37+
run: uv publish

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,7 @@ target/
5959

6060
# IDE
6161
.idea/
62+
63+
# uv
64+
.venv
65+
.python-version

README.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ The package is available on PyPI::
1818

1919
* psycopg2 - standard distribution of psycopg2, requires compilation so few system dependencies are required for it
2020
* psycopg2-binary - already compiled distribution (no system dependencies are required)
21-
* psycopg2cffi - pypy compatible version
2221

2322
See `Psycopg2's binary install docs <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>`_
2423
for more context on choosing a distribution.

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def _warn_node(self, msg, node, **kwargs):
7373
#
7474
# This is also used if you do content translation via gettext catalogs.
7575
# Usually you set "language" from the command line for these cases.
76-
language = None
76+
language = 'en'
7777

7878
# There are two options for replacing |today|: either, you set today to some
7979
# non-false value, then it is used:

pyproject.toml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
[build-system]
2+
requires = ["hatchling", "uv-dynamic-versioning"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "deepnote-sqlalchemy-redshift"
7+
dynamic = ["version"]
8+
description = "Amazon Redshift Dialect for sqlalchemy"
9+
readme = "README.rst"
10+
requires-python = ">=3.9,<3.14"
11+
license = "MIT"
12+
authors = [
13+
{name = "Matt George", email = "mgeorge@gmail.com"},
14+
]
15+
maintainers = [
16+
{name = "Deepnote", email = "product-engineers@deepnote.com"},
17+
]
18+
classifiers = [
19+
"Development Status :: 4 - Beta",
20+
"Environment :: Console",
21+
"Intended Audience :: Developers",
22+
"Operating System :: OS Independent",
23+
"Programming Language :: Python",
24+
"Programming Language :: Python :: 3",
25+
"Programming Language :: Python :: 3.9",
26+
"Programming Language :: Python :: 3.10",
27+
"Programming Language :: Python :: 3.11",
28+
"Programming Language :: Python :: 3.12",
29+
"Programming Language :: Python :: 3.13",
30+
]
31+
dependencies = [
32+
"SQLAlchemy>=1.4.15,<3.0.0",
33+
"packaging",
34+
]
35+
36+
[project.urls]
37+
Homepage = "https://github.com/deepnote/sqlalchemy-redshift"
38+
39+
[project.entry-points."sqlalchemy.dialects"]
40+
redshift = "sqlalchemy_redshift.dialect:RedshiftDialect_psycopg2"
41+
"redshift.psycopg2" = "sqlalchemy_redshift.dialect:RedshiftDialect_psycopg2"
42+
"redshift.redshift_connector" = "sqlalchemy_redshift.dialect:RedshiftDialect_redshift_connector"
43+
44+
[tool.hatch.version]
45+
source = "uv-dynamic-versioning"
46+
47+
[tool.uv-dynamic-versioning]
48+
fallback-version = "0.0.1"
49+
vcs = "git"
50+
style = "pep440"
51+
52+
[tool.hatch.build.targets.wheel]
53+
packages = ["sqlalchemy_redshift"]
54+
55+
[tool.hatch.build.targets.wheel.force-include]
56+
"sqlalchemy_redshift/redshift-ca-bundle.crt" = "sqlalchemy_redshift/redshift-ca-bundle.crt"
57+
58+
[tool.hatch.build.targets.sdist]
59+
include = [
60+
"sqlalchemy_redshift/",
61+
"README.rst",
62+
"CHANGES.rst",
63+
"LICENSE",
64+
]

redshift_sqlalchemy/__init__.py

Lines changed: 0 additions & 22 deletions
This file was deleted.

requirements-docs.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
-e .
2-
sphinx==1.6.3
3-
numpydoc==0.6.0
4-
psycopg2-binary==2.9.1
5-
jinja2<3.1.0
2+
sphinx>=7.0.0,<8.0.0
3+
numpydoc>=1.5.0,<2.0.0
4+
psycopg2-binary>=2.9.9,<3.0.0
5+
jinja2>=3.1.0,<4.0.0
6+
setuptools>=65.0.0,<76.0.0

setup.cfg

Lines changed: 0 additions & 2 deletions
This file was deleted.

setup.py

Lines changed: 0 additions & 53 deletions
This file was deleted.

sqlalchemy_redshift/__init__.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
from pkg_resources import DistributionNotFound, get_distribution, parse_version
1+
from importlib.metadata import version, PackageNotFoundError
2+
from packaging.version import parse as parse_version
23

3-
for package in ['psycopg2', 'psycopg2-binary', 'psycopg2cffi']:
4+
MIN_PSYCOPG2_VERSION = parse_version('2.5')
5+
6+
for package in ['psycopg2', 'psycopg2-binary']:
47
try:
5-
if get_distribution(package).parsed_version < parse_version('2.5'):
8+
if parse_version(version(package)) < MIN_PSYCOPG2_VERSION:
69
raise ImportError('Minimum required version for psycopg2 is 2.5')
710
break
8-
except DistributionNotFound:
11+
except PackageNotFoundError:
912
pass
1013

11-
__version__ = get_distribution('sqlalchemy-redshift').version
14+
__version__ = version('deepnote-sqlalchemy-redshift')
1215

1316
from sqlalchemy.dialects import registry # noqa
1417

@@ -20,10 +23,6 @@
2023
"redshift.psycopg2", "sqlalchemy_redshift.dialect",
2124
"RedshiftDialect_psycopg2"
2225
)
23-
registry.register(
24-
'redshift+psycopg2cffi', 'sqlalchemy_redshift.dialect',
25-
'RedshiftDialect_psycopg2cffi',
26-
)
2726

2827
registry.register(
2928
"redshift+redshift_connector", "sqlalchemy_redshift.dialect",

0 commit comments

Comments
 (0)