From 539539095306acefc0c1d601bd2056bf88b12996 Mon Sep 17 00:00:00 2001 From: Matthew Messinger Date: Fri, 29 Mar 2024 10:49:54 -0400 Subject: [PATCH 1/3] Migrate to pyproject.toml Building is now done with pyproject-build instead of wheel and setuptools. A console entrypoint has also been added, so it can be installed with pipx and ran by executing pgsqlite --- .gitignore | 7 +++++++ README.md | 6 ++++++ install_pypi.sh | 4 ++-- pgsqlite/pgsqlite.py | 7 +++++-- pyproject.toml | 38 +++++++++++++++++++++++++++++++++++ setup.py | 48 -------------------------------------------- 6 files changed, 58 insertions(+), 52 deletions(-) create mode 100644 .gitignore create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c4312eb --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +.venv + +build/ +dist/ +*.egg-info/ +*.pyc +__pycache__/ diff --git a/README.md b/README.md index 1774910..8119610 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,12 @@ pgsqlite ======= Load SQLite3 databases into PostgreSQL. +Install with pipx + +```sh +pipx install pgsqlite +``` + Usage: ``` usage: pgsqlite.py [-h] -f SQLITE_FILENAME -p POSTGRES_CONNECT_URL [-d DEBUG] [--drop_tables DROP_TABLES] [--drop_everything DROP_EVERYTHING] [--drop_tables_after_import DROP_TABLES_AFTER_IMPORT] diff --git a/install_pypi.sh b/install_pypi.sh index 0eebeab..e58ace5 100755 --- a/install_pypi.sh +++ b/install_pypi.sh @@ -5,7 +5,7 @@ rm -rf dist/* rm -rf build/* rm -rf pgsqlite.egg-info set -e -pip install wheel bumpversion twine -python setup.py sdist bdist_wheel +pip install build bumpversion twine +pyproject-build python -m twine check dist/* python -m twine upload --repository-url https://upload.pypi.org/legacy/ dist/* diff --git a/pgsqlite/pgsqlite.py b/pgsqlite/pgsqlite.py index 18b2e1c..fde723f 100644 --- a/pgsqlite/pgsqlite.py +++ b/pgsqlite/pgsqlite.py @@ -517,7 +517,7 @@ async def create_all_indexes(): # todo: add checks, views, triggers. -if __name__ == "__main__": +def main(): parser = argparse.ArgumentParser() parser.add_argument( "-f", @@ -586,4 +586,7 @@ async def create_all_indexes(): logger.debug(json.dumps(loader.get_summary(), indent=2)) if args.drop_tables_after_import: - loader._drop_tables() \ No newline at end of file + loader._drop_tables() + +if __name__ == "__main__": + main() diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..b20006d --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,38 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[project] +name = "pgsqlite" +version = "1.0.3" +description = "Loader to import sqlite3 databases into Postgres" + +readme = "README.md" +authors = [ + { name = "bit.io", email = "python@bit.io" } +] + +requires-python = ">=3.9" +dependencies = [ + "sqlite-utils >= 3.28", + "psycopg >= 3.1", + "psycopg-binary >= 3.1", + "structlog >= 22.1.0", + "sqlglot >= 10.6.3" +] + +keywords = ["bit.io", "Database", "postgres", "postgresql", "sqlite", "sqlite3"] +classifiers = [ + "Programming Language :: Python :: 3", + "Operating System :: OS Independent", +] + +[project.urls] +"Homepage" = "https://github.com/bitdotioinc/pgsqlite" +"Bug Tracker" = "https://github.com/bitdotioinc/pgsqlite/issues" + +[project.scripts] +pgsqlite = "pgsqlite.pgsqlite:main" + +[tool.setuptools.packages.find] +exclude = ["test", "tests"] diff --git a/setup.py b/setup.py deleted file mode 100644 index 7c7fad7..0000000 --- a/setup.py +++ /dev/null @@ -1,48 +0,0 @@ -# coding: utf-8 - -""" - pgsqlite - - pgsqlite # noqa: E501 -""" - - -from setuptools import setup, find_packages # noqa: H301 - -NAME = "pgsqlite" -VERSION = "1.0.3" -# To install the library, run the following -# -# python setup.py install -# -# prerequisite: setuptools -# http://pypi.python.org/pypi/setuptools - -REQUIRES = ["sqlite-utils >= 3.28", "psycopg >= 3.1", "psycopg-binary >= 3.1", "structlog >= 22.1.0", "sqlglot >= 10.6.3"] - - -with open("README.md", "r", encoding="utf-8") as fh: - long_description = fh.read() - -setup( - name=NAME, - version=VERSION, - description="Loader to import sqlite3 databases into Postgres", - author="bit.io", - author_email="python@bit.io", - url="https://github.com/bitdotioinc/pgsqlite", - keywords=["bit.io", "Database", "postgres", "postgresql", "sqlite", "sqlite3"], - install_requires=REQUIRES, - packages=find_packages(exclude=["test", "tests"]), - include_package_data=True, - long_description=long_description, - long_description_content_type="text/markdown", - project_urls={ - "Bug Tracker": "https://github.com/bitdotioinc/pgsqlite/issues", - }, - classifiers=[ - "Programming Language :: Python :: 3", - "Operating System :: OS Independent", - ], - python_requires=">=3.9", -) From 278708b80564079abaa5cc02d859fbb98ae1a742 Mon Sep 17 00:00:00 2001 From: Matthew Messinger Date: Fri, 29 Mar 2024 10:58:15 -0400 Subject: [PATCH 2/3] Add a __main__.py file --- pgsqlite/__main__.py | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 pgsqlite/__main__.py diff --git a/pgsqlite/__main__.py b/pgsqlite/__main__.py new file mode 100644 index 0000000..0b59e97 --- /dev/null +++ b/pgsqlite/__main__.py @@ -0,0 +1,4 @@ +from pgsqlite.pgsqlite import main + +if __name__ == "__main__": + main() From 7992d7999c84895ab8db6736516a59cb9203d7f8 Mon Sep 17 00:00:00 2001 From: Matthew Messinger Date: Fri, 29 Mar 2024 11:02:26 -0400 Subject: [PATCH 3/3] Replace bumpversion with bump-my-version --- install_pypi.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install_pypi.sh b/install_pypi.sh index e58ace5..849699d 100755 --- a/install_pypi.sh +++ b/install_pypi.sh @@ -5,7 +5,7 @@ rm -rf dist/* rm -rf build/* rm -rf pgsqlite.egg-info set -e -pip install build bumpversion twine +pip install build bump-my-version twine pyproject-build python -m twine check dist/* python -m twine upload --repository-url https://upload.pypi.org/legacy/ dist/*