aws-deadline / deadline-cloud-for-cinema-4d

AWS Deadline Cloud for Cinema 4D
Apache License 2.0
9 stars 12 forks source link

feat: Only import openjd and deadline modules for Cinema 4D adaptor. #88

Closed karthikbekalp closed 1 week ago

karthikbekalp commented 2 weeks ago

What was the problem/requirement? (What/Why)

I observed that while building the Cinema 4D adaptor in Python 3.12, we would break Cinema 4D's python. This is because Cinema 4D's python was using Python 3.11 and it was failing to import modules that were compiled from Python 3.12.

2024/11/07 10:58:24-06:00 ADAPTOR_OUTPUT: STDOUT: (null)    import win32file
2024/11/07 10:58:24-06:00 ADAPTOR_OUTPUT: STDOUT: (null)ImportError: Module use of python312.dll conflicts with this version of Python.

What was the solution? (How)

Credits to @mwiebe for helping out with the fix. We essentially only import deadline and openjd modules that the adaptor needs.

This is similar to how Maya does it: https://github.com/aws-deadline/deadline-cloud-for-maya/blob/mainline/src/deadline/maya_adaptor/MayaAdaptor/adaptor.py#L373-L383

What is the impact of this change?

Now the adaptor and Cinema 4D's python versions can be different but it would still work.

How was this change tested?

To test this was a multi-step process:

2024/11/11 18:04:05-06:00 ADAPTOR_OUTPUT: STDOUT: ALF_PROGRESS 94.5833
2024/11/11 18:04:05-06:00 ADAPTOR_OUTPUT: STDOUT: ALF_PROGRESS 95.4167
2024/11/11 18:04:05-06:00 ADAPTOR_OUTPUT: STDOUT: ALF_PROGRESS 95.8333
2024/11/11 18:04:05-06:00 ADAPTOR_OUTPUT: STDOUT: ALF_PROGRESS 96.6667
2024/11/11 18:04:05-06:00 ADAPTOR_OUTPUT: STDOUT: ALF_PROGRESS 97.0833
2024/11/11 18:04:05-06:00 ADAPTOR_OUTPUT: STDOUT: ALF_PROGRESS 97.5
2024/11/11 18:04:05-06:00 ADAPTOR_OUTPUT: STDOUT: ALF_PROGRESS 97.9167
2024/11/11 18:04:05-06:00 ADAPTOR_OUTPUT: STDOUT: ALF_PROGRESS 98.3333
2024/11/11 18:04:05-06:00 ADAPTOR_OUTPUT: STDOUT: ALF_PROGRESS 98.75
2024/11/11 18:04:05-06:00 ADAPTOR_OUTPUT: STDOUT: ALF_PROGRESS 99.1667
2024/11/11 18:04:05-06:00 ADAPTOR_OUTPUT: STDOUT: ALF_PROGRESS 99.5833
2024/11/11 18:04:06-06:00 ADAPTOR_OUTPUT: STDOUT: Finished Rendering
2024/11/11 18:04:06-06:00 INFO: Done Cinema4DAdaptor main
2024/11/11 18:04:06-06:00 Process pid 4064 exited with code: 0 (unsigned) / 0x0 (hex)

Was this change documented?

Is this a breaking change?


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

sonarcloud[bot] commented 2 weeks ago

Quality Gate Passed Quality Gate passed

Issues
2 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

karthikbekalp commented 1 week ago

Is there a change we could make to OJD that would let things work without this hack? If so, let's open an issue in its repo.

Hmm, it might not be very straightforward. Ideally if one is using site packages then it should ideally generally work unless there are differences in the versions for python. I'll see if there is an issue in OJD regardless.