PR: Add option to prepend or append Pythonpath Manager paths to sys.path#21769
Merged
ccordoba12 merged 45 commits intospyder-ide:masterfrom Feb 24, 2025
Merged
PR: Add option to prepend or append Pythonpath Manager paths to sys.path#21769ccordoba12 merged 45 commits intospyder-ide:masterfrom
sys.path#21769ccordoba12 merged 45 commits intospyder-ide:masterfrom
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 2025-01-24 02:08:36 UTC |
3999697 to
3c2c64d
Compare
b11ccad to
a433e97
Compare
5f68078 to
ffd9395
Compare
0a04027 to
73e407e
Compare
…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.
…path manager widget is invoked. If the system paths have changed since last widget invocation, then the user may not be aware and there is no indication in the widget that there has been a change. Furthermore, canceling the widget may still result in a change to the pythonpath, which would be inconsistent with the cancel action.
Rather than automatically updating the system paths, provide mechanism for user to do so.
* Test system PYTHONPATH import in test_pathmanager instead of test_mainwindow * Move restore_user_env fixture from app/tests/conftest.py to utils/tests/conftest.py * Ensure that the user environment script runs on posix while testing
Co-authored-by: Carlos Cordoba <ccordoba12@gmail.com>
…igrated. _migrate_to_config_options only converts from old path configuration files to the new configuration system. Load paths from configuration (after possibly migrating the configuration) in setup; no need for _load_paths. Only get up-to-date system paths upon request from user in the pythonpath manager widget.
… widget rather than container (just a further check).
Co-authored-by: Carlos Cordoba <ccordoba12@gmail.com>
…spyder-ide/spyder-kernels.git external-deps/spyder-kernels subrepo: subdir: "external-deps/spyder-kernels" merged: "633c29712" upstream: origin: "https://github.com/spyder-ide/spyder-kernels.git" branch: "master" commit: "633c29712" git-subrepo: version: "0.4.9" origin: "???" commit: "???"
…to the top of the user list actually placed it in the project path section. Fix issue where adding duplicate path that is also the same as project path and selecting "yes" to move it to the top of the user list actually moved the project path item to the user list section. Ensure that user path item is selectable even if same as project path item.
Contributor
Author
|
@dalthviz, all the issues that you found should now be fixed. |
Member
|
Gave another check to the latest changes and seems like indeed things are working as expected now 👍 |
ccordoba12
approved these changes
Feb 24, 2025
Member
ccordoba12
left a comment
There was a problem hiding this comment.
Thanks @mrclary for this really powerful improvement!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Changes
UI/UX Changes
sys.pathin IPython console and Jedi completion environments.Primary Changes
These changes directly affect the plugin API.
user_paths,system_paths, andprioritize.user_pathsandsystem_pathsare dictionaries with path as key and enabled state as value.prioritizeis a boolean. The unofficial configuration keyspath,user_path, andsystem_pathare no longer used. Thespyder_pythonpathconfiguration key remains unchanged.SPY_PYTHONPATHenvironment variable is eliminated in favor of directly accessing thespyder_pythonpathconfiguration key in thepythonpath_managerconfiguration section on startup of IPython console kernels.sig_pythonpath_changednow sends the newspyder_pythonpathvalue (list of strings) andprioritize(boolean). This signal no longer sends the "old" paths. The old paths were only required byspyder-kernelsin order to remove those paths fromsys.pathbefore adding the new paths tosys.path. The update tospyder-kernelsin the companion PR eliminates the need for sending the "old" paths.UnboundLocalError.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.
PythonpathContainercontainer object and thePathManagerwidget object were changed frompath,not_active_path,user_path,system_path, andoriginal_path_dict, to the less ambiguoususer_pathsandsystem_paths. The latter are maintained asOrderedDictobjects throughout.pythonpath_managerconfigurations are now only set inPythonpathContainer._save_paths, and only on condition of change, rather than in multiple locations throughout the container andPathManagerwidget.sig_pythonpath_changedsignal is emitted only inPythonpathContainer._save_paths, and only on condition thatspyder_pythonpathorprioritizehas changed.Companion PRs
extra_pathsto be placed in front ofsys.pathpython-lsp/python-lsp-server#527.Outstanding questions
python-lsp-server.pylsp.Document.sys_pathbe removed (API break)?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