From 4ecf4ad0b4fd576d8d280825308dc3a642c248f8 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 13 Feb 2025 11:53:25 -0500 Subject: [PATCH] use pep 621 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 --- docs/build/unreleased/pyproject.rst | 4 ++ pyproject.toml | 89 ++++++++++++++++++++++++++++- setup.cfg | 80 -------------------------- setup.py | 4 -- tests/test_command.py | 28 ++++----- tests/test_editor.py | 15 ++--- tests/test_messaging.py | 5 +- tests/test_op.py | 10 +++- tests/test_post_write.py | 15 +++-- 9 files changed, 134 insertions(+), 116 deletions(-) create mode 100644 docs/build/unreleased/pyproject.rst diff --git a/docs/build/unreleased/pyproject.rst b/docs/build/unreleased/pyproject.rst new file mode 100644 index 00000000..32f4ff3c --- /dev/null +++ b/docs/build/unreleased/pyproject.rst @@ -0,0 +1,4 @@ +.. change:: + :tags: changed, general + + Installation has been converted to use :pep:`621`, e.g. ``pyproject.toml``. diff --git a/pyproject.toml b/pyproject.toml index eedcd327..8034dd0c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" diff --git a/setup.cfg b/setup.cfg index c6dbc109..f3aaa9aa 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 diff --git a/setup.py b/setup.py index 1a4f69a8..60684932 100644 --- a/setup.py +++ b/setup.py @@ -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() diff --git a/tests/test_command.py b/tests/test_command.py index 1b41af6d..89398c24 100644 --- a/tests/test_command.py +++ b/tests/test_command.py @@ -1227,9 +1227,12 @@ class CommandLineTest(TestBase): 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, @@ -1286,12 +1289,11 @@ class CommandLineTest(TestBase): 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_( @@ -1306,10 +1308,10 @@ class CommandLineTest(TestBase): 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_( diff --git a/tests/test_editor.py b/tests/test_editor.py index 0ec6f5f4..c5fdc8db 100644 --- a/tests/test_editor.py +++ b/tests/test_editor.py @@ -10,13 +10,14 @@ from alembic.testing.fixtures import TestBase 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) diff --git a/tests/test_messaging.py b/tests/test_messaging.py index cfd450a2..0b23a63a 100644 --- a/tests/test_messaging.py +++ b/tests/test_messaging.py @@ -10,8 +10,9 @@ from alembic.util.messaging import obfuscate_url_pw 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_( diff --git a/tests/test_op.py b/tests/test_op.py index 789203cb..d9e65091 100644 --- a/tests/test_op.py +++ b/tests/test_op.py @@ -1287,9 +1287,13 @@ class OpTest(TestBase): 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) diff --git a/tests/test_post_write.py b/tests/test_post_write.py index 2027ab9a..f728f0bb 100644 --- a/tests/test_post_write.py +++ b/tests/test_post_write.py @@ -148,12 +148,15 @@ class RunHookTest(TestBase): ] 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")]) -- 2.47.2