Skip to content

Commit

Permalink
use pep 621
Browse files Browse the repository at this point in the history
Installation has been converted to use :pep:`621`, e.g. ``pyproject.toml``.

note that the introduction of pyproject with min python version of 3.9
is also consumed by Black which now wants to format a few test files
differently, so that is included as well.

Change-Id: I7f61abded37fd3f1d7bf32e3228fe97902029d19
  • Loading branch information
zzzeek committed Feb 14, 2025
1 parent a30a908 commit 4ecf4ad
Show file tree
Hide file tree
Showing 9 changed files with 134 additions and 116 deletions.
4 changes: 4 additions & 0 deletions docs/build/unreleased/pyproject.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.. change::
:tags: changed, general

Installation has been converted to use :pep:`621`, e.g. ``pyproject.toml``.
89 changes: 88 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,98 @@
[build-system]
build-backend = "setuptools.build_meta"
requires = [
"setuptools>=61.0",
"setuptools>=61.2",
]


[project]
name = "alembic"
description = "A database migration tool for SQLAlchemy."
authors = [{name = "Mike Bayer", email = "mike_mp@zzzcomputing.com"}]
license = {text = "MIT"}
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Environment :: Console",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Database :: Front-Ends",
]
requires-python = ">=3.9"
dependencies = [
"SQLAlchemy>=1.4.0",
"Mako",
"typing-extensions>=4.12",
]
dynamic = ["version"]

[project.readme]
file = "README.rst"
content-type = "text/x-rst"

[project.urls]
Homepage = "https://alembic.sqlalchemy.org"
Documentation = "https://alembic.sqlalchemy.org/en/latest/"
Changelog = "https://alembic.sqlalchemy.org/en/latest/changelog.html"
Source = "https://github.com/sqlalchemy/alembic/"
"Issue Tracker" = "https://github.com/sqlalchemy/alembic/issues/"

[project.optional-dependencies]
tz = ["tzdata"]

[project.scripts]
alembic = "alembic.config:main"

[tool.setuptools]
include-package-data = true
zip-safe = false
package-dir = {"" = "."}
license-files = ["LICENSE"]

[tool.setuptools.package-data]
alembic = ["*.pyi", "py.typed"]

[tool.setuptools.exclude-package-data]
alembic = ["test*"]

[tool.setuptools.packages.find]
include = ["alembic*"]
exclude = [
"test*",
"examples*",
]
namespaces = true


[tool.setuptools.dynamic]
version = {attr = "alembic.__version__"}

[tool.distutils.egg_info]
tag-build = "dev"

[tool.distutils.upload_docs]
upload-dir = "docs/build/output/html"

[tool.distutils.upload]
sign = 1
identity = "C4DAFEE1"





[tool.black]
line-length = 79
target-version = ['py39']

[tool.pytest.ini_options]
addopts = "--tb native -v -r sfxX -p no:warnings -p no:logging --maxfail=100"
Expand Down
80 changes: 0 additions & 80 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,83 +1,3 @@
[metadata]

name = alembic
version = attr: alembic.__version__
description = A database migration tool for SQLAlchemy.
long_description = file: README.rst
long_description_content_type = text/x-rst
url=https://alembic.sqlalchemy.org
author = Mike Bayer
author_email = mike_mp@zzzcomputing.com
license = MIT
license_files = LICENSE


classifiers =
Development Status :: 5 - Production/Stable
Intended Audience :: Developers
Environment :: Console
License :: OSI Approved :: MIT License
Operating System :: OS Independent
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Programming Language :: Python :: 3.13
Programming Language :: Python :: Implementation :: CPython
Programming Language :: Python :: Implementation :: PyPy
Topic :: Database :: Front-Ends
project_urls =
Documentation = https://alembic.sqlalchemy.org/en/latest/
Changelog = https://alembic.sqlalchemy.org/en/latest/changelog.html
Source = https://github.com/sqlalchemy/alembic/
Issue Tracker = https://github.com/sqlalchemy/alembic/issues/
[options]
packages = find_namespace:
include_package_data = true
zip_safe = false
python_requires = >=3.9

install_requires =
SQLAlchemy>=1.4.0
Mako
typing-extensions>=4.12

[options.extras_require]
tz =
tzdata

[options.package_data]
alembic = *.pyi, py.typed

[options.packages.find]
include=alembic*
exclude =
test*
examples*

[options.exclude_package_data]
'' = test*

[options.entry_points]
console_scripts =
alembic = alembic.config:main

[egg_info]
tag_build=dev

[upload_docs]
upload_dir = docs/build/output/html

[upload]
sign = 1
identity = C4DAFEE1

[nosetests]
with-sqla_testing = true
where = tests

[flake8]
enable-extensions = G
# E203 is due to https://github.com/PyCQA/pycodestyle/issues/373
Expand Down
4 changes: 0 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
from setuptools import __version__
from setuptools import setup

if not int(__version__.partition(".")[0]) >= 47:
raise RuntimeError(f"Setuptools >= 47 required. Found {__version__}")

setup()
28 changes: 15 additions & 13 deletions tests/test_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -1227,9 +1227,12 @@ def test_help_text(self):
assert not commands, "Commands without help text: %s" % commands

def test_init_file_exists_and_is_not_empty(self):
with mock.patch(
"alembic.command.os.listdir", return_value=["file1", "file2"]
), mock.patch("alembic.command.os.access", return_value=True):
with (
mock.patch(
"alembic.command.os.listdir", return_value=["file1", "file2"]
),
mock.patch("alembic.command.os.access", return_value=True),
):
directory = "alembic"
assert_raises_message(
util.CommandError,
Expand Down Expand Up @@ -1286,12 +1289,11 @@ def listdir_(path):
else:
return ["file1", "file2", "alembic.ini.mako"]

with mock.patch(
"alembic.command.os.access", side_effect=access_
), mock.patch("alembic.command.os.makedirs") as makedirs, mock.patch(
"alembic.command.os.listdir", side_effect=listdir_
), mock.patch(
"alembic.command.ScriptDirectory"
with (
mock.patch("alembic.command.os.access", side_effect=access_),
mock.patch("alembic.command.os.makedirs") as makedirs,
mock.patch("alembic.command.os.listdir", side_effect=listdir_),
mock.patch("alembic.command.ScriptDirectory"),
):
command.init(self.cfg, directory="foobar")
eq_(
Expand All @@ -1306,10 +1308,10 @@ def access_(path, mode):
else:
return False

with mock.patch(
"alembic.command.os.access", side_effect=access_
), mock.patch("alembic.command.os.makedirs") as makedirs, mock.patch(
"alembic.command.ScriptDirectory"
with (
mock.patch("alembic.command.os.access", side_effect=access_),
mock.patch("alembic.command.os.makedirs") as makedirs,
mock.patch("alembic.command.ScriptDirectory"),
):
command.init(self.cfg, directory="foobar")
eq_(
Expand Down
15 changes: 8 additions & 7 deletions tests/test_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@

class TestHelpers(TestBase):
def common(self, cb, is_posix=True):
with patch("alembic.util.editor.check_call") as check_call, patch(
"alembic.util.editor.exists"
) as exists, patch(
"alembic.util.editor.is_posix",
new=is_posix,
), patch(
"os.pathsep", new=":" if is_posix else ";"
with (
patch("alembic.util.editor.check_call") as check_call,
patch("alembic.util.editor.exists") as exists,
patch(
"alembic.util.editor.is_posix",
new=is_posix,
),
patch("os.pathsep", new=":" if is_posix else ";"),
):
cb(check_call, exists)

Expand Down
5 changes: 3 additions & 2 deletions tests/test_messaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
class MessagingTest(TestBase):
def test_msg_wraps(self):
buf = StringIO()
with mock.patch("sys.stdout", buf), mock.patch(
"alembic.util.messaging.TERMWIDTH", 10
with (
mock.patch("sys.stdout", buf),
mock.patch("alembic.util.messaging.TERMWIDTH", 10),
):
msg("AAAAAAAAAAAAAAAAA")
eq_(
Expand Down
10 changes: 7 additions & 3 deletions tests/test_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -1287,9 +1287,13 @@ def test_run_async_ok(self):
conn = op.get_bind()
mock_conn = MagicMock()
mock_fn = MagicMock()
with patch.object(conn.dialect, "is_async", True), patch.object(
AsyncConnection, "_retrieve_proxy_for_target", mock_conn
), patch("sqlalchemy.util.await_only") as mock_await:
with (
patch.object(conn.dialect, "is_async", True),
patch.object(
AsyncConnection, "_retrieve_proxy_for_target", mock_conn
),
patch("sqlalchemy.util.await_only") as mock_await,
):
res = op.run_async(mock_fn, 99, foo=42)

eq_(res, mock_await.return_value)
Expand Down
15 changes: 9 additions & 6 deletions tests/test_post_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,15 @@ def _run_black_with_config(
]

importlib_metadata_get = mock.Mock(return_value=retVal)
with mock.patch(
"alembic.util.compat.importlib_metadata_get",
importlib_metadata_get,
), mock.patch(
"alembic.script.write_hooks.subprocess"
) as mock_subprocess:
with (
mock.patch(
"alembic.util.compat.importlib_metadata_get",
importlib_metadata_get,
),
mock.patch(
"alembic.script.write_hooks.subprocess"
) as mock_subprocess,
):
rev = command.revision(self.cfg, message="x")

eq_(importlib_metadata_get.mock_calls, [mock.call("console_scripts")])
Expand Down

0 comments on commit 4ecf4ad

Please sign in to comment.