Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate: Remove Python2.7 installation support #1416

Merged
merged 42 commits into from
Oct 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
66515dc
Remove Py2 support
jfuss Sep 17, 2019
c72e7f4
Remove dependecies needed for Py2
jfuss Sep 17, 2019
0ab2cae
Upgrade dev dependencies
jfuss Sep 17, 2019
533218e
Handle Unnecessary pass statement
jfuss Sep 17, 2019
6833ff7
Handle useless-object-inheritance
jfuss Sep 17, 2019
134dba8
Handle wrong-import-order
jfuss Sep 17, 2019
f397092
Handle inconsistent-return-statements
jfuss Sep 17, 2019
8870014
Handle keyword-arg-before-vararg
jfuss Sep 17, 2019
af4ba9a
Handle raising-format-tuple
jfuss Sep 17, 2019
21e3e9b
Handle no-else-return
jfuss Sep 17, 2019
65f72c4
Handle consider-using-in
jfuss Sep 17, 2019
ac77973
Handle onsider-using-set-comprehension
jfuss Sep 17, 2019
9204ae2
move from 'from mock' to 'from unittest.mock' since mock is now in th…
jfuss Sep 17, 2019
40d4b8b
Use std's assertCountEqual instead of six's
jfuss Sep 17, 2019
7078124
removed six and six usage
jfuss Sep 18, 2019
38fcfd8
remove backport import statement for std library tempfile
jfuss Sep 18, 2019
7cce9a9
Remove pylint overriding due to Py2 to Py3 differences
jfuss Sep 18, 2019
7a75e84
Force python3 on windows in appveyor
jfuss Sep 18, 2019
73196f2
format using black
jfuss Sep 18, 2019
6464407
attempt to to make windows appveyor use py3 instead of py2
jfuss Sep 18, 2019
a7a9142
try PYTHON_VERSION instead of PYTHON
jfuss Sep 18, 2019
5f56464
Add python from matrix to path on windows
jfuss Sep 18, 2019
af1bdff
try non-quoted version
jfuss Sep 18, 2019
64ba491
try refreshenv
jfuss Sep 20, 2019
2ef451c
Use PYTHON_HOME instead of PYTHON env var
jfuss Sep 20, 2019
3399846
try only PYTHON_HOME
jfuss Sep 20, 2019
90e820c
remove refreshenv
jfuss Sep 20, 2019
0fe6eb7
try to fix unicode error in py37 on windows
jfuss Sep 20, 2019
20047f7
Revert "try to fix unicode error in py37 on windows"
jfuss Sep 23, 2019
8d8765c
Try forcing encoding
jfuss Sep 23, 2019
bfcbd5d
force encoding on file open
jfuss Sep 23, 2019
3500e81
Remove forced encoding on a template file
jfuss Sep 23, 2019
2f71529
remove un-needed dev requirements
jfuss Sep 23, 2019
1d0eb1a
Removed depreciation warning
jfuss Sep 23, 2019
19c81c7
Remove deprecation warning integ tests
jfuss Sep 23, 2019
c6fb7f9
Remove py27 formatting from black
jfuss Sep 24, 2019
e7861de
Ingore nose-parameterize warnings
jfuss Sep 24, 2019
ef1ae1e
Fix rebase conflicts
jfuss Oct 21, 2019
02a9ec1
format with black
jfuss Oct 21, 2019
6348db8
fix import order
jfuss Oct 21, 2019
2e61897
Add pytest-forked and timeout back to dev.txt
jfuss Oct 21, 2019
d0a1896
Handle further updates after rebasing with HEAD of develop
jfuss Oct 23, 2019
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
1 change: 1 addition & 0 deletions appveyor-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ environment:
HOME: 'C:\Users\appveyor'
HOMEDRIVE: 'C:'
HOMEPATH: 'C:\Users\appveyor'
NOSE_PARAMETERIZED_NO_WARN: 1

init:
# Uncomment this for RDP
Expand Down
6 changes: 6 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ environment:
- PYTHON_HOME: "C:\\Python36-x64"
PYTHON_VERSION: '3.6.8'
PYTHON_ARCH: '64'
NOSE_PARAMETERIZED_NO_WARN: 1

- PYTHON_HOME: "C:\\Python37-x64"
PYTHON_VERSION: '3.7.4'
PYTHON_ARCH: '64'
RUN_SMOKE: 1
NOSE_PARAMETERIZED_NO_WARN: 1

for:
-
Expand All @@ -30,12 +32,16 @@ for:
- "echo %PATH%"
- "python --version"
# Upgrade setuptools, wheel and virtualenv
- "SET PATH=%PYTHON_HOME%;%PATH%"
- "echo %PYTHON_HOME%"
- "echo %PATH%"
- "python -m pip install --upgrade setuptools wheel virtualenv"

# Create new virtual environment and activate it
- "rm -rf venv"
- "python -m virtualenv venv"
- "venv\\Scripts\\activate"
- "python --version"

build_script:
# Activate virtualenv again on windows
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ requires = ["setuptools", "wheel"] # PEP 508 specifications.

[tool.black]
line-length = 120
target_version = ['py37', 'py27', 'py36']
target_version = ['py37', 'py36']
exclude = '''

(
Expand All @@ -17,6 +17,7 @@ exclude = '''
| dist
| pip-wheel-metadata
| samcli/local/init/templates
| tests/integration/testdata
)/
)
'''
4 changes: 2 additions & 2 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[pytest]
env =
AWS_DEFAULT_REGION = ap-southeast-1
filterwarnings =
error
#filterwarnings =
# error
3 changes: 0 additions & 3 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
six~=1.11.0
chevron~=0.12
click~=7.0
enum34~=1.1.6; python_version<"3.4"
Flask~=1.0.2
boto3~=1.9, >=1.9.56
PyYAML~=5.1
Expand All @@ -10,7 +8,6 @@ aws-sam-translator==1.15.1
docker~=4.0
dateparser~=0.7
python-dateutil~=2.6
pathlib2~=2.3.2; python_version<"3.4"
requests==2.22.0
serverlessrepo==0.1.9
aws_lambda_builders==0.5.0
25 changes: 8 additions & 17 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
coverage==4.3.4
pytest-cov==2.4.0
# astroid > 2.0.4 is not compatible with pylint1.7
astroid>=1.5.8,<2.1.0
pylint==1.7.2
coverage==4.5.4
pytest-cov==2.7.1
pylint==2.3.1

# Test requirements
pytest==3.6.0
py==1.5.1
pluggy==0.6.0
mock==2.0.0
parameterized==0.6.1
pathlib2==2.3.2; python_version<"3.4"
futures==3.2.0; python_version<"3.2.3"
# Py3.2 backport
backports.tempfile==1.0
pytest-xdist==1.20.0
pytest-forked==1.0.2
pytest==5.2.1
parameterized==0.7.0
pytest-xdist==1.30.0
pytest-forked==1.1.3
pytest-timeout==1.3.3
pytest-rerunfailures==5.0
pytest-rerunfailures==7.0
19 changes: 4 additions & 15 deletions samcli/cli/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import logging
import importlib
import sys
from collections import OrderedDict

import click
Expand All @@ -24,13 +23,6 @@
"samcli.commands.publish",
]

DEPRECATION_NOTICE = (
"Deprecated : AWS SAM CLI no longer supports "
"installations on Python 2.7. "
"Install AWS SAM CLI via https://docs.aws.amazon.com/serverless-application-model/"
"latest/developerguide/serverless-sam-cli-install.html for continued support with new versions. \n"
)


class BaseCommand(click.MultiCommand):
"""
Expand All @@ -53,7 +45,7 @@ class BaseCommand(click.MultiCommand):
will produce a command name "baz".
"""

def __init__(self, cmd_packages=None, *args, **kwargs):
def __init__(self, *args, cmd_packages=None, **kwargs):
"""
Initializes the class, optionally with a list of available commands

Expand All @@ -69,9 +61,6 @@ def __init__(self, cmd_packages=None, *args, **kwargs):
self._commands = {}
self._commands = BaseCommand._set_commands(cmd_packages)

if sys.version_info.major == 2:
click.secho(DEPRECATION_NOTICE, fg="red", err=True)

@staticmethod
def _set_commands(package_names):
"""
Expand Down Expand Up @@ -109,18 +98,18 @@ def get_command(self, ctx, cmd_name):
"""
if cmd_name not in self._commands:
logger.error("Command %s not available", cmd_name)
return
return None

pkg_name = self._commands[cmd_name]

try:
mod = importlib.import_module(pkg_name)
except ImportError:
logger.exception("Command '%s' is not configured correctly. Unable to import '%s'", cmd_name, pkg_name)
return
return None

if not hasattr(mod, "cli"):
logger.error("Command %s is not configured correctly. It must expose an function called 'cli'", cmd_name)
return
return None

return mod.cli
6 changes: 5 additions & 1 deletion samcli/cli/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import click


class Context(object):
class Context:
"""
Top level context object for the CLI. Exposes common functionality required by a CLI, including logging,
environment config parsing, debug logging etc.
Expand Down Expand Up @@ -98,6 +98,8 @@ def command_path(self):
if click_core_ctx:
return click_core_ctx.command_path

return None

@staticmethod
def get_current_context():
"""
Expand Down Expand Up @@ -129,6 +131,8 @@ def my_command_handler(ctx):
if click_core_ctx:
return click_core_ctx.find_object(Context) or click_core_ctx.ensure_object(Context)

return None

def _refresh_session(self):
"""
Update boto3's default session by creating a new session based on values set in the context. Some properties of
Expand Down
7 changes: 2 additions & 5 deletions samcli/cli/global_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@
import logging
import uuid
import os
from pathlib import Path

import click

try:
from pathlib import Path
except ImportError: # pragma: no cover
from pathlib2 import Path # pragma: no cover

LOG = logging.getLogger(__name__)

Expand All @@ -21,7 +18,7 @@
TELEMETRY_ENABLED_KEY = "telemetryEnabled"


class GlobalConfig(object):
class GlobalConfig:
"""
Contains helper methods for global configuration files and values. Handles
configuration file creation, updates, and fetching in a platform-neutral way.
Expand Down
9 changes: 2 additions & 7 deletions samcli/commands/_utils/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@
"""

import os
import six
import pathlib
import yaml

try:
import pathlib
except ImportError:
import pathlib2 as pathlib

from samcli.yamlhelper import yaml_parse, yaml_dump


Expand Down Expand Up @@ -218,7 +213,7 @@ def _resolve_relative_to(path, original_root, new_root):
Updated path if the given path is a relative path. None, if the path is not a relative path.
"""

if not isinstance(path, six.string_types) or path.startswith("s3://") or os.path.isabs(path):
if not isinstance(path, str) or path.startswith("s3://") or os.path.isabs(path):
# Value is definitely NOT a relative path. It is either a S3 URi or Absolute path or not a string at all
return None

Expand Down
10 changes: 3 additions & 7 deletions samcli/commands/build/build_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@
import logging
import os
import shutil

try:
import pathlib
except ImportError:
import pathlib2 as pathlib
import pathlib

from samcli.local.docker.manager import ContainerManager
from samcli.commands.local.lib.sam_function_provider import SamFunctionProvider
Expand All @@ -21,7 +17,7 @@
LOG = logging.getLogger(__name__)


class BuildContext(object):
class BuildContext:

# Build directories need not be world writable.
# This is usually a optimal permission for directories
Expand Down Expand Up @@ -150,7 +146,7 @@ def functions_to_build(self):
available_function_message = "{} not found. Possible options in your template: {}" \
.format(self._function_identifier, all_functions)
LOG.info(available_function_message)
raise FunctionNotFound("Unable to find a Function with name '%s'", self._function_identifier)
raise FunctionNotFound("Unable to find a Function with name '{}'".format(self._function_identifier))

return [function]

Expand Down
1 change: 0 additions & 1 deletion samcli/commands/build/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ class InvalidBuildDirException(UserException):
"""
Value provided to --build-dir is invalid
"""
pass
2 changes: 1 addition & 1 deletion samcli/commands/init/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


@click.command(
"init", short_help="Init an AWS SAM application.", context_settings=dict(help_option_names=[u"-h", u"--help"])
"init", short_help="Init an AWS SAM application.", context_settings=dict(help_option_names=["-h", "--help"])
)
@click.option("-l", "--location", help="Template location (git, mercurial, http(s), zip, path)")
@click.option(
Expand Down
18 changes: 5 additions & 13 deletions samcli/commands/local/cli_common/invoke_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import errno
import json
import os
from pathlib import Path

import samcli.lib.utils.osutils as osutils
from samcli.lib.utils.stream_writer import StreamWriter
Expand All @@ -18,16 +19,8 @@
from .user_exceptions import InvokeContextException, DebugContextException
from ..lib.sam_function_provider import SamFunctionProvider

# This is an attempt to do a controlled import. pathlib is in the
# Python standard library starting at 3.4. This will import pathlib2,
# which is a backport of the Python Standard Library pathlib
try:
from pathlib import Path
except ImportError:
from pathlib2 import Path


class InvokeContext(object):
class InvokeContext:
"""
Sets up a context to invoke Lambda functions locally by parsing all command line arguments necessary for the
invoke.
Expand Down Expand Up @@ -350,11 +343,10 @@ def _get_debug_context(debug_port, debug_args, debugger_path):
except OSError as error:
if error.errno == errno.ENOENT:
raise DebugContextException("'{}' could not be found.".format(debugger_path))
else:
raise error

# We turn off pylint here due to https://github.com/PyCQA/pylint/issues/1660
if not debugger.is_dir(): # pylint: disable=no-member
raise error

if not debugger.is_dir():
raise DebugContextException("'{}' should be a directory with the debugger in it.".format(debugger_path))
debugger_path = str(debugger)

Expand Down
7 changes: 2 additions & 5 deletions samcli/commands/local/cli_common/options.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
"""
Common CLI options for invoke command
"""
from pathlib import Path

import click
from samcli.commands._utils.options import template_click_option, docker_click_options, parameter_override_click_option

try:
from pathlib import Path
except ImportError:
from pathlib2 import Path
from samcli.commands._utils.options import template_click_option, docker_click_options, parameter_override_click_option


def get_application_dir():
Expand Down
Loading