From 074cbc9cae4b6ebb7d013adcec42e070be1ae6b3 Mon Sep 17 00:00:00 2001 From: Miguel Grinberg Date: Mon, 7 Jun 2021 00:00:35 +0100 Subject: [PATCH] Improved project structure --- .github/workflows/tests.yml | 4 -- MANIFEST.in | 8 ++-- __version__ | 1 - pyproject.toml | 6 +++ setup.cfg | 36 ++++++++++++++ setup.py | 48 +------------------ .../flask_migrate}/__init__.py | 0 {flask_migrate => src/flask_migrate}/cli.py | 0 .../templates/flask-multidb/README | 0 .../templates/flask-multidb/alembic.ini.mako | 0 .../templates/flask-multidb/env.py | 1 + .../templates/flask-multidb/script.py.mako | 1 + .../flask_migrate}/templates/flask/README | 0 .../templates/flask/alembic.ini.mako | 0 .../flask_migrate}/templates/flask/env.py | 0 .../templates/flask/script.py.mako | 0 tox.ini | 2 +- 17 files changed, 52 insertions(+), 55 deletions(-) delete mode 100644 __version__ create mode 100644 pyproject.toml create mode 100644 setup.cfg rename {flask_migrate => src/flask_migrate}/__init__.py (100%) rename {flask_migrate => src/flask_migrate}/cli.py (100%) rename {flask_migrate => src/flask_migrate}/templates/flask-multidb/README (100%) rename {flask_migrate => src/flask_migrate}/templates/flask-multidb/alembic.ini.mako (100%) rename {flask_migrate => src/flask_migrate}/templates/flask-multidb/env.py (99%) rename {flask_migrate => src/flask_migrate}/templates/flask-multidb/script.py.mako (98%) rename {flask_migrate => src/flask_migrate}/templates/flask/README (100%) rename {flask_migrate => src/flask_migrate}/templates/flask/alembic.ini.mako (100%) rename {flask_migrate => src/flask_migrate}/templates/flask/env.py (100%) rename {flask_migrate => src/flask_migrate}/templates/flask/script.py.mako (100%) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 692f076..23e710b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -24,10 +24,6 @@ jobs: # TODO: add windows-latest os: [ubuntu-latest, macos-latest] python: ['3.6', '3.7', '3.8', '3.9', 'pypy3'] - exclude: - # pypy3 currently fails to run on Windows - - os: windows-latest - python: pypy3 fail-fast: false runs-on: ${{ matrix.os }} steps: diff --git a/MANIFEST.in b/MANIFEST.in index a3bdfde..ef47d6c 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,5 @@ -include __version__ README.md LICENSE flask_migrate/templates/flask/* \ -flask_migrate/templates/flask-multidb/* tests/* - +include README.md +include LICENSE +include src/flask_migrate/templates/flask/* +include src/flask_migrate/templates/flask-multidb/* +include tests/* diff --git a/__version__ b/__version__ deleted file mode 100644 index b4b9c21..0000000 --- a/__version__ +++ /dev/null @@ -1 +0,0 @@ -3.0.2dev diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..374b58c --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,6 @@ +[build-system] +requires = [ + "setuptools>=42", + "wheel" +] +build-backend = "setuptools.build_meta" diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..542e9cb --- /dev/null +++ b/setup.cfg @@ -0,0 +1,36 @@ +[metadata] +name = Flask-Migrate +version = 3.0.2.dev0 +author = Miguel Grinberg +author_email = miguel.grinberg@gmail.com +description = SQLAlchemy database migrations for Flask applications using Alembic. +long_description = file: README.md +long_description_content_type = text/markdown +url = https://github.com/miguelgrinberg/flask-migrate +project_urls = + Bug Tracker = https://github.com/miguelgrinberg/flask-migrate/issues +classifiers = + Environment :: Web Environment + Intended Audience :: Developers + Programming Language :: Python :: 3 + License :: OSI Approved :: MIT License + Operating System :: OS Independent + +[options] +zip_safe = False +include_package_data = True +package_dir = + = src +packages = find: +python_requires = >=3.6 +install_requires = + Flask >= 0.9 + Flask-SQLAlchemy >= 1.0 + alembic >= 0.7 + +[options.packages.find] +where = src + +[options.entry_points] +flask.commands = + db = flask_migrate.cli:db diff --git a/setup.py b/setup.py index 6c318ab..b908cbe 100644 --- a/setup.py +++ b/setup.py @@ -1,47 +1,3 @@ -""" -Flask-Migrate --------------- +import setuptools -SQLAlchemy database migrations for Flask applications using Alembic. -""" -from setuptools import setup - - -VERSION = open('__version__').read().strip() - -setup( - name='Flask-Migrate', - version=VERSION, - url='http://github.com/miguelgrinberg/flask-migrate/', - license='MIT', - author='Miguel Grinberg', - author_email='miguelgrinberg50@gmail.com', - description=('SQLAlchemy database migrations for Flask applications ' - 'using Alembic'), - long_description=__doc__, - packages=['flask_migrate'], - zip_safe=False, - include_package_data=True, - platforms='any', - install_requires=[ - 'Flask>=0.9', - 'Flask-SQLAlchemy>=1.0', - 'alembic>=0.7' - ], - entry_points={ - 'flask.commands': [ - 'db=flask_migrate.cli:db' - ], - }, - classifiers=[ - 'Environment :: Web Environment', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: MIT License', - 'Operating System :: OS Independent', - 'Programming Language :: Python', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 3', - 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', - 'Topic :: Software Development :: Libraries :: Python Modules' - ] -) +setuptools.setup() diff --git a/flask_migrate/__init__.py b/src/flask_migrate/__init__.py similarity index 100% rename from flask_migrate/__init__.py rename to src/flask_migrate/__init__.py diff --git a/flask_migrate/cli.py b/src/flask_migrate/cli.py similarity index 100% rename from flask_migrate/cli.py rename to src/flask_migrate/cli.py diff --git a/flask_migrate/templates/flask-multidb/README b/src/flask_migrate/templates/flask-multidb/README similarity index 100% rename from flask_migrate/templates/flask-multidb/README rename to src/flask_migrate/templates/flask-multidb/README diff --git a/flask_migrate/templates/flask-multidb/alembic.ini.mako b/src/flask_migrate/templates/flask-multidb/alembic.ini.mako similarity index 100% rename from flask_migrate/templates/flask-multidb/alembic.ini.mako rename to src/flask_migrate/templates/flask-multidb/alembic.ini.mako diff --git a/flask_migrate/templates/flask-multidb/env.py b/src/flask_migrate/templates/flask-multidb/env.py similarity index 99% rename from flask_migrate/templates/flask-multidb/env.py rename to src/flask_migrate/templates/flask-multidb/env.py index 04b1ff7..8c572fc 100644 --- a/flask_migrate/templates/flask-multidb/env.py +++ b/src/flask_migrate/templates/flask-multidb/env.py @@ -27,6 +27,7 @@ 'sqlalchemy.url', str(current_app.extensions['migrate'].db.get_engine().url).replace( '%', '%%')) +bind_names = [] if current_app.config.get('SQLALCHEMY_BINDS') is not None: bind_names = list(current_app.config['SQLALCHEMY_BINDS'].keys()) else: diff --git a/flask_migrate/templates/flask-multidb/script.py.mako b/src/flask_migrate/templates/flask-multidb/script.py.mako similarity index 98% rename from flask_migrate/templates/flask-multidb/script.py.mako rename to src/flask_migrate/templates/flask-multidb/script.py.mako index 56f3cb4..3beabc4 100644 --- a/flask_migrate/templates/flask-multidb/script.py.mako +++ b/src/flask_migrate/templates/flask-multidb/script.py.mako @@ -28,6 +28,7 @@ def downgrade(engine_name): <% from flask import current_app + bind_names = [] if current_app.config.get('SQLALCHEMY_BINDS') is not None: bind_names = list(current_app.config['SQLALCHEMY_BINDS'].keys()) else: diff --git a/flask_migrate/templates/flask/README b/src/flask_migrate/templates/flask/README similarity index 100% rename from flask_migrate/templates/flask/README rename to src/flask_migrate/templates/flask/README diff --git a/flask_migrate/templates/flask/alembic.ini.mako b/src/flask_migrate/templates/flask/alembic.ini.mako similarity index 100% rename from flask_migrate/templates/flask/alembic.ini.mako rename to src/flask_migrate/templates/flask/alembic.ini.mako diff --git a/flask_migrate/templates/flask/env.py b/src/flask_migrate/templates/flask/env.py similarity index 100% rename from flask_migrate/templates/flask/env.py rename to src/flask_migrate/templates/flask/env.py diff --git a/flask_migrate/templates/flask/script.py.mako b/src/flask_migrate/templates/flask/script.py.mako similarity index 100% rename from flask_migrate/templates/flask/script.py.mako rename to src/flask_migrate/templates/flask/script.py.mako diff --git a/tox.ini b/tox.ini index aee7890..8663ef0 100644 --- a/tox.ini +++ b/tox.ini @@ -19,7 +19,7 @@ commands= deps= flake8 commands= - flake8 --exclude=".*" flask_migrate tests + flake8 --exclude=".*" src/flask_migrate tests [testenv:docs] changedir=docs