From d7d7ecbc08984ffff30ee9e632f045075d041b3d Mon Sep 17 00:00:00 2001 From: koobs Date: Tue, 28 May 2019 08:55:49 +0000 Subject: [PATCH] databases/py-pgcli: Fix runtime dependency failures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit pgcli depends on sqlparse<0.3.0,>=0.2.2, and sqlparse was updated to 0.3.0 in ports r495481. pgcli depends on psycopg2>=2.7.4,<2.8, and psycopg2 was updated to 2.8.2 in ports r502646. These broke run time, with the following error(s) raise DistributionNotFound(req, requirers) pkg_resources.DistributionNotFound: The 'sqlparse<0.3.0,>=0.2.2' distribution was not found and is required by pgcli raise DistributionNotFound(req, requirers) pkg_resources.DistributionNotFound: The 'psycopg2>=2.7.4,<2.8' distribution was not found and is required by pgcli Upstream upgraded sqlparse support to include 0.3.0 in PR #1052 [1], this change backports that PR accordingly. Upstream has an open PR to unpin psycopg2 [2][3] but it needs to be updated to use psycopg2 (not psycopg2-binary) in install_requires. This change patches out the psycopg2 max version. The test results shows no test failure delta with 2.8.2 over 2.7.7 (the version before ports r502646). While I'm here: - Declare pinned (maximum) RUN_DEPENDS versions according to setup.py to pick these issues up earlier during QA (max versions not being satisfied will error out during dependency builds/verification pre-commit [1] https://github.com/dbcli/pgcli/pull/1052 [2] https://github.com/dbcli/pgcli/pull/1059 [3] https://github.com/dbcli/pgcli/issues/1036 PR: 238182 Reported by: Marcin Cieślak Approved by: portmgr (blanket: run time fix, just fix it) --- databases/py-pgcli/Makefile | 11 +++++- databases/py-pgcli/files/patch-PR1052 | 56 +++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 databases/py-pgcli/files/patch-PR1052 diff --git a/databases/py-pgcli/Makefile b/databases/py-pgcli/Makefile index 82ec4a702af63..bf4bde013f9a9 100644 --- a/databases/py-pgcli/Makefile +++ b/databases/py-pgcli/Makefile @@ -3,6 +3,7 @@ PORTNAME= pgcli PORTVERSION= 2.1.0 +PORTREVISION= 1 CATEGORIES= databases python MASTER_SITES= CHEESESHOP PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX} @@ -18,15 +19,21 @@ RUN_DEPENDS= ${PYTHON_PKGNAMEPREFIX}cli-helpers>=1.2.0:devel/py-cli-helpers@${PY ${PYTHON_PKGNAMEPREFIX}configobj>=5.0.6:devel/py-configobj@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}humanize>=0.5.1:devel/py-humanize@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}pgspecial>=1.11.5:databases/py-pgspecial@${PY_FLAVOR} \ - ${PYTHON_PKGNAMEPREFIX}prompt_toolkit>=2.0.6:devel/py-prompt_toolkit@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}prompt_toolkit>=2.0.6<2.1.0:devel/py-prompt_toolkit@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}psycopg2>=2.7.4:databases/py-psycopg2@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}pygments>=2.0:textproc/py-pygments@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}setproctitle>=1.1.9:devel/py-setproctitle@${PY_FLAVOR} \ - ${PYTHON_PKGNAMEPREFIX}sqlparse>=0.2.2:databases/py-sqlparse@${PY_FLAVOR} + ${PYTHON_PKGNAMEPREFIX}sqlparse>=0.2.2<0.4:databases/py-sqlparse@${PY_FLAVOR} +TEST_DEPENDS= ${PYTHON_PKGNAMEPREFIX}pytest>=2.7.0:devel/py-pytest@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}mock>=1.0.1:devel/py-mock@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}pexpect>=0:misc/py-pexpect@${PY_FLAVOR} USES= pgsql python USE_PYTHON= autoplist concurrent distutils NO_ARCH= yes +do-test: + @cd ${WRKSRC} && ${PYTHON_CMD} -m pytest -v -rs + .include diff --git a/databases/py-pgcli/files/patch-PR1052 b/databases/py-pgcli/files/patch-PR1052 new file mode 100644 index 0000000000000..371acb39c4066 --- /dev/null +++ b/databases/py-pgcli/files/patch-PR1052 @@ -0,0 +1,56 @@ +# Upgrade to sqlparse 0.3.0 #1052 +# https://github.com/dbcli/pgcli/pull/1052 + +# Unpin psycopg2 +# https://github.com/dbcli/pgcli/issues/1036 +# https://github.com/dbcli/pgcli/pull/1059 + +From 1908142adb80f324d6c795e76e38f7939948d7f1 Mon Sep 17 00:00:00 2001 +From: Amjith Ramanujam +Date: Mon, 6 May 2019 09:05:56 -0700 +Subject: [PATCH 4/5] Upgrade to sqlparse 0.3.0. + +--- pgcli/packages/sqlcompletion.py.orig 2018-09-28 21:20:16 UTC ++++ pgcli/packages/sqlcompletion.py +@@ -154,7 +154,7 @@ def suggest_type(full_text, text_before_cursor): + # Be careful here because trivial whitespace is parsed as a + # statement, but the statement won't have a first token + tok1 = stmt.parsed.token_first() +- if tok1 and tok1.value == '\\': ++ if tok1 and tok1.value.startswith('\\'): + text = stmt.text_before_cursor + stmt.word_before_cursor + return suggest_special(text) + +@@ -398,7 +398,7 @@ def suggest_based_on_last_token(token, stmt): + elif token_v == 'set': + return (Column(table_refs=stmt.get_tables(), + local_tables=stmt.local_tables),) +- elif token_v in ('select', 'where', 'having', 'by', 'distinct'): ++ elif token_v in ('select', 'where', 'having', 'order by', 'distinct'): + # Check for a table alias or schema qualification + parent = (stmt.identifier and stmt.identifier.get_parent_name()) or [] + tables = stmt.get_tables() +--- setup.py.orig 2019-04-06 00:24:36 UTC ++++ setup.py +@@ -16,8 +16,8 @@ install_requirements = [ + 'click >= 4.1', + 'Pygments >= 2.0', # Pygments has to be Capitalcased. WTF? + 'prompt_toolkit>=2.0.6,<2.1.0', +- 'psycopg2 >= 2.7.4,<2.8', +- 'sqlparse >=0.2.2,<0.3.0', ++ 'psycopg2 >= 2.7.4', ++ 'sqlparse >=0.2.2,<0.4', + 'configobj >= 5.0.6', + 'humanize >= 0.5.1', + 'cli_helpers[styles] >= 1.2.0', +--- tests/test_sqlcompletion.py.orig 2018-01-11 20:31:20 UTC ++++ tests/test_sqlcompletion.py +@@ -236,7 +236,7 @@ def test_distinct_suggests_cols(text): + ( + 'SELECT * FROM tbl x JOIN tbl1 y ORDER BY ', + 'SELECT * FROM tbl x JOIN tbl1 y ORDER BY ', +- 'BY', ++ 'ORDER BY', + ) + ]) + def test_distinct_and_order_by_suggestions_with_aliases(text, text_before,