Skip to content

Commit

Permalink
databases/py-pgcli: Fix runtime dependency failures
Browse files Browse the repository at this point in the history
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] dbcli/pgcli#1052
[2] dbcli/pgcli#1059
[3] dbcli/pgcli#1036

PR:		238182
Reported by:	Marcin Cieślak <saper saper info>
Approved by:	portmgr (blanket: run time fix, just fix it)
  • Loading branch information
koobs committed May 28, 2019
1 parent 051b340 commit d7d7ecb
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 2 deletions.
11 changes: 9 additions & 2 deletions databases/py-pgcli/Makefile
Expand Up @@ -3,6 +3,7 @@

PORTNAME= pgcli
PORTVERSION= 2.1.0
PORTREVISION= 1
CATEGORIES= databases python
MASTER_SITES= CHEESESHOP
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}
Expand All @@ -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 <bsd.port.mk>
56 changes: 56 additions & 0 deletions 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 <amjith.r@gmail.com>
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,

0 comments on commit d7d7ecb

Please sign in to comment.