From 017f31675e7303cbdd40a0f79d7a0e7fdaec295d Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Fri, 1 Feb 2019 00:16:00 +0100 Subject: [PATCH 1/4] [setup] keep up with the removal of `--process-dependency-links` --- Dockerfile | 2 -- Makefile | 2 +- setup.py | 45 ++++++++++++++++++++++----------------------- 3 files changed, 23 insertions(+), 26 deletions(-) diff --git a/Dockerfile b/Dockerfile index 809bac5b6..453f9739b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,7 +22,6 @@ RUN sed \ --in-place=.org \ /app/requirements.txt \ && pip3 install \ - --process-dependency-links \ --no-cache-dir \ --requirement /app/requirements.txt \ && mv /app/requirements.txt.org /app/requirements.txt \ @@ -34,7 +33,6 @@ RUN sed \ COPY . /app RUN pip3 install \ - --process-dependency-links \ --no-cache-dir \ /app \ && rm -rf /app \ diff --git a/Makefile b/Makefile index aaa8b1b92..aa5638655 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ install-requirements: venv-create .PHONY: install install: venv-create rm -rf `find hangupsbot -name __pycache__` - $(pip) install . --process-dependency-links --upgrade + $(pip) install . --upgrade # update or reinstall all packages .PHONY: update-requirements diff --git a/setup.py b/setup.py index 69fa9daa1..66e52fd40 100644 --- a/setup.py +++ b/setup.py @@ -19,40 +19,40 @@ VERSION = VERSION_PATH.read_text().strip().split(' ')[-1].strip('"') INSTALL_REQUIRES = [] -DEPENDENCY_LINKS = [] +EDITABLE_LINKS = [] REQUIREMENTS_PATH = REPO / 'requirements' / 'requirements.txt' for line in REQUIREMENTS_PATH.read_text().split('\n'): line = line.strip() if not line or line[0] == '#': continue - if '//' in line: - if line.startswith('-e '): - line = line[3:] - DEPENDENCY_LINKS.append(line) + if line.startswith('-e '): + EDITABLE_LINKS.append(line) else: INSTALL_REQUIRES.append(line) -# pip and setuptools are not compatible here, their url schemes: -# - pip : `...#egg=pkg` -# - setuptools: `...#egg=pkg-version` -# The requirements.txt file stores the pip compatible ones. -# Parse the urls for the setuptools here: -# Support urls like this one, which includes the version as a tag/branch: -# `git+https://github.com/user/repo@v0.2.1#egg=pkg` -REGEX_TAG_NAME = re.compile(r'.*@v(?P.+)#egg=(?P.+)') -for line in DEPENDENCY_LINKS.copy(): - match = REGEX_TAG_NAME.match(line) +# pip requirements vs setuptools is a mess with editable url-dependencies: +# - pip requirement editable : `-e URL@TAG#egg=pkg` +# NOTE: the TAG must to be v prefixed +# - setuptools install_requires: `pkg @ URL` +# +# The requirements.txt file stores the pip compatible scheme. +# Parse the lines for the setuptools here: +REGEX_REQUIREMENT = re.compile(r'-e (?P\S+)#egg=(?P.+)') +for line in EDITABLE_LINKS: + match = REGEX_REQUIREMENT.match(line) if not match: raise RuntimeError( - '%r has an incompatible scheme, use a "v" prefixed tag or branch' - % line + 'Requirement %r has an incompatible scheme, required: %r' + % ( + line, + REGEX_REQUIREMENT.pattern, + ) ) - dependency_locked = match.group('name') + '==' + match.group('version') - - DEPENDENCY_LINKS.remove(line) - DEPENDENCY_LINKS.append(line + '-' + match.group('version')) - INSTALL_REQUIRES.append(dependency_locked) + compat_line = '{name} @ {url}'.format( + **match.groupdict() + ) + INSTALL_REQUIRES.append(compat_line) PACKAGES = [path[:-12].replace('/', '.') for path in glob.glob('hangupsbot/**/__init__.py', recursive=True)] @@ -66,7 +66,6 @@ name='hangupsbot', version=VERSION, install_requires=INSTALL_REQUIRES, - dependency_links=DEPENDENCY_LINKS, packages=PACKAGES, entry_points={ 'console_scripts': [ From 8d3be29c671c17ccf5177a4588e6a0fb99f5bb2f Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Fri, 1 Feb 2019 18:10:19 +0100 Subject: [PATCH 2/4] [make] upgrade pip in a new venv The venv module installs a packaged and outdated version of pip. --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index aa5638655..74793dc8b 100644 --- a/Makefile +++ b/Makefile @@ -61,6 +61,7 @@ localization: venv-create: $(pip) $(pip): ${python} -m venv $(venv) + $(pip) install --upgrade pip # house keeping: update the requirements.in file requirements/requirements.in: $(shell find hangupsbot -type d) From 24e652d6971949ce0bbca4774da95d76c84f8777 Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Fri, 1 Feb 2019 19:31:13 +0100 Subject: [PATCH 3/4] [travis] drop the upper version limit for pip --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6b1006736..53a727d08 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ matrix: # workaround py3.7 end before_install: - - $VIRTUAL_ENV/bin/pip install --upgrade 'pip<19' + - $VIRTUAL_ENV/bin/pip install --upgrade pip install: - make venv-dev venv=$VIRTUAL_ENV From 67323f29bd083236d1d936e4cf989887ba8632b7 Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Fri, 1 Feb 2019 20:50:19 +0100 Subject: [PATCH 4/4] [docker] install `pip>=18.1` for PEP508 support --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 453f9739b..7920fdbbc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,6 +14,7 @@ EXPOSE $PORTS RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone \ && mkdir /app \ +&& pip install --no-cache-dir --upgrade 'pip>=18.1' \ && true COPY requirements/requirements.txt /app