Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid PATH overflow from SetupPython calls #11215

Merged
merged 1 commit into from
Oct 29, 2020

Conversation

mmisol
Copy link
Collaborator

@mmisol mmisol commented Oct 28, 2020

Purpose

Calling Installer.SetupPython from Python.Included makes sure Python is
installed and also adds the install location to the PATH env variable.
The location is added to the PATH even if it was already there, so this
can potentially lead to an env variable overflow with the message
'Environment variable name or value is too long', after which the only
way to get CPython3 back to work would be to restart Dynamo.

The problem is avoided by remembering if Python was setup using a local
field. This should reduce the number of calls to a maximum of 2, which
is not the best (1 would be) but is far from resulting in an overflow.

Declarations

Check these if you believe they are true

  • The codebase is in a better state after this PR
  • Is documented according to the standards
  • The level of testing this PR includes is appropriate
  • User facing strings, if any, are extracted into *.resx files
  • All tests pass using the self-service CI.
  • Snapshot of UI changes, if any.
  • Changes to the API follow Semantic Versioning and are documented in the API Changes document.
  • This PR modifies some build requirements and the readme is updated

Calling Installer.SetupPython from Python.Included makes sure Python is
installed and also adds the install location to the PATH env variable.
The location is added to the PATH even if it was already there, so this
can potentially lead to an env variable overflow with the message
'Environment variable name or value is too long', after which the only
way to get CPython3 back to work would be to restart Dynamo.

The problem is avoided by remembering if Python was setup using a local
field. This should reduce the number of calls to a maximum of 2, which
is not the best (1 would be) but is far from resulting in an overflow.
@mjkkirschner
Copy link
Member

@mmisol is it worth adding a test for this functionality to preserve this behavior in the future or you are satisfied with the comment?

@mmisol
Copy link
Collaborator Author

mmisol commented Oct 28, 2020

Reproducing this with a unit test would be easy too, you would only need to execute code with CPython3 in a loop until you run into the overflow. I thought about it and went with the comment, since it seemed cleaner than that test. Let me know what you think.

@mmisol
Copy link
Collaborator Author

mmisol commented Oct 29, 2020

Strange. The build is this https://master-5.jenkins.autodesk.com/job/Dynamo/job/DynamoSelfServe/job/pullRequestValidation/1689/ and it passed but somehow it got disconnected from the PR. Merging.

@mmisol mmisol merged commit 4c6d232 into DynamoDS:master Oct 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants