Skip to content

Commit

Permalink
Change Python package update system
Browse files Browse the repository at this point in the history
The versions are hard-coded but also relaxed in some cases to allow
dependencies to be resolved easier.

The reason we hard-code version numbers is to ensure consistent
formatting/linting and documentation building.

Different Maya versions will require different Python versions and so
will require different package versions.

The "doc" and "dev" requirement files have been merged into a single
file for each Maya version because keeping all the files up to date
seemed like a bit of a nightmare, and doesn't seem to provide any extra
details. Instead the different needs of the packages are named in the
comments of the files.

The versions (where given) in these files are known to work today
(2024-09-16) with the Python versions expected. If the Python vesions
change in the future, these version numbers may need to be changed.
  • Loading branch information
david-cattermole committed Sep 16, 2024
1 parent 2a6f53f commit 67bedad
Show file tree
Hide file tree
Showing 32 changed files with 134 additions and 66 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_and_deploy_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r share/requirements-doc.txt
pip install -r share/python_requirements/requirements-github-build-and-deploy-docs.txt
- name: Building Sphinx Documentation
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint_code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r share/requirements-dev.txt
pip install -r share/python_requirements/requirements-github-lint-code.txt
- name: Analysing the Python code with flake8 (Hard Error)
run: |
Expand Down
2 changes: 1 addition & 1 deletion scripts/build_mmSolver_linux_maya2020.bash
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ MAYA_VERSION=2020
MAYA_LOCATION=/usr/autodesk/maya2020/

# Executable names/paths used for build process.
PYTHON_EXE=python
PYTHON_EXE=python3
CMAKE_EXE=cmake3
RUST_CARGO_EXE=cargo

Expand Down
2 changes: 1 addition & 1 deletion scripts/build_mmSolver_linux_maya2022.bash
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ MAYA_VERSION=2022
MAYA_LOCATION=/usr/autodesk/maya2022/

# Executable names/paths used for build process.
PYTHON_EXE=python
PYTHON_EXE=python3
CMAKE_EXE=cmake3
RUST_CARGO_EXE=cargo

Expand Down
2 changes: 1 addition & 1 deletion scripts/build_mmSolver_linux_maya2023.bash
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ MAYA_VERSION=2023
MAYA_LOCATION=/usr/autodesk/maya2023/

# Executable names/paths used for build process.
PYTHON_EXE=python
PYTHON_EXE=python3
CMAKE_EXE=cmake3
RUST_CARGO_EXE=cargo

Expand Down
3 changes: 3 additions & 0 deletions scripts/build_mmSolver_linux_maya2024.bash
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ MAYA_VERSION=2024
MAYA_LOCATION=/usr/autodesk/maya2024/

# Executable names/paths used for build process.
#
# RockyLinux8 has Python 3.6 by default, but we use Python 3.9 because
# it has better support for tools like 'ruff'.
PYTHON_EXE=python3.9
CMAKE_EXE=cmake3
RUST_CARGO_EXE=cargo
Expand Down
9 changes: 4 additions & 5 deletions scripts/internal/python_venv_activate.bash
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ fi
REQUIRE_PACKAGE_INSTALL=0
if [ ! -f "${PYTHON_VIRTUAL_ENV_ACTIVATE_SCRIPT}" ]; then
echo "Setting up Python Virtual Environment ${PYTHON_VIRTUAL_ENV_DIR_NAME}"
${PYTHON_EXE} --version
${PYTHON_EXE} -m venv ${PYTHON_VIRTUAL_ENV_DIR}
REQUIRE_PACKAGE_INSTALL=1
fi
Expand All @@ -69,13 +70,11 @@ source "${PYTHON_VIRTUAL_ENV_ACTIVATE_SCRIPT}"

# Install requirements
if [ ${REQUIRE_PACKAGE_INSTALL} -eq 1 ]; then
${PYTHON_EXE} --version
${PYTHON_EXE} -m pip install --upgrade pip

REQUIRE_DEV_MAYA_VERSION_FILE="${PROJECT_ROOT}/share/requirements-dev-maya${MAYA_VERSION}.txt"
REQUIRE_DOC_MAYA_VERSION_FILE="${PROJECT_ROOT}/share/requirements-doc-maya${MAYA_VERSION}.txt"

${PYTHON_EXE} -m pip install -r $REQUIRE_DEV_MAYA_VERSION_FILE
${PYTHON_EXE} -m pip install -r $REQUIRE_DOC_MAYA_VERSION_FILE
REQUIRE_MAYA_VERSION_FILE="${PROJECT_ROOT}/share/python_requirements/requirements-maya${MAYA_VERSION}.txt"
${PYTHON_EXE} -m pip install -r $REQUIRE_MAYA_VERSION_FILE
fi

cd ${PROJECT_ROOT}
9 changes: 5 additions & 4 deletions scripts/internal/python_venv_activate.bat
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ IF "%FRESH_PYTHON_VIRTUAL_ENV%"=="1" (
SET REQUIRE_PACKAGE_INSTALL=0
IF NOT EXIST %PYTHON_VIRTUAL_ENV_ACTIVATE_SCRIPT% (
ECHO Setting up Python Virtual Environment "%PYTHON_VIRTUAL_ENV_DIR_NAME%"
%PYTHON_EXE% --version
%PYTHON_EXE% -m venv %PYTHON_VIRTUAL_ENV_DIR%
SET REQUIRE_PACKAGE_INSTALL=1
)
Expand All @@ -65,12 +66,12 @@ ECHO Activating Python Virtual Environment "%PYTHON_VIRTUAL_ENV_DIR_NAME%"
CALL %PYTHON_VIRTUAL_ENV_ACTIVATE_SCRIPT%

:: Install requirements
SET MAYA_VERSION_REQUIRE_DEV_FILE=%PROJECT_ROOT%\share\requirements-dev-maya%MAYA_VERSION%.txt
SET MAYA_VERSION_REQUIRE_DOC_FILE=%PROJECT_ROOT%\share\requirements-doc-maya%MAYA_VERSION%.txt
SET MAYA_VERSION_REQUIRE_FILE=%PROJECT_ROOT%\share\python_requirements\requirements-maya%MAYA_VERSION%.txt
IF "%REQUIRE_PACKAGE_INSTALL%"=="1" (
%PYTHON_EXE% --version
:: TODO: Why is the PIP upgrade disabled on Windows? On Linux it's very important.
:: %PYTHON_EXE% -m pip install --upgrade pip
%PYTHON_EXE% -m pip install -r %MAYA_VERSION_REQUIRE_DEV_FILE%
%PYTHON_EXE% -m pip install -r %MAYA_VERSION_REQUIRE_DEV_FILE%
%PYTHON_EXE% -m pip install -r %MAYA_VERSION_REQUIRE_FILE%
)

:: Return back project root directory.
Expand Down
2 changes: 1 addition & 1 deletion scripts/python_venv_activate_maya2020.bash
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ PROJECT_ROOT=`pwd`
MAYA_VERSION=2020

# Python executable - edit this to point to an explicit python executable file.
PYTHON_EXE=python
PYTHON_EXE=python3

PYTHON_VIRTUAL_ENV_DIR_NAME="python_venv_linux_maya${MAYA_VERSION}"
source "${PROJECT_ROOT}/scripts/internal/python_venv_activate.bash"
2 changes: 1 addition & 1 deletion scripts/python_venv_activate_maya2022.bash
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ PROJECT_ROOT=`pwd`
MAYA_VERSION=2022

# Python executable - edit this to point to an explicit python executable file.
PYTHON_EXE=python
PYTHON_EXE=python3

PYTHON_VIRTUAL_ENV_DIR_NAME="python_venv_linux_maya${MAYA_VERSION}"
source "${PROJECT_ROOT}/scripts/internal/python_venv_activate.bash"
2 changes: 1 addition & 1 deletion scripts/python_venv_activate_maya2023.bash
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ PROJECT_ROOT=`pwd`
MAYA_VERSION=2023

# Python executable - edit this to point to an explicit python executable file.
PYTHON_EXE=python
PYTHON_EXE=python3

PYTHON_VIRTUAL_ENV_DIR_NAME="python_venv_linux_maya${MAYA_VERSION}"
source "${PROJECT_ROOT}/scripts/internal/python_venv_activate.bash"
9 changes: 9 additions & 0 deletions share/python_requirements/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Python Package Requirement Files

This directory is the home to "requirements.txt" files, which are used
by Python's PIP package manager to install python packages.

There are different files for different usages. The "github"
requirement files are used by various GitHub actions, and are reduced
to the minimum required dependencies, to improve speed of the GitHub
actions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# .github/workflows/build_and_deploy_docs.yml
#
# Expects Python 3.7.x

# Required packages for building documentation on GitHub.
#
# NOTE: No versions are specified to allow the package version resolver
# to resolve correctly.
Sphinx
furo
12 changes: 12 additions & 0 deletions share/python_requirements/requirements-github-lint-code.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# .github/workflows/lint_code.yml
#
# Expects Python 3.7.x

# Required packages for linting code on GitHub.
#
# NOTE: No versions are specified to allow the package version resolver
# to resolve correctly.
black
pylint
flake8
cpplint
17 changes: 17 additions & 0 deletions share/python_requirements/requirements-maya2018.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Python Package Requirements.
#
# Expects Python 3.6.x

# Tools needed for code linting and formatting.
#
# NOTE: No versions are explicitly to allow the PIP version resolver to find a match.
black
pylint
flake8
cpplint

# Tools needed for documentation building.
#
# NOTE: No versions are explicitly to allow the PIP version resolver to find a match.
Sphinx
furo
13 changes: 13 additions & 0 deletions share/python_requirements/requirements-maya2019.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Python Package Requirements.
#
# Expects Python 3.6.x

# Tools needed for code linting and formatting.
black == 22.8.0
pylint == 2.13.9
flake8 == 5.0.4
cpplint == 1.6.1

# Tools needed for documentation building.
Sphinx == 4.3.2
furo == 2022.4.7
13 changes: 13 additions & 0 deletions share/python_requirements/requirements-maya2020.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Python Package Requirements.
#
# Expects Python 3.6.x

# Tools needed for code linting and formatting.
black == 22.8.0
pylint == 2.13.9
flake8 == 5.0.4
cpplint == 1.6.1

# Tools needed for documentation building.
Sphinx == 4.3.2
furo == 2022.4.7
13 changes: 13 additions & 0 deletions share/python_requirements/requirements-maya2022.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Python Package Requirements.
#
# Expects Python 3.6.x

# Tools needed for code linting and formatting.
black == 22.8.0
pylint == 2.13.9
flake8 == 5.0.4
cpplint == 1.6.1

# Tools needed for documentation building.
Sphinx == 4.3.2
furo == 2022.4.7
13 changes: 13 additions & 0 deletions share/python_requirements/requirements-maya2023.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Python Package Requirements.
#
# Expects Python 3.6.x

# Tools needed for code linting and formatting.
black == 22.8.0
pylint == 2.13.9
flake8 == 5.0.4
cpplint == 1.6.1

# Tools needed for documentation building.
Sphinx == 4.3.2
furo == 2022.4.7
14 changes: 14 additions & 0 deletions share/python_requirements/requirements-maya2024.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Python Package Requirements.
#
# Expects Python 3.9.x

# Tools needed for code linting and formatting.
black == 24.8.0
pylint == 3.2.7
flake8 == 7.1.1
cpplint == 1.6.1
ruff == 0.6.5

# Tools needed for documentation building.
Sphinx == 7.4.7
furo == 2024.8.6
5 changes: 0 additions & 5 deletions share/requirements-dev-maya2018.txt

This file was deleted.

5 changes: 0 additions & 5 deletions share/requirements-dev-maya2019.txt

This file was deleted.

5 changes: 0 additions & 5 deletions share/requirements-dev-maya2020.txt

This file was deleted.

5 changes: 0 additions & 5 deletions share/requirements-dev-maya2022.txt

This file was deleted.

5 changes: 0 additions & 5 deletions share/requirements-dev-maya2023.txt

This file was deleted.

6 changes: 0 additions & 6 deletions share/requirements-dev-maya2024.txt

This file was deleted.

3 changes: 0 additions & 3 deletions share/requirements-doc-maya2018.txt

This file was deleted.

3 changes: 0 additions & 3 deletions share/requirements-doc-maya2019.txt

This file was deleted.

3 changes: 0 additions & 3 deletions share/requirements-doc-maya2020.txt

This file was deleted.

3 changes: 0 additions & 3 deletions share/requirements-doc-maya2022.txt

This file was deleted.

3 changes: 0 additions & 3 deletions share/requirements-doc-maya2023.txt

This file was deleted.

3 changes: 0 additions & 3 deletions share/requirements-doc-maya2024.txt

This file was deleted.

0 comments on commit 67bedad

Please sign in to comment.