Skip to content

Commit 9e65427

Browse files
SG-41413 - CI - Dependencies to build python packages from source (#1014)
### ### Linked issues n/a ### Summarize your change. Install and set-up dependencies for Python/Pip to build its dependencies from source. ### Describe the reason for the change. Follow up on #1013 to install the needed dependencies to build Numpy and Cryptography from source. ### Describe what you have tested and on which operating system. CI ### Add a list of changes, and note any that might need special attention during the review. ### If possible, provide screenshots. --------- Signed-off-by: Roger Nelson <[email protected]> Signed-off-by: Cédrik Fuoco <[email protected]> Co-authored-by: Roger Nelson <[email protected]>
1 parent 5643dee commit 9e65427

File tree

6 files changed

+152
-35
lines changed

6 files changed

+152
-35
lines changed

.github/workflows/ci.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,43 @@ jobs:
246246
exit 1
247247
fi
248248
249+
- name: Install GCC 11 toolchain for Rocky Linux 8
250+
if: ${{ matrix.rocky-version == '8' }}
251+
run: |
252+
retry_count=0
253+
max_retries=5
254+
255+
until [ $retry_count -ge $max_retries ]; do
256+
echo "Attempt $((retry_count + 1)) of $max_retries"
257+
258+
if dnf install -y gcc-toolset-11-toolchain; then
259+
echo "GCC 11 toolchain installed successfully"
260+
break
261+
else
262+
retry_count=$((retry_count + 1))
263+
if [ $retry_count -lt $max_retries ]; then
264+
echo "Attempt $retry_count failed. Retrying in 5 seconds..."
265+
sleep 5
266+
fi
267+
fi
268+
done
269+
270+
if [ $retry_count -ge $max_retries ]; then
271+
echo "Failed to install GCC 11 toolchain after $max_retries attempts"
272+
exit 1
273+
fi
274+
275+
- name: Enable GCC 11 toolchain for Rocky Linux 8
276+
if: ${{ matrix.rocky-version == '8' }}
277+
run: |
278+
source /opt/rh/gcc-toolset-11/enable
279+
echo "/opt/rh/gcc-toolset-11/root/usr/bin" >> $GITHUB_PATH
280+
echo "CC=/opt/rh/gcc-toolset-11/root/usr/bin/gcc" >> $GITHUB_ENV
281+
echo "CXX=/opt/rh/gcc-toolset-11/root/usr/bin/g++" >> $GITHUB_ENV
282+
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" >> $GITHUB_ENV
283+
gcc --version
284+
g++ --version
285+
249286
- name: Check out repository code
250287
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # 4.1.7
251288
with:
@@ -735,6 +772,11 @@ jobs:
735772
run: |
736773
python -c "import sys; print(sys.executable)"
737774
775+
- name: Install Rust toolchain
776+
uses: dtolnay/rust-toolchain@0b1efabc08b657293548b77fb76cc02d26091c7e
777+
with:
778+
toolchain: stable
779+
738780
- name: Cache CMake for Windows
739781
uses: actions/cache@v4
740782
id: windows-cmake-cache
@@ -757,13 +799,20 @@ jobs:
757799
echo "export ACLOCAL_PATH=/c/msys64/usr/share/aclocal" >> ~/.bash_profile
758800
shell: msys2 {0}
759801

802+
- name: Add Rust to PATH for msys2
803+
run: |
804+
echo "export PATH=\"/c/Users/runneradmin/.cargo/bin:\$PATH\"" >> ~/.bash_profile
805+
shell: msys2 {0}
806+
760807
- name: Display environment variables
761808
run: |
762809
echo $PATH
763810
echo $ACLOCAL_PATH
764811
which python
765812
which python3
766813
which cmake
814+
rustc --version || echo "WARNING: Rust not found in msys2 PATH"
815+
cargo --version || echo "WARNING: Cargo not found in msys2 PATH"
767816
shell: msys2 {0}
768817

769818
- name: Prepare Qt folder

cmake/dependencies/python3.cmake

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,14 @@ SET(RV_DEPS_PYTHON_VERSION_SHORT
2929
"${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}"
3030
)
3131

32-
# This version is used for generating src/build/requirements.txt from requirements.txt.in template All platforms install OpenTimelineIO from git to ensure
33-
# consistent source builds.
32+
# This version is used for generating src/build/requirements.txt from requirements.txt.in template
3433
SET(_opentimelineio_version
3534
"${RV_DEPS_OTIO_VERSION}"
3635
)
3736

3837
SET(_pyside_version
3938
"${RV_DEPS_PYSIDE_VERSION}"
4039
)
41-
# Construct the full git URL for pip to use in requirements.txt Using this avoids @ symbol conflicts in CONFIGURE_FILE
42-
SET(_opentimelineio_pip_url
43-
"git+https://github.com/AcademySoftwareFoundation/OpenTimelineIO@v${_opentimelineio_version}#egg=OpenTimelineIO"
44-
)
4540

4641
SET(_python3_download_url
4742
"https://github.com/python/cpython/archive/refs/tags/v${_python3_version}.zip"
@@ -77,9 +72,6 @@ SET(_build_dir
7772
${RV_DEPS_BASE_DIR}/${_python3_target}/build
7873
)
7974

80-
# Note: OpenTimelineIO is now installed via requirements.txt from git URL for all platforms. This ensures consistent source builds across Windows, Mac, and
81-
# Linux.
82-
8375
FETCHCONTENT_DECLARE(
8476
${_pyside_target}
8577
URL ${_pyside_archive_url}
@@ -276,12 +268,21 @@ ELSE()
276268
SET(_otio_debug_env "")
277269
ENDIF()
278270

279-
# Single unified command for all platforms and build types
271+
# Using --no-binary :all: to ensure all packages with native extensions are built from source
272+
# against our custom Python build, preventing ABI compatibility issues.
280273
SET(_requirements_install_command
281274
${CMAKE_COMMAND} -E env
282275
${_otio_debug_env}
276+
)
277+
278+
# Only set OPENSSL_DIR if we built OpenSSL ourselves (not for Rocky Linux 8 CY2023 which uses system OpenSSL)
279+
IF(DEFINED RV_DEPS_OPENSSL_INSTALL_DIR)
280+
LIST(APPEND _requirements_install_command "OPENSSL_DIR=${RV_DEPS_OPENSSL_INSTALL_DIR}")
281+
ENDIF()
282+
283+
LIST(APPEND _requirements_install_command
283284
"CMAKE_ARGS=-DPYTHON_LIBRARY=${_python3_cmake_library} -DPYTHON_INCLUDE_DIR=${_include_dir} -DPYTHON_EXECUTABLE=${_python3_executable}"
284-
"${_python3_executable}" -s -E -I -m pip install --upgrade --no-cache-dir --force-reinstall -r "${_requirements_output_file}"
285+
"${_python3_executable}" -s -E -I -m pip install --upgrade --no-cache-dir --force-reinstall --no-binary :all: -r "${_requirements_output_file}"
285286
)
286287

287288
IF(RV_TARGET_WINDOWS)
@@ -383,13 +384,16 @@ IF(RV_TARGET_WINDOWS
383384
AND CMAKE_BUILD_TYPE MATCHES "^Debug$"
384385
)
385386
# OCIO v2.2's pybind11 doesn't find python<ver>.lib in Debug since the name is python<ver>_d.lib.
387+
# Also, Rust libraries (like cryptography via pyo3) look for python3.lib.
386388
ADD_CUSTOM_COMMAND(
387389
TARGET ${_python3_target}
388390
POST_BUILD
389391
COMMENT "Copying Debug Python lib as a unversionned file for Debug"
390392
COMMAND cmake -E copy_if_different ${_python3_implib} ${_python_release_libpath}
391-
COMMAND cmake -E copy_if_different ${_python3_implib} ${_python_release_in_bin_libpath} DEPENDS ${_python3_target} ${_requirements_output_file}
392-
${_requirements_input_file}
393+
COMMAND cmake -E copy_if_different ${_python3_implib} ${_python_release_in_bin_libpath}
394+
COMMAND cmake -E copy_if_different ${_lib_dir}/python${PYTHON_VERSION_MAJOR}_d.lib ${_lib_dir}/python${PYTHON_VERSION_MAJOR}.lib
395+
COMMAND cmake -E copy_if_different ${_bin_dir}/python${PYTHON_VERSION_MAJOR}_d.lib ${_bin_dir}/python${PYTHON_VERSION_MAJOR}.lib
396+
DEPENDS ${_python3_target} ${_requirements_output_file} ${_requirements_input_file}
393397
)
394398
ENDIF()
395399

docs/build_system/config_linux_rocky89.md

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ All other dependencies are shared across variations.
7373
1. [Install tools and build dependencies](rocky_install_tools_and_dependencies)
7474
2. [Install Pyenv / Python](rocky_install_pyenv_and_python)
7575
3. [Install CMake](rocky_install_cmake)
76-
4. [Install Qt](rocky_install_qt)
77-
5. [Build Open RV](rocky_build_openrv)
76+
4. [Install Rust](rocky_install_rust)
77+
5. [Install Qt](rocky_install_qt)
78+
6. [Build Open RV](rocky_build_openrv)
7879
6. [Building with Docker (Optional)](rocky_building_with_docker)
7980

8081

@@ -164,8 +165,30 @@ cmake --version # confirm the version of your newly installed version of CMake
164165
cmake version 3.31.6
165166
```
166167

168+
(rocky_install_rust)=
169+
### 4. Install Rust
170+
171+
````{warning}
172+
Rust version **1.92 or later** is required to build certain Python dependencies (such as cryptography).
173+
````
174+
175+
Install Rust using rustup, and add its installation path to your ~/.bashrc and apply the changes to your current terminal window:
176+
177+
```bash
178+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
179+
echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> ~/.bashrc
180+
source ~/.bashrc
181+
```
182+
183+
Verify that Rust is installed correctly:
184+
185+
```bash
186+
rustc --version
187+
cargo --version
188+
```
189+
167190
(rocky_install_qt)=
168-
### 4. Install Qt
191+
### 5. Install Qt
169192

170193
Download the latest open-source [Qt installer](https://www.qt.io/download-open-source). We do not recommend that you install Qt from other installable sources as it may introduce build issues.
171194

@@ -193,19 +216,19 @@ Note 1: If you install Qt at a different installation path, you will need to man
193216
Note 2: Qt modules for Logs, Android, iOS and WebAssembly are not required to build Open RV.
194217

195218
(rocky_build_openrv)=
196-
### 5. Build Open RV
219+
### 6. Build Open RV
197220

198221
Once the platform-specific installation process is complete, building Open RV follows the same process for all platforms. Please refer to the [Common Build Instructions](config_common_build.md) for the complete build process.
199222

200223
(rocky_building_with_docker)=
201-
### 6. Building with Docker (Optional)
224+
### 7. Building with Docker (Optional)
202225

203226
To build Open RV using Docker, use the provided Dockerfile found in this repository, which should already contain all required dependencies.
204227

205228
Please go through the cloning procedure found in the [common build process](config_common_build.md). Once cloned, get back here to build the docker image, run the container, and build Open RV within the docker container.
206229

207230

208-
#### 5.1. Build the image and run
231+
#### 7.1. Build the image and run
209232

210233
````{tabs}
211234
```{code-tab} bash Rocky 9
@@ -223,7 +246,7 @@ docker run -d openrv-rocky8 /bin/bash -c "sleep infinity"
223246

224247

225248

226-
#### 5.2. Create and run the container
249+
#### 7.2. Create and run the container
227250
```bash
228251
# Lookup the container id for openrv-rocky{8/9}
229252
docker container ls
@@ -237,11 +260,11 @@ docker container ls
237260
docker container exec -it <id> /bin/bash # replace 'id' with your value
238261
```
239262

240-
#### 5.3. Build Open RV in the container
263+
#### 7.3. Build Open RV in the container
241264

242265
Once you are into the container, you can follow the [common build process](config_common_build.md) to build Open RV.
243266

244-
#### 5.4. Copy the stage folder outside of the container
267+
#### 7.4. Copy the stage folder outside of the container
245268

246269
If you are on a host that is the same as, or compatible with, your version of Rocky Linux, you can copy the stage folder outside of the container and execute Open RV.
247270

docs/build_system/config_macos.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,18 @@ Most of the build requirements can be installed by running the following brew in
126126
127127
````{tabs}
128128
```{code-tab} bash VFX-CY2024
129-
brew install ninja readline sqlite3 xz zlib tcl-tk@8 autoconf automake libtool [email protected] yasm clang-format black meson nasm pkg-config glew
129+
brew install ninja readline sqlite3 xz zlib tcl-tk@8 autoconf automake libtool [email protected] yasm clang-format black meson nasm pkg-config glew rust
130130
```
131131
```{code-tab} bash VFX-CY2023
132-
brew install ninja readline sqlite3 xz zlib tcl-tk@8 autoconf automake libtool [email protected] yasm clang-format black meson nasm pkg-config glew
132+
brew install ninja readline sqlite3 xz zlib tcl-tk@8 autoconf automake libtool [email protected] yasm clang-format black meson nasm pkg-config glew rust
133133
```
134134
````
135135
136+
````{warning}
137+
Rust version **1.92 or later** is required to build certain Python dependencies (such as cryptography) that contain Rust components.
138+
Homebrew will install the latest stable version of Rust.
139+
````
140+
136141
Make sure `xcode-select -p` still returns `/Applications/Xcode.app/Contents/Developer`. If that is not the case, run `sudo xcode-select -s /Applications/Xcode.app`
137142
138143
(install_qt)=

docs/build_system/config_windows.md

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,11 @@ All other dependencies are shared across variations.
7474
4. [Install CMake](install_cmake)
7575
5. [Install Qt](install_windows_qt)
7676
6. [Install Strawberry Perl](install_strawberry_perl)
77-
7. [Install MSYS2](install_msys2)
77+
7. [Install Rust](install_rust)
78+
8. [Install MSYS2](install_msys2)
7879
1. [Install required MSYS2 pacman packages (from an MSYS2-MinGW64 shell)](install_msys2_packages)
79-
8. [Setup environment variables](setup_env)
80-
9. [Build Open RV](build_windows_openrv)
80+
9. [Setup environment variables](setup_env)
81+
10. [Build Open RV](build_windows_openrv)
8182

8283

8384
````{warning}
@@ -373,8 +374,33 @@ Take note of the installation path for Strawberry Perl, as it will be required i
373374
The default path is `C:\Strawberry`.
374375
````
375376

377+
(install_rust)=
378+
## 7. Install Rust
379+
380+
````{warning}
381+
Rust version **1.92 or later** is required to build certain Python dependencies (such as cryptography).
382+
````
383+
384+
Install Rust using rustup-init:
385+
386+
1. Download rustup-init from [https://win.rustup.rs/x86_64](https://win.rustup.rs/x86_64)
387+
2. Run `rustup-init.exe`
388+
3. Follow the prompts to complete the installation (the default options are recommended)
389+
4. After installation, close and reopen your terminal to apply the PATH changes
390+
391+
Verify that Rust is installed correctly and check the version:
392+
393+
```bash
394+
rustc --version
395+
cargo --version
396+
```
397+
398+
````{note}
399+
The Rust installation will be located at `%USERPROFILE%\.cargo\bin` (typically `C:\Users\<username>\.cargo\bin`). Do not forget to add the location to the PATH environment variable in [Setup environment variables](#setup_env).
400+
````
401+
376402
(install_msys2)=
377-
## 7. Install MSYS2
403+
## 8. Install MSYS2
378404

379405
````{warning}
380406
@@ -389,7 +415,7 @@ Download and install the latest [MSYS2](https://www.msys2.org/). Open RV is **NO
389415
MSYS2 is only used for convenience as it comes with a package manager with utility packages required for the Open RV build such as cmake, git, flex, bison, nasm, unzip, zip, etc.
390416

391417
(install_msys2_packages)=
392-
### 7.1 Install required MSYS2 pacman packages
418+
### 8.1 Install required MSYS2 pacman packages
393419

394420
````{note}
395421
The MSYS2 MingGW64 (mingw64.exe) terminal MUST be used.\
@@ -432,7 +458,7 @@ While installing the MSYS packages, review the list for any missing package. Som
432458
Note: To confirm which version/location of any tool used inside the MSYS shell, `where` can be used e.g. `where python`. If there's more than one path return, the top one will be used.
433459

434460
(setup_env)=
435-
### 8. Setup environment variables
461+
### 9. Setup environment variables
436462

437463
````{note}
438464
This is the step where the path of Strawberry Perl, Python, CMake and Qt will be needed.
@@ -447,28 +473,37 @@ These modifications will be added to the `.bash_profile` file located in the Use
447473
#### PATH environment variable
448474

449475
````{note}
450-
Update the CMake, Strawberry Perl and Python location to reflect your installation path, using **forward slashes (/)** for a Unix-style path
476+
Update the CMake, Strawberry Perl, Python, and Rust locations to reflect your installation paths, using **forward slashes (/)** for a Unix-style path
451477
to prevent issues later on.
452478
(e.g., C:\Python310 becomes /c/Python310).
479+
480+
**For Rust:** Replace `<username>` with your actual Windows username. You can find your username by running `echo %USERNAME%` in a Windows command prompt.
481+
The Rust installation is located at `%USERPROFILE%\.cargo\bin` (typically `C:\Users\<username>\.cargo\bin`),
482+
which becomes `/c/Users/<username>/.cargo/bin` in MSYS2 format.
453483
````
454484

455485
The following paths **must** be added to the PATH environment variable within MSYS2:
456486
- CMake binary directory
457487
- Python binary directory
488+
- Rust cargo binary directory
458489
- MSYS2's `mingw64/bin`
459490
- Strawberry perl directory
460491

461492
**The order is important**. Do not put Strawberry perl location before MSYS2's `mingw64/bin` directory.
462493

463494
````{tabs}
464495
```{code-tab} bash VFX-CY2024
465-
echo 'export PATH="/c/Program Files/CMake/bin:/c/Python311:/c/msys64/mingw64/bin:$PATH:/c/Strawberry/perl/bin"' >> ~/.bash_profile
496+
echo 'export PATH="/c/Program Files/CMake/bin:/c/Python311:/c/Users/<username>/.cargo/bin:/c/msys64/mingw64/bin:$PATH:/c/Strawberry/perl/bin"' >> ~/.bash_profile
466497
```
467498
```{code-tab} bash VFX-CY2023
468-
echo 'export PATH="/c/Program Files/CMake/bin:/c/Python310:/c/msys64/mingw64/bin:$PATH:/c/Strawberry/perl/bin"' >> ~/.bash_profile
499+
echo 'export PATH="/c/Program Files/CMake/bin:/c/Python310:/c/Users/<username>/.cargo/bin:/c/msys64/mingw64/bin:$PATH:/c/Strawberry/perl/bin"' >> ~/.bash_profile
469500
```
470501
````
471502

503+
````{warning}
504+
Remember to replace `<username>` with your actual Windows username in the commands above.
505+
````
506+
472507
#### ACLOCAL_PATH
473508

474509
```shell
@@ -501,7 +536,7 @@ source ~/.bash_profile
501536
```
502537

503538
(build_windows_openrv)=
504-
## 9. Build Open RV
539+
## 10. Build Open RV
505540

506541
Once the platform-specific installation process is complete, building Open RV follows the same process for all platforms. Please refer to the [Common Build Instructions](config_common_build.md) for the complete build process.
507542

src/build/requirements.txt.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# This file contains all the packages that will be packaged with RV. Please add the license next to the package.
22
# NOTE: This is a CMake template file. The actual requirements.txt is generated during CMake configuration.
33
# To update OpenTimelineIO version, edit _opentimelineio_version in cmake/dependencies/python3.cmake
4+
# NOTE: Using --no-binary :all: in pip install ensures all packages are built from source against our custom Python.
45

56
pip # License: MIT License (MIT)
67
setuptools # License: MIT License
7-
@_opentimelineio_pip_url@ # License: Other/Proprietary License (Modified Apache 2.0 License)
8+
opentimelineio==@_opentimelineio_version@ # License: Other/Proprietary License (Modified Apache 2.0 License)
89
PyOpenGL # License: BSD License (BSD)
910

1011
# MacOS only - PyOpenGL_accelerate is built from source in python3.cmake as a workaround until the fix

0 commit comments

Comments
 (0)