Skip to content

Commit

Permalink
Rebasing docker#7031 into current development on 1.26.x
Browse files Browse the repository at this point in the history
----

Downgrade gitpython to 2.1.15 and idna to 2.8

Signed-off-by: Ulysses Souza <[email protected]>

Removed Python2 support

Closes: docker#6890

Signed-off-by: Bastian Venthur <[email protected]>

Removed six

Signed-off-by: Bastian Venthur <[email protected]>
  • Loading branch information
ulyssessouza authored and alex-ubitec committed Mar 11, 2020
1 parent 1263790 commit e61c2fe
Show file tree
Hide file tree
Showing 81 changed files with 95 additions and 388 deletions.
7 changes: 2 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
sha: v1.3.4
hooks:
- id: reorder-python-imports
language_version: 'python2.7'
language_version: 'python3.7'
args:
- --add-import
- from __future__ import absolute_import
- --add-import
- from __future__ import unicode_literals
- --py3-plus
3 changes: 0 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ RUN apk add --no-cache \
musl-dev \
openssl \
openssl-dev \
python2 \
python2-dev \
zlib-dev
ENV BUILD_BOOTLOADER=1

Expand All @@ -40,7 +38,6 @@ RUN apt-get update && apt-get install --no-install-recommends -y \
libssl-dev \
make \
openssl \
python2.7-dev \
zlib1g-dev

FROM build-${BUILD_PLATFORM} AS build
Expand Down
3 changes: 0 additions & 3 deletions bin/docker-compose
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/usr/bin/env python
from __future__ import absolute_import
from __future__ import unicode_literals

from compose.cli.main import main
main()
2 changes: 0 additions & 2 deletions compose/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
from __future__ import absolute_import
from __future__ import unicode_literals

__version__ = '1.26.0-rc1'
3 changes: 0 additions & 3 deletions compose/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from __future__ import absolute_import
from __future__ import unicode_literals

from compose.cli.main import main

main()
3 changes: 0 additions & 3 deletions compose/cli/colors.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from __future__ import absolute_import
from __future__ import unicode_literals

from ..const import IS_WINDOWS_PLATFORM

NAMES = [
Expand Down
7 changes: 1 addition & 6 deletions compose/cli/command.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
from __future__ import absolute_import
from __future__ import unicode_literals

import logging
import os
import re

import six

from . import errors
from .. import config
from .. import parallel
Expand Down Expand Up @@ -110,7 +105,7 @@ def get_config_from_options(base_dir, options, additional_options=None):

def get_config_path_from_options(base_dir, options, environment):
def unicode_paths(paths):
return [p.decode('utf-8') if isinstance(p, six.binary_type) else p for p in paths]
return [p.decode('utf-8') if isinstance(p, bytes) else p for p in paths]

file_option = options.get('--file')
if file_option:
Expand Down
3 changes: 0 additions & 3 deletions compose/cli/docker_client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from __future__ import absolute_import
from __future__ import unicode_literals

import logging
import os.path
import ssl
Expand Down
3 changes: 0 additions & 3 deletions compose/cli/docopt_command.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from __future__ import absolute_import
from __future__ import unicode_literals

from inspect import getdoc

from docopt import docopt
Expand Down
3 changes: 0 additions & 3 deletions compose/cli/errors.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from __future__ import absolute_import
from __future__ import unicode_literals

import contextlib
import logging
import socket
Expand Down
6 changes: 1 addition & 5 deletions compose/cli/formatter.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
from __future__ import absolute_import
from __future__ import unicode_literals

import logging
import shutil

import six
import texttable

from compose.cli import colors
Expand Down Expand Up @@ -57,7 +53,7 @@ def get_level_message(self, record):
return ''

def format(self, record):
if isinstance(record.msg, six.binary_type):
if isinstance(record.msg, bytes):
record.msg = record.msg.decode('utf-8')
message = super(ConsoleWarningFormatter, self).format(record)
return '{0}{1}'.format(self.get_level_message(record), message)
9 changes: 3 additions & 6 deletions compose/cli/log_printer.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
from __future__ import absolute_import
from __future__ import unicode_literals

import _thread as thread
import sys
from collections import namedtuple
from itertools import cycle
from queue import Empty
from queue import Queue
from threading import Thread

from docker.errors import APIError
from six.moves import _thread as thread
from six.moves.queue import Empty
from six.moves.queue import Queue

from . import colors
from compose import utils
Expand Down
4 changes: 0 additions & 4 deletions compose/cli/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals

import contextlib
import functools
import json
Expand Down
3 changes: 0 additions & 3 deletions compose/cli/signals.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from __future__ import absolute_import
from __future__ import unicode_literals

import signal

from ..const import IS_WINDOWS_PLATFORM
Expand Down
7 changes: 1 addition & 6 deletions compose/cli/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals

import math
import os
import platform
Expand All @@ -10,7 +6,6 @@
import sys

import docker
import six

import compose
from ..const import IS_WINDOWS_PLATFORM
Expand Down Expand Up @@ -144,7 +139,7 @@ def human_readable_file_size(size):


def binarystr_to_unicode(s):
if not isinstance(s, six.binary_type):
if not isinstance(s, bytes):
return s

if IS_WINDOWS_PLATFORM:
Expand Down
9 changes: 2 additions & 7 deletions compose/cli/verbose_proxy.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
from __future__ import absolute_import
from __future__ import unicode_literals

import functools
import logging
import pprint
from itertools import chain

import six


def format_call(args, kwargs):
args = (repr(a) for a in args)
kwargs = ("{0!s}={1!r}".format(*item) for item in six.iteritems(kwargs))
kwargs = ("{0!s}={1!r}".format(*item) for item in kwargs.items())
return "({0})".format(", ".join(chain(args, kwargs)))


Expand Down Expand Up @@ -41,7 +36,7 @@ def __init__(self, obj_name, obj, log_name=None, max_lines=10):
def __getattr__(self, name):
attr = getattr(self.obj, name)

if not six.callable(attr):
if not callable(attr):
return attr

return functools.partial(self.proxy_callable, name)
Expand Down
3 changes: 0 additions & 3 deletions compose/config/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# flake8: noqa
from __future__ import absolute_import
from __future__ import unicode_literals

from . import environment
from .config import ConfigurationError
from .config import DOCKER_CONFIG_KEYS
Expand Down
22 changes: 9 additions & 13 deletions compose/config/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from __future__ import absolute_import
from __future__ import unicode_literals

import functools
import io
import logging
Expand All @@ -11,7 +8,6 @@
from collections import namedtuple
from operator import attrgetter

import six
import yaml
from cached_property import cached_property

Expand Down Expand Up @@ -204,7 +200,7 @@ def version(self):
'Compose file version 1.'.format(self.filename))
return V1

if not isinstance(version, six.string_types):
if not isinstance(version, str):
raise ConfigurationError(
'Version in "{}" is invalid - it should be a string.'
.format(self.filename))
Expand Down Expand Up @@ -688,12 +684,12 @@ def resolve_environment(service_dict, environment=None):
env.update(env_vars_from_file(env_file))

env.update(parse_environment(service_dict.get('environment')))
return dict(resolve_env_var(k, v, environment) for k, v in six.iteritems(env))
return dict(resolve_env_var(k, v, environment) for k, v in env.items())


def resolve_build_args(buildargs, environment):
args = parse_build_arguments(buildargs)
return dict(resolve_env_var(k, v, environment) for k, v in six.iteritems(args))
return dict(resolve_env_var(k, v, environment) for k, v in args.items())


def validate_extended_service_dict(service_dict, filename, service):
Expand Down Expand Up @@ -780,7 +776,7 @@ def process_service(service_config):


def process_build_section(service_dict, working_dir):
if isinstance(service_dict['build'], six.string_types):
if isinstance(service_dict['build'], str):
service_dict['build'] = resolve_build_path(working_dir, service_dict['build'])
elif isinstance(service_dict['build'], dict):
if 'context' in service_dict['build']:
Expand Down Expand Up @@ -848,7 +844,7 @@ def process_healthcheck(service_dict):
hc['test'] = ['NONE']

for field in ['interval', 'timeout', 'start_period']:
if field not in hc or isinstance(hc[field], six.integer_types):
if field not in hc or isinstance(hc[field], int):
continue
hc[field] = parse_nanoseconds_int(hc[field])

Expand Down Expand Up @@ -1179,7 +1175,7 @@ def parse_sequence_func(seq):
def merge_build(output, base, override):
def to_dict(service):
build_config = service.get('build', {})
if isinstance(build_config, six.string_types):
if isinstance(build_config, str):
return {'context': build_config}
return build_config

Expand Down Expand Up @@ -1389,7 +1385,7 @@ def normalize_build(service_dict, working_dir, environment):
if 'build' in service_dict:
build = {}
# Shortcut where specifying a string is treated as the build context
if isinstance(service_dict['build'], six.string_types):
if isinstance(service_dict['build'], str):
build['context'] = service_dict.pop('build')
else:
build.update(service_dict['build'])
Expand All @@ -1415,7 +1411,7 @@ def validate_paths(service_dict):
if 'build' in service_dict:
build = service_dict.get('build', {})

if isinstance(build, six.string_types):
if isinstance(build, str):
build_path = build
elif isinstance(build, dict) and 'context' in build:
build_path = build['context']
Expand Down Expand Up @@ -1506,7 +1502,7 @@ def merge_list_or_string(base, override):
def to_list(value):
if value is None:
return []
elif isinstance(value, six.string_types):
elif isinstance(value, str):
return [value]
else:
return value
Expand Down
6 changes: 1 addition & 5 deletions compose/config/environment.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
from __future__ import absolute_import
from __future__ import unicode_literals

import logging
import os
import re

import dotenv
import six

from ..const import IS_WINDOWS_PLATFORM
from .errors import ConfigurationError
Expand All @@ -16,7 +12,7 @@


def split_env(env):
if isinstance(env, six.binary_type):
if isinstance(env, bytes):
env = env.decode('utf-8', 'replace')
key = value = None
if '=' in env:
Expand Down
2 changes: 0 additions & 2 deletions compose/config/errors.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import absolute_import
from __future__ import unicode_literals


VERSION_EXPLANATION = (
Expand Down
Loading

0 comments on commit e61c2fe

Please sign in to comment.