From 41060e7e7cb838328c879de6a98ae794dc1886d0 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Thu, 20 Jan 2022 17:18:29 -0800 Subject: [PATCH 1/7] Pin all versions to work with Python 3.6, refs #1609 --- setup.py | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/setup.py b/setup.py index e9ef082a..f927207b 100644 --- a/setup.py +++ b/setup.py @@ -42,21 +42,21 @@ setup( include_package_data=True, python_requires=">=3.6", install_requires=[ - "asgiref>=3.2.10,<3.5.0", - "click>=7.1.1,<8.1.0", - "click-default-group~=1.2.2", - "Jinja2>=2.10.3,<3.1.0", - "hupper~=1.9", - "httpx>=0.20", - "pint~=0.9", - "pluggy>=1.0,<1.1", - "uvicorn~=0.11", - "aiofiles>=0.4,<0.9", - "janus>=0.6.2,<1.1", - "asgi-csrf>=0.9", - "PyYAML>=5.3,<7.0", - "mergedeep>=1.1.1,<1.4.0", - "itsdangerous>=1.1,<3.0", + "asgiref==3.4.1", + "click==8.0.3", + "click-default-group==1.2.2", + "Jinja2==3.0.3", + "hupper==1.10.3", + "httpx==0.21.3", + "pint==0.17", + "pluggy==1.0.0", + "uvicorn==0.16.0", + "aiofiles==0.8.0", + "janus==0.7.0", + "asgi-csrf==0.9", + "PyYAML==6.0", + "mergedeep==1.3.4", + "itsdangerous==2.0.1", "python-baseconv==1.2.2", ], entry_points=""" @@ -67,14 +67,14 @@ setup( extras_require={ "docs": ["sphinx_rtd_theme", "sphinx-autobuild", "codespell"], "test": [ - "pytest>=5.2.2,<6.3.0", - "pytest-xdist>=2.2.1,<2.6", - "pytest-asyncio>=0.10,<0.17", - "beautifulsoup4>=4.8.1,<4.11.0", + "pytest==6.2.5", + "pytest-xdist==2.5.0", + "pytest-asyncio==0.16.0", + "beautifulsoup4==4.10.0", "black==21.12b0", - "pytest-timeout>=1.4.2,<2.1", - "trustme>=0.7,<0.10", - "cogapp>=3.3.0", + "pytest-timeout==2.0.2", + "trustme==0.9.0", + "cogapp==3.3.0", ], "rich": ["rich"], }, From 6b459c8732b23344a7912a9127212646bc15ccad Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Thu, 20 Jan 2022 17:55:57 -0800 Subject: [PATCH 2/7] Use environment markers for Python 3.6, refs #1609 --- setup.py | 47 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/setup.py b/setup.py index f927207b..092ae172 100644 --- a/setup.py +++ b/setup.py @@ -42,22 +42,39 @@ setup( include_package_data=True, python_requires=">=3.6", install_requires=[ - "asgiref==3.4.1", - "click==8.0.3", - "click-default-group==1.2.2", - "Jinja2==3.0.3", - "hupper==1.10.3", - "httpx==0.21.3", - "pint==0.17", - "pluggy==1.0.0", - "uvicorn==0.16.0", - "aiofiles==0.8.0", - "janus==0.7.0", - "asgi-csrf==0.9", - "PyYAML==6.0", - "mergedeep==1.3.4", - "itsdangerous==2.0.1", + "asgiref>=3.2.10,<3.5.0", + "click>=7.1.1,<8.1.0", + "click-default-group~=1.2.2", + "Jinja2>=2.10.3,<3.1.0", + "hupper~=1.9", + "httpx>=0.20", + "pint~=0.9", + "pluggy>=1.0,<1.1", + "uvicorn~=0.11", + "aiofiles>=0.4,<0.9", + "janus>=0.6.2,<1.1", + "asgi-csrf>=0.9", + "PyYAML>=5.3,<7.0", + "mergedeep>=1.1.1,<1.4.0", + "itsdangerous>=1.1,<3.0", "python-baseconv==1.2.2", + # The following are known to work with 3.6 + 'asgiref<=3.4.1;python_version<="3.6"', + 'click<=8.0.3;python_version<="3.6"', + 'click-default-group<=1.2.2;python_version<="3.6"', + 'Jinja2<=3.0.3;python_version<="3.6"', + 'hupper<=1.10.3;python_version<="3.6"', + 'httpx<=0.21.3;python_version<="3.6"', + 'pint<=0.17;python_version<="3.6"', + 'pluggy<=1.0.0;python_version<="3.6"', + 'uvicorn<=0.16.0;python_version<="3.6"', + 'aiofiles<=0.8.0;python_version<="3.6"', + 'janus<=0.7.0;python_version<="3.6"', + 'asgi-csrf<=0.9;python_version<="3.6"', + 'PyYAML<=6.0;python_version<="3.6"', + 'mergedeep<=1.3.4;python_version<="3.6"', + 'itsdangerous<=2.0.1;python_version<="3.6"', + 'python-baseconv<=1.2.2;python_version<="3.6"', ], entry_points=""" [console_scripts] From 265c62344aec9aff04890a05cc7eb10f2261b206 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Thu, 20 Jan 2022 18:01:47 -0800 Subject: [PATCH 3/7] Output pip freeze to show installed packages, refs #1609 --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 704931a6..d45a6f31 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,6 +24,7 @@ jobs: - name: Install dependencies run: | pip install -e '.[test]' + pip freeze - name: Run tests run: | pytest -n auto -m "not serial" From 8da5208561be7895f62834becdd7b6b16f6e503f Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Thu, 20 Jan 2022 18:08:20 -0800 Subject: [PATCH 4/7] Release 0.60.1 Refs #1609 --- datasette/version.py | 2 +- docs/changelog.rst | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/datasette/version.py b/datasette/version.py index a4e340b3..7e844fa5 100644 --- a/datasette/version.py +++ b/datasette/version.py @@ -1,2 +1,2 @@ -__version__ = "0.60" +__version__ = "0.60.1" __version_info__ = tuple(__version__.split(".")) diff --git a/docs/changelog.rst b/docs/changelog.rst index d7e2af39..bc168de3 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -4,6 +4,13 @@ Changelog ========= +.. _v0_60.1: + +0.60.1 (2022-01-20) +------------------- + +- Fixed a bug where installation on Python 3.6 stopped working due to a change to an underlying dependency. This release can now be installed on Python 3.6, but is the last release of Datasette that will support anything less than Python 3.7. (:issue:`1609`) + .. _v0_60: 0.60 (2022-01-13) From a0ff62aac113762619e2de2b5cc278671fb48dd9 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Mon, 7 Feb 2022 15:28:46 -0800 Subject: [PATCH 5/7] De-duplicate 'datasette db.db db.db', closes #1632 Refs https://github.com/simonw/datasette-publish-fly/pull/12 --- datasette/cli.py | 3 +++ tests/test_cli.py | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/datasette/cli.py b/datasette/cli.py index 9d1b5ee5..61e7ce91 100644 --- a/datasette/cli.py +++ b/datasette/cli.py @@ -549,6 +549,9 @@ def serve( ) ) + # De-duplicate files so 'datasette db.db db.db' only attaches one /db + files = list(dict.fromkeys(files)) + try: ds = Datasette(files, **kwargs) except SpatialiteNotFound: diff --git a/tests/test_cli.py b/tests/test_cli.py index 763fe2e7..9da99d87 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -259,6 +259,7 @@ def test_serve_create(ensure_eventloop, tmpdir): def test_serve_duplicate_database_names(ensure_eventloop, tmpdir): + "'datasette db.db nested/db.db' should attach two databases, /db and /db_2" runner = CliRunner() db_1_path = str(tmpdir / "db.db") nested = tmpdir / "nested" @@ -272,6 +273,17 @@ def test_serve_duplicate_database_names(ensure_eventloop, tmpdir): assert {db["name"] for db in databases} == {"db", "db_2"} +def test_serve_deduplicate_same_database_path(ensure_eventloop, tmpdir): + "'datasette db.db db.db' should only attach one database, /db" + runner = CliRunner() + db_path = str(tmpdir / "db.db") + sqlite3.connect(db_path).execute("vacuum") + result = runner.invoke(cli, [db_path, db_path, "--get", "/-/databases.json"]) + assert result.exit_code == 0, result.output + databases = json.loads(result.output) + assert {db["name"] for db in databases} == {"db"} + + @pytest.mark.parametrize( "filename", ["test-database (1).sqlite", "database (1).sqlite"] ) From 0b1aa9d1a387b2987d2dbfec9f693c9951bb6769 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Mon, 7 Feb 2022 15:32:54 -0800 Subject: [PATCH 6/7] Release 0.60.2 Refs #1632 --- datasette/version.py | 2 +- docs/changelog.rst | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/datasette/version.py b/datasette/version.py index 7e844fa5..91224615 100644 --- a/datasette/version.py +++ b/datasette/version.py @@ -1,2 +1,2 @@ -__version__ = "0.60.1" +__version__ = "0.60.2" __version_info__ = tuple(__version__.split(".")) diff --git a/docs/changelog.rst b/docs/changelog.rst index bc168de3..c58c8444 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -4,6 +4,13 @@ Changelog ========= +.. _v0_60.2: + +0.60.2 (2022-02-07) +------------------- + +- Fixed a bug where Datasette would open the same file twice with two different database names if you ran ``datasette file.db file.db``. (:issue:`1632`) + .. _v0_60.1: 0.60.1 (2022-01-20) From 5619069968ab39fd44c44a1888965e361c6f7fb9 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Mon, 7 Feb 2022 15:42:37 -0800 Subject: [PATCH 7/7] Use de-dupe idiom that works with Python 3.6, refs #1632 --- datasette/cli.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/datasette/cli.py b/datasette/cli.py index 61e7ce91..a8da0741 100644 --- a/datasette/cli.py +++ b/datasette/cli.py @@ -550,7 +550,9 @@ def serve( ) # De-duplicate files so 'datasette db.db db.db' only attaches one /db - files = list(dict.fromkeys(files)) + files_seen = set() + deduped_files = [f for f in files if f not in files_seen and not files_seen.add(f)] + files = deduped_files try: ds = Datasette(files, **kwargs)