Skip to content

Commit

Permalink
DEV-2479: py38 upgrade
Browse files Browse the repository at this point in the history
This updates DTT to run with py38 and drops support for earlier python
versions. This change also includes running pyupgrade on the repository
and updating the github actions to run on supported operating systems.
  • Loading branch information
jiakf committed Feb 16, 2024
1 parent 254c55b commit 01f1957
Show file tree
Hide file tree
Showing 30 changed files with 240 additions and 261 deletions.
62 changes: 32 additions & 30 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,47 @@ on:
- develop
- release/**
- hotfix/**
- feat/dev-583-remove-set-env-in-github-actions
- feat/DEV-2479-upgrade-py38
tags:
- "*"
- '*'

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- macos-10.15
- macos-11
- macos-12
- macos-13
- ubuntu-20.04
- ubuntu-16.04
- ubuntu-18.04
- windows-latest
- ubuntu-22.04
- windows-2019
- windows-2022
python:
- 3.7
- 3.8
env:
GDC_CLIENT_ZIP: "gdc-client.zip"
GDC_CLIENT_ZIP: 'gdc-client.zip'
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: Run Tests
if: matrix.os != 'windows-latest'
run: |
python -m pip install --upgrade pip
pip install tox
tox -e py
- name: Package
run: |
cd bin
pip install virtualenv
. ./package
echo "GDC_CLIENT_ZIP=$GDC_CLIENT_ZIP" >> $GITHUB_ENV
shell: bash
- uses: actions/upload-artifact@v2
with:
name: ${{ env.GDC_CLIENT_ZIP }}-py${{ matrix.python }}-${{ matrix.os }}
path: bin/gdc-client_*.zip
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: Run Tests
if: matrix.os != 'windows-latest'
run: |
pip install --upgrade pip
pip install tox
tox -e py
- name: Package
run: |
cd bin
pip install virtualenv
. ./package
echo "GDC_CLIENT_ZIP=$GDC_CLIENT_ZIP" >> $GITHUB_ENV
shell: bash
- uses: actions/upload-artifact@v2
with:
name: ${{ env.GDC_CLIENT_ZIP }}-py${{ matrix.python }}-${{ matrix.os }}
path: bin/gdc-client_*.zip
4 changes: 1 addition & 3 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ tox:
parallel:
matrix:
- BUILD_PY_VERSION:
- python3.6
- python3.7
- python3.8
script:
- tox -r -e py


release:
before_script:
# unshallow the git repo to resolve version with setuptools_scm.
Expand Down
8 changes: 3 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@ install:
- virtualenv venv
- source venv/bin/activate
- pip install tox-travis tox-pyenv
- pyenv install 3.5.7
- pyenv install 3.6.9
- pyenv install 3.7.5
- pyenv install 3.8.18

script:
- pyenv local 3.5.7 3.6.9 3.7.5
- tox -e py35,py36,py37
- pyenv local 3.8.18
- tox -e py38

after_script:
- tox -e coverage
13 changes: 8 additions & 5 deletions bin/package
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

set -e
set -euox pipefail

function cleanup() {
# get rid of the virtualenv
Expand Down Expand Up @@ -69,7 +69,9 @@ esac
# setup.py is in previous dir
cd ..

python -m pip install -r requirements.txt
python -m pip install --upgrade pip
python -m pip install --no-deps -r requirements.txt
python -m pip install --no-deps .
python setup.py install

# go back go the ./gdc_client/bin dir
Expand All @@ -78,10 +80,10 @@ cd bin
echo "Building for ${TARGET_ENVIRONMENT}..."

# Make sure the correct version of pyinstaller and setuptools are installed
pip install -U "PyInstaller==3.5"
pip install -U PyInstaller

# Ran into ModuleNotFoundError: No module named 'pkg_resources.py2_warn' with higher versions of setuptools
pip install --upgrade 'setuptools<45.0.0'
pip install --upgrade setuptools

# Get version
VERSION=$(python -c "
Expand All @@ -96,6 +98,7 @@ pyinstaller \
--additional-hooks-dir=. \
--noconfirm \
--onefile \
--copy-metadata gdc-client \
-c gdc-client

echo "Testing produced binary..."
Expand All @@ -106,7 +109,7 @@ echo "Zipping binary..."
cd dist

PRE_ZIP_NAME="gdc-client_${VERSION}_${TARGET_ENVIRONMENT}_x64"
if [ -n "${DATE}" ]; then
if [ -n "${DATE+x}" ]; then
PRE_ZIP_NAME="gdc-client_${VERSION}_${DATE}_${TARGET_ENVIRONMENT}_x64"
fi

Expand Down
1 change: 1 addition & 0 deletions dev-requirements.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-c requirements.txt

click>= 8
flask~=1.0.2
pytest~=4.6.2
pytest-cov~=2.7.1
Expand Down
32 changes: 16 additions & 16 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# This file is autogenerated by pip-compile
# To update, run:
# This file is autogenerated by pip-compile with Python 3.8
# by the following command:
#
# pip-compile dev-requirements.in
#
Expand All @@ -14,12 +14,12 @@ aws-sam-translator==1.11.0
# cfn-lint
aws-xray-sdk==2.11.0
# via moto
boto==2.49.0
# via moto
boto3==1.16.63
# via
# aws-sam-translator
# moto
boto==2.49.0
# via moto
botocore==1.19.63
# via
# aws-xray-sdk
Expand All @@ -42,8 +42,10 @@ chardet==3.0.4
# via
# -c requirements.txt
# requests
click==7.1.2
# via flask
click==8.1.7
# via
# -r dev-requirements.in
# flask
coverage==5.5
# via pytest-cov
cryptography==2.8
Expand All @@ -68,9 +70,9 @@ idna==2.8
# -c requirements.txt
# moto
# requests
importlib-metadata==2.1.3
importlib-metadata==7.0.1
# via
# pluggy
# -c requirements.txt
# pytest
itsdangerous==1.1.0
# via flask
Expand Down Expand Up @@ -107,8 +109,6 @@ moto==1.3.16
# via -r dev-requirements.in
packaging==20.9
# via pytest
pathlib2==2.3.7.post1
# via pytest
pluggy==0.13.1
# via pytest
py==1.11.0
Expand All @@ -124,12 +124,12 @@ pycparser==2.21
# cffi
pyparsing==2.4.7
# via packaging
pytest-cov==2.7.1
# via -r dev-requirements.in
pytest==4.6.2
# via
# -r dev-requirements.in
# pytest-cov
pytest-cov==2.7.1
# via -r dev-requirements.in
python-dateutil==2.8.2
# via
# botocore
Expand All @@ -145,8 +145,6 @@ pyyaml==5.3.1
# -c requirements.txt
# cfn-lint
# moto
requests-mock==1.5.2
# via -r dev-requirements.in
requests==2.22.0
# via
# -c requirements.txt
Expand All @@ -156,6 +154,8 @@ requests==2.22.0
# moto
# requests-mock
# responses
requests-mock==1.5.2
# via -r dev-requirements.in
responses==0.17.0
# via moto
rsa==4.7.2
Expand All @@ -172,7 +172,6 @@ six==1.16.0
# ecdsa
# mock
# moto
# pathlib2
# pytest
# python-dateutil
# python-jose
Expand All @@ -199,8 +198,9 @@ wrapt==1.14.1
# via aws-xray-sdk
xmltodict==0.13.0
# via moto
zipp==1.2.0
zipp==3.17.0
# via
# -c requirements.txt
# importlib-metadata
# moto

Expand Down
4 changes: 2 additions & 2 deletions gdc_client/auth/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ def read_token_file(path):
# raise argparse.ArgumentTypeError(permissions_msg)

try:
ifs = open(abspath, "r")
except IOError as err:
ifs = open(abspath)
except OSError as err:
raise argparse.ArgumentTypeError(err)

with closing(ifs):
Expand Down
6 changes: 3 additions & 3 deletions gdc_client/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
GDC_API_PORT = 443


class GDCClient(object):
class GDCClient:
"""GDC API Requests Client"""

def __init__(self, host=GDC_API_HOST, port=GDC_API_PORT, token=None):
Expand All @@ -23,7 +23,7 @@ def __init__(self, host=GDC_API_HOST, port=GDC_API_PORT, token=None):

agent = " ".join(
[
"GDC-Client/{version}".format(version=version.__version__),
f"GDC-Client/{version.__version__}",
self.session.headers.get("User-Agent", "Unknown"),
]
)
Expand All @@ -43,7 +43,7 @@ def request(self, verb, path, **kwargs):
path=path,
),
auth=auth.GDCTokenAuth(self.token),
**kwargs
**kwargs,
)

with closing(res):
Expand Down
4 changes: 2 additions & 2 deletions gdc_client/client/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ def config(parser):
"-H",
"--host",
default=os.environ.get("GDC_API_HOST", GDC_API_HOST),
help="GDC API host [{host}]".format(host=GDC_API_HOST),
help=f"GDC API host [{GDC_API_HOST}]",
)

parser.add_argument(
"-P",
"--port",
default=os.environ.get("GDC_API_PORT", GDC_API_PORT),
help="GDC API port [{port}]".format(port=GDC_API_PORT),
help=f"GDC API port [{GDC_API_PORT}]",
)
12 changes: 5 additions & 7 deletions gdc_client/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ class GDCClientArgumentParser(argparse.ArgumentParser):

def error(self, message):
self.print_help(sys.stderr)
sys.stderr.write("\ngdc-client error: {}\n".format(message))
sys.stderr.write(f"\ngdc-client error: {message}\n")
sys.exit(2)


class GDCClientConfigShared(object):
class GDCClientConfigShared:
setting_getters = {
"server": ConfigParser.get,
"http_chunk_size": ConfigParser.getint,
Expand Down Expand Up @@ -106,13 +106,11 @@ def get_setting(self, section, option):
try:
return self.setting_getters[option](self.config, section, option)
except NoOptionError:
log.debug(
'Setting named "{}" not found in section "{}"'.format(option, section)
)
log.debug(f'Setting named "{option}" not found in section "{section}"')
except NoSectionError:
log.debug('No section named "{}" found'.format(section))
log.debug(f'No section named "{section}" found')
except KeyError:
log.debug('Invalid setting "{}"'.format(option))
log.debug(f'Invalid setting "{option}"')

# Return defaults if nothing was provided in config file

Expand Down
Loading

0 comments on commit 01f1957

Please sign in to comment.