Skip to content
This repository has been archived by the owner on Sep 16, 2021. It is now read-only.

[setup] hotfix for pip>=19 #103

Merged
merged 5 commits into from
Feb 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 \
Expand All @@ -34,7 +34,6 @@ RUN sed \

COPY . /app
RUN pip3 install \
--process-dependency-links \
--no-cache-dir \
/app \
&& rm -rf /app \
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
45 changes: 22 additions & 23 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]#egg=pkg`
REGEX_TAG_NAME = re.compile(r'.*@v(?P<version>.+)#egg=(?P<name>.+)')
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<url>\S+)#egg=(?P<name>.+)')
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)]
Expand All @@ -66,7 +66,6 @@
name='hangupsbot',
version=VERSION,
install_requires=INSTALL_REQUIRES,
dependency_links=DEPENDENCY_LINKS,
packages=PACKAGES,
entry_points={
'console_scripts': [
Expand Down