-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
PR: Add option to prepend or append Pythonpath Manager paths to sys.path #21769
base: master
Are you sure you want to change the base?
Conversation
Hello @mrclary! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2024-06-19 16:20:06 UTC |
3999697
to
3c2c64d
Compare
b11ccad
to
a433e97
Compare
5f68078
to
ffd9395
Compare
0a04027
to
73e407e
Compare
…_paths, system_paths) and dictionary type
…pdate_paths method and call setup in update-paths method. This will allow the container to instantiate the PathManager widget before providing paths. Paths will not be retrieved or determined within the widget, only passed to it by the container.
These will be dictionaries and the container will handle updating the pythonpath_manager configuration and assembling the final spyder_pythonpath. There is no need for _update_system_path method because the container will handle updates to the underlying system path. Again, the widget will only handle user-interactive changes.
This will be done in the container instead.
…oritize) -> (_user_paths, _system_paths, _project_paths, _prioritize, _spyder_pythonpath). Path lists are now OrderedDict * Simplifies _load_pythonpath -> _load_paths * Move migration method from setup to _load_paths
* Promptly exits if remnants of old configuration are not present * Removes remnants of old configuration if present * Constructs user paths from old configuration remnants
* Configuration keys and private attributes for user paths, system paths, prioritize, and spyder_pythonpath are set conditionally in this method and nowhere else. * sig_pythonpath_changed is conditionally emitted from this method and nowhere else. This signal now sends only the spyder_pythonpath and prioritize, not the old spyder_pythonpath. Subscribers should update accordingly.
…ardly constructed from project, user, and system paths attributes.
…d in _save_paths if spyder_pythonpath is changed.
…d in PathManager.updat_paths
… Note that spyder-kernels must be updated to accommodate.
Icon and tooltip are changed to reflect current state.
Co-authored-by: Jitse Niesen <jitseniesen@yahoo.com> Typographical errors. Improved docstring clarity
The desired affect is project paths | user paths | system paths, where the paths are in that order and are overwritten in that order. System paths cannot overwrite user paths, which cannot overwrite project paths, i.e we cannot just do project_paths.update(user_paths) etc.
…lary/spyder-kernels.git --update --force external-deps/spyder-kernels subrepo: subdir: "external-deps/spyder-kernels" merged: "1285e11fd" upstream: origin: "https://github.com/mrclary/spyder-kernels.git" branch: "ppm-syspath" commit: "1285e11fd" git-subrepo: version: "0.4.6" origin: "???" commit: "???"
…lary/python-lsp-server.git --update --force external-deps/python-lsp-server subrepo: subdir: "external-deps/python-lsp-server" merged: "8c8807af5" upstream: origin: "https://github.com/mrclary/python-lsp-server.git" branch: "ppm-syspath" commit: "8c8807af5" git-subrepo: version: "0.4.6" origin: "???" commit: "???"
Gave this a quick manual check and I see that there is now an option to change where to put the paths and seems like is working as expected 👍 As a behavior preview: However, seems like there could be an issue with saving the paths after Spyder closes. So, while I was testing this each time I close and launch Spyder again, the manager dialog always shows that I don't have any paths added: Or maybe this behavior is some how expected? 🤔 |
@dalthviz, thanks for checking this. That is not expected behavior. User paths should be stored in Spyder's config file and persist to new instances. Just to be sure, can you start Spyder in |
I did not check with Traceback (most recent call last):
File "E:\Acer\Documentos\Spyder\Spyder otros\rear1019\spyder\bootstrap.py", line 211, in <module>
start.main()
File "e:\acer\documentos\spyder\spyder otros\rear1019\spyder\spyder\app\start.py", line 261, in main
mainwindow.main(options, args)
File "e:\acer\documentos\spyder\spyder otros\rear1019\spyder\spyder\app\mainwindow.py", line 1451, in main
mainwindow = create_window(MainWindow, app, splash, options, args)
File "e:\acer\documentos\spyder\spyder otros\rear1019\spyder\spyder\app\utils.py", line 356, in create_window
main.setup()
File "e:\acer\documentos\spyder\spyder otros\rear1019\spyder\spyder\app\mainwindow.py", line 778, in setup
PLUGIN_REGISTRY.register_plugin(self, PluginClass,
File "e:\acer\documentos\spyder\spyder otros\rear1019\spyder\spyder\api\plugin_registration\registry.py", line 345, in register_plugin
instance = self._instantiate_spyder5_plugin(
File "e:\acer\documentos\spyder\spyder otros\rear1019\spyder\spyder\api\plugin_registration\registry.py", line 187, in _instantiate_spyder5_plugin
plugin_instance = PluginClass(main_window, configuration=CONF)
File "e:\acer\documentos\spyder\spyder otros\rear1019\spyder\spyder\api\plugins\new_api.py", line 330, in __init__
container.setup()
File "e:\acer\documentos\spyder\spyder otros\rear1019\spyder\spyder\plugins\pythonpath\container.py", line 54, in setup
self._load_pythonpath()
File "e:\acer\documentos\spyder\spyder otros\rear1019\spyder\spyder\plugins\pythonpath\container.py", line 146, in _load_pythonpath
for path in previous_paths:
TypeError: 'NoneType' object is not iterable Then I did a |
Description of Changes
Primary Changes
Added toggle button to Pythonpath Manager dialog that determines whether active paths should be prepended to or appended to
![Screenshot 2024-03-04 at 11 11 45 AM](https://private-user-images.githubusercontent.com/9618975/309887191-7d67c94f-47b3-439d-a5bf-838852f9372e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjAxOTE1OTQsIm5iZiI6MTcyMDE5MTI5NCwicGF0aCI6Ii85NjE4OTc1LzMwOTg4NzE5MS03ZDY3Yzk0Zi00N2IzLTQzOWQtYTViZi04Mzg4NTJmOTM3MmUucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDcwNSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA3MDVUMTQ1NDU0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9M2QxMzIyNGQ3MmRhYmQwNzQ2MTkzYWJmMzY2MzQ0ZDFjMzcyOTQyNTJhZDFjMGEzNmU5NzdmYjFhYjJiNzAwNSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.uJcS1DHn_M57tVOHHQJfUqWOSRONmTmBWq8ETI5pojY)
sys.path
in IPython console and Jedi completion environments.user_paths
,system_paths
, andprioritize
.user_paths
andsystem_paths
are dictionaries with path as key and enabled state as value.prioritize
is a boolean. The unofficial configuration keyspath
,user_path
, andsystem_path
are no longer used. Thespyder_pythonpath
configuration key remains unchanged.SPY_PYTHONPATH
environment variable is eliminated in favor of directly accessing thespyder_pythonpath
configuration key in thepythonpath_manager
configuration section on startup of IPython console kernels.sig_pythonpath_changed
now sends the newspyder_pythonpath
value (list of strings) andprioritize
(boolean). This signal no longer sends the "old" paths. The old paths were only required byspyder-kernels
in order to remove those paths fromsys.path
before adding the new paths tosys.path
. The update tospyder-kernels
in the companion PR eliminates the need for sending the "old" paths.Secondary Changes
In order to simplify the handling of PYTHONPATH, the following changes were made to the Pythonpath Manager plugin. These do not directly affect the UI, UX, or plugin API, but streamline and clarify the actions performed within the plugin.
PythonpathContainer
container object and thePathManager
widget object were changed frompath
,not_active_path
,user_path
,system_path
, andoriginal_path_dict
, to the less ambiguoususer_paths
andsystem_paths
. The latter are maintained asOrderedDict
objects throughout.pythonpath_manager
configurations are now only set inPythonpathContainer._save_paths
, and only on condition of change, rather than in multiple locations throughout the container andPathManager
widget.sig_pythonpath_changed
signal is emitted only inPythonpathContainer._save_paths
, and only on condition thatspyder_pythonpath
orprioritize
has changed.Companion PRs
Outstanding questions
python-lsp-server.pylsp.Document.sys_path
be removed (API break)?new_dlg.kfp.text() == pytest.kfp
andnew_dlg.pw.text() == pytest.pw
fail on latest master? Why are they skipped for CI?Issue(s) Resolved
Fixes #17066
Affirmation
By submitting this Pull Request or typing my (user)name below,
I affirm the Developer Certificate of Origin
with respect to all commits and content included in this PR,
and understand I am releasing the same under Spyder's MIT (Expat) license.
I certify the above statement is true and correct:
@mrclary