Skip to content

Commit

Permalink
compat: pip 10
Browse files Browse the repository at this point in the history
  • Loading branch information
hartym committed Apr 19, 2018
1 parent 40122f8 commit e841fca
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 31 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Medikit 0.5.20 on 2018-04-14.
# Generated by Medikit 0.5.20 on 2018-04-19.
# All changes will be overriden.
# Edit Projectfile and run “make update” (or “medikit update”) to regenerate.

Expand Down Expand Up @@ -36,7 +36,7 @@ else ifneq ($(QUICK),)
@printf "Skipping \033[36m%s\033[0m because \033[36m$$QUICK\033[0m is not empty.\n" $(target)
else
@printf "Applying \033[36m%s\033[0m target...\n" $(target)
$(PIP) install $(PIP_INSTALL_OPTIONS) -U "pip <10" wheel
$(PIP) install $(PIP_INSTALL_OPTIONS) -U "pip ~=10.0" wheel
$(PIP) install $(PIP_INSTALL_OPTIONS) -U -r $(PYTHON_REQUIREMENTS_FILE)
@mkdir -p .medikit; touch $@
endif
Expand All @@ -54,7 +54,7 @@ else ifneq ($(QUICK),)
@printf "Skipping \033[36m%s\033[0m because \033[36m$$QUICK\033[0m is not empty.\n" $(target)
else
@printf "Applying \033[36m%s\033[0m target...\n" $(target)
$(PIP) install $(PIP_INSTALL_OPTIONS) -U "pip <10" wheel
$(PIP) install $(PIP_INSTALL_OPTIONS) -U "pip ~=10.0" wheel
$(PIP) install $(PIP_INSTALL_OPTIONS) -U -r $(PYTHON_REQUIREMENTS_DEV_FILE)
@mkdir -p .medikit; touch $@
endif
Expand All @@ -79,7 +79,7 @@ release: medikit ## Runs the "release" pipeline.
$(MEDIKIT) pipeline release start

medikit: # Checks installed medikit version and updates it if it is outdated.
@$(PYTHON) -c 'import medikit, pip, sys; from packaging.version import Version; sys.exit(0 if (Version(medikit.__version__) >= Version("$(MEDIKIT_VERSION)")) and (Version(pip.__version__) < Version("10")) else 1)' || $(PYTHON) -m pip install -U "pip <10" "medikit>=$(MEDIKIT_VERSION)"
@$(PYTHON) -c 'import medikit, pip, sys; from packaging.version import Version; sys.exit(0 if (Version(medikit.__version__) >= Version("$(MEDIKIT_VERSION)")) and (Version(pip.__version__) < Version("10")) else 1)' || $(PYTHON) -m pip install -U "pip ~=10.0" "medikit>=$(MEDIKIT_VERSION)"

update: medikit ## Update project artifacts using medikit.
$(MEDIKIT) update $(MEDIKIT_UPDATE_OPTIONS)
Expand Down
3 changes: 1 addition & 2 deletions Projectfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ python.add_requirements(
'jinja2 ~=2.9',
'mondrian ~=0.6.5',
'packaging ~=17.0',
'pip <10',
'pip-tools ~=1.11',
'pip-tools ~=2.0.1',
'stevedore ~=1.28',
'whistle ~=1.0',
'yapf ~=0.20',
Expand Down
12 changes: 0 additions & 12 deletions medikit/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
import sys

from medikit._version import __version__

try:
from pip.req import parse_requirements
except ImportError:
print('Medikit is not yet compatible with pip 10 (like all libraries that depended on any internal api).')
print()
print('Please switch back to pip 9.')
print()
print(' $ pip install "pip ~=9.0"')
sys.exit(1)


def listen(*args, **kwargs):
raise NotImplementedError('This is a stub.')
Expand Down
2 changes: 1 addition & 1 deletion medikit/feature/make/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def add_medikit_targets(self, config):

self.makefile.add_target(
'medikit',
'@$(PYTHON) -c {!r} || $(PYTHON) -m pip install -U "pip <10" "medikit>=$(MEDIKIT_VERSION)"'.format(
'@$(PYTHON) -c {!r} || $(PYTHON) -m pip install -U "pip ~=10.0" "medikit>=$(MEDIKIT_VERSION)"'.format(
'; '.join(source)
),
phony=True,
Expand Down
12 changes: 6 additions & 6 deletions medikit/feature/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
import tempfile
from getpass import getuser

from pip._vendor.distlib.util import parse_requirement
from pip.req import parse_requirements
from piptools.repositories import PyPIRepository
from piptools.resolver import Resolver
from piptools.scripts.compile import get_pip_command
from piptools.utils import format_requirement
from piptools._vendored.pip.req import parse_requirements
from piptools._vendored.pip._vendor.distlib.util import parse_requirement

from medikit.events import subscribe
from medikit.feature import Feature, ABSOLUTE_PRIORITY
Expand Down Expand Up @@ -247,7 +247,7 @@ def on_make_generate(self, event):
event.makefile['PIP_INSTALL_OPTIONS'] = ''

event.makefile.get_target('install').install = [
'$(PIP) install $(PIP_INSTALL_OPTIONS) -U "pip <10" wheel',
'$(PIP) install $(PIP_INSTALL_OPTIONS) -U "pip ~=10.0" wheel',
'$(PIP) install $(PIP_INSTALL_OPTIONS) -U -r $(PYTHON_REQUIREMENTS_FILE)',
]
event.makefile.get_target('install').deps += ['$(PYTHON_REQUIREMENTS_FILE)', 'setup.py']
Expand All @@ -257,7 +257,7 @@ def on_make_generate(self, event):
reqs_var = 'PYTHON_REQUIREMENTS_' + extra.upper().replace('-', '_') + '_FILE'

target.install += [
'$(PIP) install $(PIP_INSTALL_OPTIONS) -U "pip <10" wheel',
'$(PIP) install $(PIP_INSTALL_OPTIONS) -U "pip ~=10.0" wheel',
'$(PIP) install $(PIP_INSTALL_OPTIONS) -U -r $(' + reqs_var + ')',
]
target.deps += ['$(PYTHON_REQUIREMENTS_FILE)', '$(' + reqs_var + ')', 'setup.py']
Expand Down Expand Up @@ -360,7 +360,7 @@ def on_end(self, event):
session = pip_command._build_session(pip_options)
repository = PyPIRepository(pip_options, session)

for extra in itertools.chain((None, ), python_config.get_extras()):
for extra in itertools.chain((None,), python_config.get_extras()):
requirements_file = 'requirements{}.txt'.format('-' + extra if extra else '')

if python_config.override_requirements or not os.path.exists(requirements_file):
Expand All @@ -382,7 +382,7 @@ def on_end(self, event):
'\n'.join(
(
'-e .{}'.format('[' + extra + ']' if extra else ''),
*(('-r requirements.txt', ) if extra else ()),
*(('-r requirements.txt',) if extra else ()),
*sorted(
format_requirement(req) for req in resolver.resolve(max_rounds=10)
if req.name != python_config.get('name')
Expand Down
2 changes: 1 addition & 1 deletion medikit/steps/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class Install(System):
def __init__(self, *packages):
if not len(packages):
packages = ('pip <10', 'wheel', 'twine')
packages = ('pip ~=10.0', 'wheel', 'twine')
packages = list(sorted(packages))
super().__init__(sys.executable + ' -m pip install --upgrade ' + ' '.join(map(repr, packages)))
self.__args__ = (*packages, )
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
alabaster==0.7.10
attrs==17.4.0
babel==2.5.3
certifi==2018.1.18
certifi==2018.4.16
chardet==3.0.4
coverage==4.5.1
docutils==0.14
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ markupsafe==1.0
mondrian==0.6.6
packaging==17.1
pbr==4.0.2
pip-tools==1.11.0
pip-tools==2.0.1
pyparsing==2.2.0
semantic-version==2.6.0
six==1.11.0
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Medikit 0.5.20 on 2018-04-14.
# Generated by Medikit 0.5.20 on 2018-04-19.
# All changes will be overriden.
# Edit Projectfile and run “make update” (or “medikit update”) to regenerate.

Expand Down Expand Up @@ -54,8 +54,8 @@ def execfile(fname, globs, locs=None):
packages=find_packages(exclude=['ez_setup', 'example', 'test']),
include_package_data=True,
install_requires=[
'git-semver (~= 0.2.1)', 'jinja2 (~= 2.9)', 'mondrian (~= 0.6.5)', 'packaging (~= 17.0)', 'pip (< 10)',
'pip-tools (~= 1.11)', 'stevedore (~= 1.28)', 'whistle (~= 1.0)', 'yapf (~= 0.20)'
'git-semver (~= 0.2.1)', 'jinja2 (~= 2.9)', 'mondrian (~= 0.6.5)', 'packaging (~= 17.0)',
'pip-tools (~= 2.0.1)', 'stevedore (~= 1.28)', 'whistle (~= 1.0)', 'yapf (~= 0.20)'
],
extras_require={
'dev': [
Expand Down

0 comments on commit e841fca

Please sign in to comment.