aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/python/pythonutils.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Python: use DataFromProcess to fetch python version outputDavid Schulz7 hours1-39/+8
| | | | | | | and remove duplicated calls and caches Change-Id: I39f73354035f2ad427e7f2360ccba7143aeb2b84 Reviewed-by: hjk <hjk@qt.io>
* Python: Remove unused createVenv()hjk2025-11-051-20/+0
| | | | | | | Flagged by Axivion. Change-Id: I23a69cd805371b76cfb584e37e2b4feb256cd505 Reviewed-by: David Schulz <david.schulz@qt.io>
* Add pyproject.toml support for Python projectsJaime Resano2025-03-111-2/+3
| | | | | | | | | | | This patch adds support for the standard Python project configuration file: pyproject.toml. It is intended to replace *.pyproject files. Task-number: QTCREATORBUG-22492 Task-number: PYSIDE-2714 Change-Id: I783ee7b49be23c61b0a501ef9bbd722cc652ad14 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Jaime Resano <Jaime.RESANO-AISA@qt.io>
* ProjectExplorer: Add and make use of forwarding accessors in ProjectChristian Kandeler2025-01-201-6/+4
| | | | | | | | | Most accesses to activeTarget() are for getting to the active kit or build/deploy/run configuration. Simplify client code by adding convenience functions for that. No functional changes intended. Change-Id: Ide266712d19f960e4512672eb3bd00fc4d21b47b Reviewed-by: hjk <hjk@qt.io>
* Utils: Rename FilePath::toString() into toUrlishString()hjk2025-01-101-1/+1
| | | | | | | | | | | | | | | | toString() is almost always the wrong conversion, but unfortunately too easy to find and often even working at least for local setup. This here raises the bar as the non-availability of the "obvious" toString() hopefully helps people to think about the semantics of the needed conversion and choose the right toXXX() function. The chosen new name is intentional ugly to reduce the likelihood that this (still almost always wrong) function is used out of convenience. Change-Id: I57f1618dd95ef2629d7d978688d130275e096c0f Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Python: optimize the pip and venv checksDavid Schulz2025-01-071-16/+23
| | | | | | | | | Those checks can take an considerable amount of time. So instead of running them the first time we want to check this info run them in the background as soon as we have loaded the python settings. Change-Id: I287acd2a5fd7b053873257238f7dfbaa9cf00170 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Change the mime database to Apache TikaEike Ziller2024-09-201-1/+1
| | | | | | | | | | | | | | | | qtbase/2d2975bd9fb32bb6dc50c7f513cbe00337fc16b0 Change the mimetype database embedded into QtCore Like before, this is a copy from Qt, because we do not want to depend on Qt versions for this and also always use the embedded database and never system ones on Linux, so we get something deterministic. Add some MIME types that are missing in the Tika database to corresponding plugins. Fixes: QTCREATORBUG-31272 Change-Id: I5c1ff5d7c5f22bb1276570195b0719beb5268925 Reviewed-by: David Schulz <david.schulz@qt.io>
* CommandLine: Reuse new c'torJarek Kobus2024-05-221-4/+2
| | | | | | Change-Id: Id154881b4f5d8c488e5c1f5e0f843d36bf838759 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
* Python: offer to install pyside also in qml filesDavid Schulz2024-04-221-2/+2
| | | | | | | | | | This shwos the same editor toolbar as in the python editor that offers to install pyside, if the qml file can be associated to a python project and the configured python for that project does not contain a valid pyside. Change-Id: Id05a2621aec9d78c4a22e61830813cd261eda4fc Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Merge remote-tracking branch 'origin/13.0'Eike Ziller2024-03-141-11/+0
|\ | | | | | | | | | | | | | | | | Conflicts: src/plugins/cmakeprojectmanager/cmaketool.cpp src/plugins/python/pythonutils.cpp src/plugins/qtsupport/baseqtversion.cpp Change-Id: Ia3e35c763ff9475d17ad922718b54152209893b8
| * Utils: Remove PresistentStoreCacheMarcus Tillmanns2024-03-121-11/+0
| | | | | | | | | | | | | | | | | | It turns out caching the information is unreliable due to a variety of reasons. We remove the cache for now as its less dangerous than trying to fix each use case. Change-Id: I8238166486a2fb29c101f700af1c8d7e4ad7a172 Reviewed-by: hjk <hjk@qt.io>
* | Utils: Fix build with MSVC with C++20Eike Ziller2024-02-281-1/+1
|/ | | | | | | | | | | | | | | | | Rename process.h back to qtcprocess.h MSVC's "threads" standard header includes <process.h>, and that ends up including our process.h from Utils. There already was a hacky workaround in place for a similar issue with MINGW, but that doesn't work with MSVC because that doesn't have Simply use a name that doesn't conflict. Change-Id: I1159cd2096b4f2dbc4a1728d0131dd6edd30ebd3 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: hjk <hjk@qt.io>
* Use more std::chrono and std::chrono_literals namespacesJarek Kobus2024-01-231-1/+2
| | | | | Change-Id: Ib8c83988d7afe35d81b87ff8c5c87eef2082f12d Reviewed-by: hjk <hjk@qt.io>
* Process: Get rid of setTimeoutS()Jarek Kobus2024-01-221-2/+1
| | | | | | | | Add an extra arg to runBlocking() function instead. Use std::chrono::seconds for timeout. Change-Id: I7c3c21e8f26a2ccbed157d15083d6ef0b4cd2f7e Reviewed-by: Orgad Shaneh <orgads@gmail.com>
* PythonUtils: Remove code repetitionJarek Kobus2024-01-221-28/+17
| | | | | | | | | Introduce isUsableHelper() and use it from venvIsUsable() and pipIsUsable(). Change-Id: I29c869f544e28d0962bc0e357399db66f48ba3d1 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
* Python: fix venv checkDavid Schulz2024-01-171-1/+1
| | | | | | | | | FilePath::contains only checks whether the passed string is inside the path, and not whether the path contains a folder or file with the passed string. Change-Id: I20a1a9a52a9f9a436433848ac2eccd38666274d7 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Python: optimize venv and pip checksDavid Schulz2024-01-161-14/+47
| | | | | | | | | | | | | | Checking for the venv and pip module can take some time. Since this is done now whenever the kits are validated this has performance implications for multiple actions. For example showing the target selector wizard page or opening/switching sessions. Use a cache to reduce the number of python processes started to check the existence of the modules, and if the module can be found store that info in a persistent store to avoid checking it again after a restart. Change-Id: Ib899da0e6b2da28fbee2b5baff7f923e4595260a Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Python: Avoid polluting global or virtual environments with pylspDavid Schulz2023-12-131-0/+26
| | | | | | | | | | Install the language server into the Qt Creator resource directory instead. Reuse the server for all interpreters with the same version. This also reduces the amount of editor toolbars asking the user to install a language server for a specific interpreter. Change-Id: I48ef4ad30fe0097ee8d2b855b0f278e98be5ce57 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Python: show warnings if pip or venv is missingDavid Schulz2023-12-111-0/+16
| | | | | | Change-Id: Ib38c1eb3b0f31d6988d3a5f084ac6eda08ec0619 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Python: use kits page in python wizardsDavid Schulz2023-11-281-8/+14
| | | | | Change-Id: I1f7aaf145443481546abb868c8c167186600b848 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Python: Use FilePath::searchInPath instead of Environment::findInPathhjk2023-05-241-4/+5
| | | | | | | That's the last remaining users. Change-Id: I14ce380b9c96b2197e478600a46ca725ed1acfbf Reviewed-by: David Schulz <david.schulz@qt.io>
* Utils: Add TerminalMode::DetachedMarcus Tillmanns2023-05-041-16/+16
| | | | | Change-Id: Ic36845d3469719e17f24602ce80f3e6cfc984fbf Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Utils: Rename qtcprocess.{cpp,h} -> process.{cpp,h}Jarek Kobus2023-05-041-1/+1
| | | | | | | | Follows QtcProcess -> Process rename. Change-Id: I97235a9a40cb7fd52944515b7ab878d96528f919 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Utils: Rename QtcProcess -> ProcessJarek Kobus2023-05-041-5/+5
| | | | | | | | Task-number: QTCREATORBUG-29102 Change-Id: Ibc264f9db6a32206e4097766ee3f7d0b35225a5c Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: hjk <hjk@qt.io>
* Python: add create venv actionDavid Schulz2023-03-211-0/+21
| | | | | | | | | The action can be triggered from the interpreter chooser of the editor toolbar. Change-Id: Ie23b68a3790525ea02883ef359b357a0d317b2f5 Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
* ProjectExplorer: Move some not-fully-session related bitshjk2023-03-011-5/+5
| | | | | | | | | | | | | | | ... out of SessionManager. The idea is to later move SessionManager into the Core plugin, which both is sensible conceptually and also prerequisite to merge the Bookmark plugin into TextEditor plugin. Currently, only the interface is split, as the load/save implemetations are non-mechanical to disentangle. Change-Id: I31631db3094ea192825a2ccaa6add6188662940b Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
* Python: add interpreter selector to editor toolbarDavid Schulz2023-01-201-0/+15
| | | | | | Fixes: PYSIDE-2154 Change-Id: If5e90f5bf2923b61af37ebbfcd35c512b3b07db4 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Remove GPL-3.0+ from license identifiersKai Köhne2023-01-061-1/+1
| | | | | | | | | | | | | | | Since we also license under GPL-3.0 WITH Qt-GPL-exception-1.0, this applies only to a hypothetical newer version of GPL, that doesn't exist yet. If such a version emerges, we can still decide to relicense... While at it, replace (deprecated) GPL-3.0 with more explicit GPL-3.0-only Change was done by running find . -type f -exec perl -pi -e "s/LicenseRef-Qt-Commercial OR GPL-3.0\+ OR GPL-3.0 WITH Qt-GPL-exception-1.0/LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0/g" {} \; Change-Id: I5097e6ce8d10233993ee30d7e25120e2659eb10b Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Python: Replace one use of QDirCurrentPath()hjk2022-11-211-1/+1
| | | | | Change-Id: I88a04930b8c62a68ee1adb73e1cdd3c433eea4e3 Reviewed-by: David Schulz <david.schulz@qt.io>
* Use SPDX license identifiersLucie Gérard2022-08-261-24/+2
| | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Task-number: QTBUG-67283 Change-Id: I708fd1f9f2b73d60f57cc3568646929117825813 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Python: Convert to Tr::trhjk2022-07-211-6/+4
| | | | | | Change-Id: I0241053b0d51dbb1a60c43351cbff543fd52573d Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
* Python: ignore windows store redirectorsDavid Schulz2022-06-201-6/+15
| | | | | Change-Id: Ife5c13549d73156550a7ce4b5436f1e5a19503fa Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Python: prefer python from path when detecting python for documentDavid Schulz2022-06-151-5/+15
| | | | | Change-Id: I794a741fa7257833f0b4efbc25dfae43b8748427 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Python: simplify detect python for document pathDavid Schulz2022-06-151-12/+8
| | | | | Change-Id: I49b943e8b89db32c11b12ee66c0ad3add9a695af Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Python: Fix python detection for non project filesDavid Schulz2022-06-101-2/+2
| | | | | | | | Do not return an empty file path if we cannot find a python venv for a file path, but also consider the configured interpreters. Change-Id: I5a7f06e394fb925f9a00143fc5f0797e8754534b Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Promote previously python-specific InterpreterAspecthjk2022-04-271-7/+8
| | | | | | | | ... and drop PythonRunConfiguration, which is a plain RunConfiguration now. Change-Id: I540cb738180fc1424f730d6d1998886915ce527b Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
* PythonUtils: Connect to QtcProcess::done() signalJarek Kobus2022-04-271-11/+10
| | | | | | | | Instead of connecting to errorOccurred() and finished() signals. Change-Id: I02fefe01cfc4be6ef996c7c8b98b36137217504e Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
* Python: work with Interpreter in PythonRunConfigurationDavid Schulz2022-03-281-1/+1
| | | | | | | | This saves some unneeded file path conversion and lookups in the python settings. Change-Id: I8647858320183dc1da027363b4ab265f6c75e1ae Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Python: extract pythonProjectForFile function to utilsDavid Schulz2022-03-281-0/+11
| | | | | Change-Id: I4055527302cab09f55cd4b06bfd3896accb4832a Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Python: move python name cache to utilsDavid Schulz2022-03-281-0/+19
| | | | | Change-Id: I7f6d13a465be6de90aea64e7f19c92bca3ee6c19 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Mimetypes: Make implementation switchable between new and oldEike Ziller2022-02-251-1/+1
| | | | | | | | | | | | | | | | | | - configure with QTC_USE_NEW_MIMEDATABASE to switch to the new one in utils/mimetypes2/ - added utils/mimeutils.h header for the Qt Creator specific static wrappers, that also includes the "public" headers for MimeType et al from the new or old implementation, depending on configuration - change all utils/mimetypes/ includes to utils/mimeutils.h - move the implementation for the wrappers to utils/mimetypes(2)/mimeutils.cpp - also move the MimeDatabase declaration in the "old" implementation back to utils/mimetypes/mimedatabase.h Change-Id: Ie8de229c035d6cd9a5e4739dc0fa78d9c17228e3 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
* QtcProcess: Extract QtcProcess specific enums into separate headerJarek Kobus2022-02-181-1/+1
| | | | | | Change-Id: Ib3498f189000fd8f5501130c0d280b0f5ae83849 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: hjk <hjk@qt.io>
* Utils: Move QtcProcess constructor setup data to shared setup datahjk2022-02-111-1/+2
| | | | | | | | This includes replacing DeviceProcess terminal handling with base member. Change-Id: Id1541bfce33c71dddc71b4816ad0b174dce3879c Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
* PythonUtils: Use QtcProcess in terminal mode instead of ConsoleProcessJarek Kobus2022-01-251-4/+4
| | | | | | Change-Id: Icd8a481a03a2a13f5556327ce5caf661a5d19321 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* ConsoleProcess: Uniform the common interface of QtcProcessJarek Kobus2022-01-201-1/+1
| | | | | | | | | | | This is a preliminary step before merging ConsoleProcess into QtcProcess. Rename command() to commandLine(). Return const references from commandLine() and from environment(). Change-Id: Iacbf48030d00f8dbba053ece70bd460924f96041 Reviewed-by: hjk <hjk@qt.io>
* PythonEditor: Fix a leak of console process on shutdownJarek Kobus2022-01-201-3/+3
| | | | | | | | | | | | | | | Give a parent for console process in order to delete it on shutdown. In case the console process was started and the user closed the Creator we were leaking console process instance together with its process. Connect to ConsoleProcess::finished() instead of stubStopped(). There is no point to keep the console open when the process finished (it forces the user to manually close the stub window by pressing enter). Change-Id: I3f14e940f39b32e11bde276e80f3cb630b13d8f7 Reviewed-by: hjk <hjk@qt.io>
* ConsoleProcess: Uniform the common interface of QtcProcessJarek Kobus2022-01-201-3/+3
| | | | | | | | | | | This is a preliminary step before merging ConsoleProcess into QtcProcess. Remove processError() signal, use errorOccurred() instead. Change-Id: If11064944228c82a9099fffdba942c4276690085 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Python: move language client functionality out of utilsDavid Schulz2022-01-181-421/+4
| | | | | | | | There will be more lsp specific functionality so moving it into its own space is reasonable. Change-Id: Ic87d437182d68673b53f662c804707138fef5b6c Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Python: fix repl workdirDavid Schulz2022-01-051-1/+1
| | | | | | | | | | Use the directory that contains the file not the file itself as the working directory for REPL. amends 4a42bcd4e8d2c73be426775597e8a58f5df6a3a8 Change-Id: Ia81efc3ef51a96a79918d358cd446de9f1ea082d Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Python: prefer python-lsp-serverDavid Schulz2021-12-101-5/+5
| | | | | | | | python-language-server is dead... long live python-lsp-server. Task-number: QTCREATORBUG-26230 Change-Id: I9343f231c732b135bc4f8a704a29541c48cc36ba Reviewed-by: Eike Ziller <eike.ziller@qt.io>