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

Refactor to use the windows installer when creating a base environment #145

Merged

Conversation

Tom-Kingstone
Copy link
Contributor

@Tom-Kingstone Tom-Kingstone commented Oct 1, 2024

NOTE: Depends on

Issues addressed by this PR

Closes #142

The changes in this PR necessitate changes to the following downstream repositories:

Refactor of very core methods, so this PR requires extensive testing, with any python based unit tests and the beta testing procedures.

Updated the base python environment logic to use the windows installer instead of embedded packages (which allows tkinter and other similar libraries to be included), and updated the Remove methods respectively to use the installer to remove the environment (as the windows installer modifies the registry to keep track of the version).

Updated relevant enums and dictionaries to only allow the most recent specific version of each minor python version, as the windows installer does not support having more than one specific version downloaded at the same time.

Move the bhom analytics logger from LadybugTools_Toolkit to Python_Toolkit (as this is where it should be to be accessible to all python based toolkits)

Test files

Use the beta test procedure and any supporting unit tests for this repo and any downstream repositories

Changelog

  • Updated base environment install method to use the windows installer rather than the embeddable package

Additional comments

When testing, make sure that if you wish to remove an environment, use the methods that remove the environments rather than manually deleting the folder, as removing the folder will not update any registry keys and therefore make it impossible to install that version of python again (this is a limitation of the windows installer). If you accidentally do this, contact me for help to resolve the issue.

@Tom-Kingstone
Copy link
Contributor Author

@BHoMBot check versioning

Copy link

bhombot-ci bot commented Oct 1, 2024

@Tom-Kingstone to confirm, the following actions are now queued:

  • check versioning

@Tom-Kingstone
Copy link
Contributor Author

@BHoMBot check versioning

Copy link

bhombot-ci bot commented Oct 1, 2024

@Tom-Kingstone to confirm, the following actions are now queued:

  • check versioning

@Tom-Kingstone
Copy link
Contributor Author

@BHoMBot check versioning

Copy link

bhombot-ci bot commented Oct 1, 2024

@Tom-Kingstone to confirm, the following actions are now queued:

  • check versioning

There are 1 requests in the queue ahead of you.

@Tom-Kingstone
Copy link
Contributor Author

@BHoMBot check versioning

Copy link

bhombot-ci bot commented Oct 1, 2024

@Tom-Kingstone to confirm, the following actions are now queued:

  • check versioning

@Tom-Kingstone
Copy link
Contributor Author

@BHoMBot check versioning

@Tom-Kingstone
Copy link
Contributor Author

@BHoMBot check null-handling
@BHoMBot check serialisation

Copy link

bhombot-ci bot commented Oct 22, 2024

@Tom-Kingstone to confirm, the following actions are now queued:

  • check null-handling
  • check serialisation

There are 11 requests in the queue ahead of you.

@Tom-Kingstone
Copy link
Contributor Author

@jamesramsden-bh suggested that the error should also display which base environments are currently installed (if any) as well as clearly stating that the one requested isn't installed.

…uired base version if it doesn't exist and leaves a note to say this.
@Tom-Kingstone
Copy link
Contributor Author

@BHoMBot check installer

Copy link

bhombot-ci bot commented Oct 29, 2024

@Tom-Kingstone to confirm, the following actions are now queued:

  • check installer

@Tom-Kingstone
Copy link
Contributor Author

@BHoMBot check installer -force

Copy link

bhombot-ci bot commented Oct 29, 2024

@Tom-Kingstone to confirm, the following actions are now queued:

  • check installer

Copy link

bhombot-ci bot commented Oct 29, 2024

The check installer has already been run previously and recorded as a successful check. This check has not been run again at this time.

@Tom-Kingstone
Copy link
Contributor Author

@BHoMBot check installer

Copy link

bhombot-ci bot commented Oct 29, 2024

@Tom-Kingstone to confirm, the following actions are now queued:

  • check installer

@Tom-Kingstone
Copy link
Contributor Author

@BHoMBot check required

Copy link

bhombot-ci bot commented Oct 29, 2024

@Tom-Kingstone to confirm, the following actions are now queued:

  • check code-compliance
  • check documentation-compliance
  • check project-compliance
  • check core
  • check null-handling
  • check serialisation
  • check versioning
  • check installer

@Tom-Kingstone
Copy link
Contributor Author

@BHoMBot check required

Copy link

bhombot-ci bot commented Oct 29, 2024

@Tom-Kingstone to confirm, the following actions are now queued:

  • check code-compliance
  • check documentation-compliance
  • check project-compliance
  • check core
  • check null-handling
  • check serialisation
  • check versioning
  • check installer

There are 22 requests in the queue ahead of you.

Copy link

bhombot-ci bot commented Oct 29, 2024

The check installer has already been run previously and recorded as a successful check. This check has not been run again at this time.

@Tom-Kingstone
Copy link
Contributor Author

@BHoMBot check installer

Copy link

bhombot-ci bot commented Oct 30, 2024

@Tom-Kingstone to confirm, the following actions are now queued:

  • check installer

@Tom-Kingstone
Copy link
Contributor Author

@BHoMBot check required
@BHoMBot check copyright-compliance

Copy link

bhombot-ci bot commented Oct 30, 2024

@Tom-Kingstone to confirm, the following actions are now queued:

  • check code-compliance
  • check documentation-compliance
  • check project-compliance
  • check core
  • check null-handling
  • check serialisation
  • check versioning
  • check installer
  • check copyright-compliance

There are 13 requests in the queue ahead of you.

Copy link

bhombot-ci bot commented Oct 30, 2024

The check installer has already been run previously and recorded as a successful check. This check has not been run again at this time.

Copy link
Contributor

@tg359 tg359 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All functionality works as expected. Jupyter still works and registers venvs correctly too 😄

I have one bit of a feedback though. I understand why we might want to expose different versions to the virtual environments, but for the root environment I think we should hide that option. I tried installing another "BasePythonEnvironment" using a different version and got an error at the very end (trace at the bottom of this message). I think it would be safer to just set the version of the BaseEnvironment behind the scenes and force users to use a specific version to save there being multiple "bases" and some confusion about why this error is happening. This is not a typical install location, nor typical behaviour of a user, so I approve this PR as nothing bad actually happens if you actually install two "Base" environments.

Obtaining file:///C:/ProgramData/BHoM/Extensions/PythonCode/Python_Toolkit
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... error

[process exited with code 1 (0x00000001)]
You can now close this terminal with Ctrl+D, or press Enter to restart.
Obtaining file:///C:/ProgramData/BHoM/Extensions/PythonCode/Python_Toolkit
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... error
  error: subprocess-exited-with-error

  × Getting requirements to build editable did not run successfully.
  │ exit code: 1
  ╰─> [23 lines of output]
      Traceback (most recent call last):
        File "C:\ProgramData\BHoM\Extensions\PythonEnvironments\Python_Toolkit\v3_11\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
          main()
        File "C:\ProgramData\BHoM\Extensions\PythonEnvironments\Python_Toolkit\v3_11\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\ProgramData\BHoM\Extensions\PythonEnvironments\Python_Toolkit\v3_11\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 132, in get_requires_for_build_editable
          return hook(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\tgerrish\AppData\Local\Temp\pip-build-env-91r7q8ug\overlay\Lib\site-packages\setuptools\build_meta.py", line 482, in get_requires_for_build_editable
          return self.get_requires_for_build_wheel(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\tgerrish\AppData\Local\Temp\pip-build-env-91r7q8ug\overlay\Lib\site-packages\setuptools\build_meta.py", line 333, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=[])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\tgerrish\AppData\Local\Temp\pip-build-env-91r7q8ug\overlay\Lib\site-packages\setuptools\build_meta.py", line 303, in _get_build_requires
          self.run_setup()
        File "C:\Users\tgerrish\AppData\Local\Temp\pip-build-env-91r7q8ug\overlay\Lib\site-packages\setuptools\build_meta.py", line 521, in run_setup
          super().run_setup(setup_script=setup_script)
        File "C:\Users\tgerrish\AppData\Local\Temp\pip-build-env-91r7q8ug\overlay\Lib\site-packages\setuptools\build_meta.py", line 319, in run_setup
          exec(code, locals())
        File "<string>", line 4, in <module>
      ModuleNotFoundError: No module named 'win32api'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build editable did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

[notice] A new release of pip is available: 23.1.2 -> 24.3.1
[notice] To update, run: C:\ProgramData\BHoM\Extensions\PythonEnvironments\Python_Toolkit\v3_11\python.exe -m pip install --upgrade pip

[process exited with code 1 (0x00000001)]
You can now close this terminal with Ctrl+D, or press Enter to restart.

@Tom-Kingstone
Copy link
Contributor Author

@BHoMBot check ready-to-merge

Copy link

bhombot-ci bot commented Nov 6, 2024

@Tom-Kingstone to confirm, the following actions are now queued:

  • check ready-to-merge

@jamesramsden-bh jamesramsden-bh merged commit 618dfb0 into develop Nov 6, 2024
10 checks passed
@jamesramsden-bh jamesramsden-bh deleted the Python_Toolkit-#142-PythonEnvironmentRefactor branch November 6, 2024 15:23
@BHoMBot BHoMBot mentioned this pull request Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:XL Measured in weeks type:feature New capability or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use the windows installer for installing base python environments
4 participants