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 diff --git a/Dockerfile b/Dockerfile index 809bac5b6..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 @@ -22,7 +23,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 +34,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..74793dc8b 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 @@ -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) 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': [