Skip to content

Commit

Permalink
Remove Python 2 support (#1622)
Browse files Browse the repository at this point in the history
Signed-off-by: Jean-Christophe Morin <[email protected]>
  • Loading branch information
JeanChristopheMorinPerso authored Feb 8, 2024
1 parent c700e99 commit 2a9a99c
Show file tree
Hide file tree
Showing 62 changed files with 242 additions and 572 deletions.
55 changes: 0 additions & 55 deletions .github/actions/setup-python/action.yaml

This file was deleted.

7 changes: 0 additions & 7 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@ updates:
# Check for updates to GitHub Actions every week
interval: "weekly"

# https://github.com/dependabot/dependabot-core/issues/6704
- package-ecosystem: "github-actions"
directory: "/.github/actions/setup-python"
schedule:
# Check for updates to GitHub Actions every week
interval: "weekly"

- package-ecosystem: "pip"
directory: "/docs"
schedule:
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/benchmark.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ jobs:
uses: actions/checkout@v4

- name: Setup python ${{ matrix.python-version }}
uses: ./.github/actions/setup-python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
os: ubuntu-latest

- name: Install Rez
run: |
Expand Down Expand Up @@ -92,10 +91,9 @@ jobs:
path: src

- name: Setup python ${{ matrix.python-version }}
uses: ./src/.github/actions/setup-python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
os: ubuntu-latest

# Note failing due to
# https://github.com/actions/virtual-environments/issues/675
Expand Down
62 changes: 8 additions & 54 deletions .github/workflows/installation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,91 +22,45 @@ jobs:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
python-version: ['2.7', '3.7', '3.8', '3.9', '3.10', '3.11']
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
method: ['install' ,'pip']

include:
# ubuntu
- os: ubuntu-latest
method: install
REZ_SET_PATH_COMMAND: 'export PATH=${PATH}:/opt/rez/bin/rez'
REZ_INSTALL_COMMAND: |
set -ex
if [[ "${MATRIX_PYTHON_VERSION}" == "2.7" ]]; then
eval "$(conda shell.bash hook)"
conda activate python
fi
python ./install.py /opt/rez
REZ_INSTALL_COMMAND: python ./install.py /opt/rez
- os: ubuntu-latest
method: pip
REZ_SET_PATH_COMMAND: 'export PATH=${PATH}:/opt/rez/bin PYTHONPATH=${PYTHONPATH}:/opt/rez'
REZ_INSTALL_COMMAND: |
set -ex
if [[ "${MATRIX_PYTHON_VERSION}" == "2.7" ]]; then
eval "$(conda shell.bash hook)"
conda activate python
fi
pip install --target /opt/rez .
REZ_INSTALL_COMMAND: pip install --target /opt/rez .
# macOS
- os: macos-latest
method: install
REZ_SET_PATH_COMMAND: 'export PATH=${PATH}:~/rez/bin/rez'
REZ_INSTALL_COMMAND: |
set -e
if [[ "${MATRIX_PYTHON_VERSION}" == "2.7" ]]; then
eval "$(conda shell.bash hook)"
conda activate python
echo "otool -L $(dirname $(which python))/../lib/libpython2.7.dylib"
otool -L $(dirname $(which python))/../lib/libpython2.7.dylib
echo "otool -l $(dirname $(which python))/../lib/libpython2.7.dylib"
otool -l $(dirname $(which python))/../lib/libpython2.7.dylib
fi
python ./install.py ~/rez
REZ_INSTALL_COMMAND: python ./install.py ~/rez
- os: macos-latest
method: pip
REZ_SET_PATH_COMMAND: 'export PATH="$PATH:~/rez/bin" PYTHONPATH=$PYTHONPATH:$HOME/rez'
REZ_INSTALL_COMMAND: |
set -ex
if [[ "${MATRIX_PYTHON_VERSION}" == "2.7" ]]; then
eval "$(conda shell.bash hook)"
conda activate python
fi
pip install --target ~/rez .
REZ_INSTALL_COMMAND: pip install --target ~/rez .
# windows
- os: windows-latest
method: install
REZ_SET_PATH_COMMAND: '$env:PATH="$env:PATH;C:\ProgramData\rez\Scripts\rez"'
REZ_INSTALL_COMMAND: |
if ($env:MATRIX_PYTHON_VERSION -eq "2.7") {
& 'C:\Miniconda\shell\condabin\conda-hook.ps1'
conda activate python
}
python ./install.py C:\ProgramData\rez
REZ_INSTALL_COMMAND: python ./install.py C:\ProgramData\rez
- os: windows-latest
method: pip
REZ_SET_PATH_COMMAND: '[System.Environment]::SetEnvironmentVariable("PATH","$env:PATH;C:\ProgramData\rez\bin"); $env:PYTHONPATH="$env:PYTHONPATH;C:\ProgramData\rez"'
REZ_INSTALL_COMMAND: |
if ($env:MATRIX_PYTHON_VERSION -eq "2.7") {
& 'C:\Miniconda\shell\condabin\conda-hook.ps1'
conda activate python
}
pip install --target C:\ProgramData\rez .
exclude:
- method: install
python-version: '2.7'
REZ_INSTALL_COMMAND: pip install --target C:\ProgramData\rez .

steps:
- uses: actions/checkout@v4

- name: Setup python ${{ matrix.python-version }}
uses: ./.github/actions/setup-python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
os: ${{ matrix.os }}

- name: Install
env:
Expand Down
12 changes: 0 additions & 12 deletions install.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,6 @@
import sys
import shutil
import subprocess

if sys.version_info[:2] < (3, 7):
sys.stderr.write(
'Error: rez can only be installed with python greater or equal to 3.7. You are trying to install using Python {0}.{1}.{2} ({3}).\n'.format(
sys.version_info[0],
sys.version_info[1],
sys.version_info[2],
sys.executable,
)
)
exit(1)

import venv


Expand Down
16 changes: 7 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@
print("install failed - requires setuptools", file=sys.stderr)
sys.exit(1)


if sys.version_info < (2, 7):
print("install failed - requires python v2.7 or greater", file=sys.stderr)
sys.exit(1)


# carefully import some sourcefiles that are standalone
source_path = os.path.dirname(os.path.realpath(__file__))
src_path = os.path.join(source_path, "src")
Expand Down Expand Up @@ -97,9 +91,13 @@ def find_files(pattern, path=None, root="rez"):
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Software Development",
"Topic :: System :: Software Distribution"
]
],
python_requires=">=3.7",
)
8 changes: 2 additions & 6 deletions src/rez/bind/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,14 @@
from rez.util import which
from rez.utils.execution import Popen
from rez.utils.logging_ import print_debug
from rez.vendor.six import six
from rez.utils.py23 import quote
from shlex import quote
import subprocess
import os.path
import os
import platform
import sys


basestring = six.string_types[0]


def log(msg):
if config.debug("bind_modules"):
print_debug(msg)
Expand Down Expand Up @@ -100,7 +96,7 @@ def extract_version(exepath, version_arg, word_index=-1, version_rank=3):
Returns:
`Version` object.
"""
if isinstance(version_arg, basestring):
if isinstance(version_arg, str):
version_arg = [version_arg]
args = [exepath] + version_arg

Expand Down
2 changes: 1 addition & 1 deletion src/rez/build_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from rez.config import config
from rez.vendor.enum import Enum
from contextlib import contextmanager
from rez.utils.py23 import quote
from shlex import quote
import getpass
import os.path
import sys
Expand Down
2 changes: 1 addition & 1 deletion src/rez/cli/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def load_plugin_cmd():
except Exception:
if config.debug("plugins"):
import traceback
from rez.vendor.six.six import StringIO
from io import StringIO
out = StringIO()
traceback.print_exc(file=out)
print_debug(out.getvalue())
Expand Down
6 changes: 1 addition & 5 deletions src/rez/cli/forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@

"""See util.create_forwarding_script()."""
import argparse
from rez.vendor.six import six

__doc__ = argparse.SUPPRESS


basestring = six.string_types[0]


def setup_parser(parser, completions=False):
parser.add_argument("YAML", type=str)
parser.add_argument("ARG", type=str, nargs=argparse.REMAINDER)
Expand Down Expand Up @@ -55,7 +51,7 @@ def command(opts, parser, extra_arg_groups=None):
nargs = doc.get("nargs", [])
kwargs = doc.get("kwargs", {})

if isinstance(doc["module"], basestring):
if isinstance(doc["module"], str):
# refers to a rez module
from rez.backport.importlib import import_module
namespace = "rez.%s" % doc["module"]
Expand Down
Loading

0 comments on commit 2a9a99c

Please sign in to comment.