-
-
Notifications
You must be signed in to change notification settings - Fork 243
Feature/poetry - uv #372
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
Draft
martin-marty
wants to merge
15
commits into
fabioz:master
Choose a base branch
from
martin-marty:feature/poetry
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Feature/poetry - uv #372
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
4ca3103
Initial commit
martin-marty 6b46803
Add poetry install/add
martin-marty 0af39ea
Adds lock/sync
martin-marty 9069d4f
Fixes for monitor progress
martin-marty fad9699
Moved poetry package
martin-marty 31c9b9a
Removed original plugin
martin-marty 9c5de93
Restored icons
martin-marty 6660f80
Refactored to add PyPoetryAction for project
martin-marty 46c540d
Remove avoid conflict
martin-marty 422f663
Refactored to make use of common commands
martin-marty 1468900
Add UV supoprt
martin-marty 1127038
Revert test file for upstream
martin-marty a190deb
Removed unused attributes
martin-marty 89e5e05
Removed export not required
martin-marty 4301b06
Changed to use `Arrays.asList`
martin-marty File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
28 changes: 19 additions & 9 deletions
28
plugins/org.python.pydev.core/pysrc/tests_python/my_django_proj_17/.pydevproject
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,22 @@ | ||
| <?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
| <?eclipse-pydev version="1.0"?><pydev_project> | ||
| <pydev_variables_property name="org.python.pydev.PROJECT_VARIABLE_SUBSTITUTION"> | ||
| <key>DJANGO_MANAGE_LOCATION</key> | ||
| <value>manage.py</value> | ||
| </pydev_variables_property> | ||
| <pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH"> | ||
| <path>/${PROJECT_DIR_NAME}</path> | ||
| </pydev_pathproperty> | ||
| <pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property> | ||
| <pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property> | ||
|
|
||
| <pydev_variables_property name="org.python.pydev.PROJECT_VARIABLE_SUBSTITUTION"> | ||
|
|
||
| <key>DJANGO_MANAGE_LOCATION</key> | ||
|
|
||
| <value>manage.py</value> | ||
|
|
||
| </pydev_variables_property> | ||
|
|
||
| <pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH"> | ||
|
|
||
| <path>/${PROJECT_DIR_NAME}</path> | ||
|
|
||
| </pydev_pathproperty> | ||
|
|
||
| <pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python interpreter</pydev_property> | ||
|
|
||
| <pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property> | ||
|
|
||
| </pydev_project> |
161 changes: 161 additions & 0 deletions
161
...s/org.python.pydev.core/src/org/python/pydev/core/package_manager/BasePackageManager.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,161 @@ | ||
| /** | ||
| * Base package manager | ||
| * | ||
| * Using either poetry or uv, manage the commands available to apply to a project. | ||
| * | ||
| * @author Martin Whitehouse | ||
| */ | ||
| package org.python.pydev.core.package_manager; | ||
|
|
||
| import java.io.File; | ||
| import java.io.IOException; | ||
| import java.util.ArrayList; | ||
| import java.util.Arrays; | ||
| import java.util.List; | ||
|
|
||
| import org.eclipse.core.runtime.Platform; | ||
| import org.python.pydev.core.log.Log; | ||
|
|
||
| /** | ||
| * Using ProcessBuilder, runs the commands to achieve e.g. `poetry install | ||
| * package_name`. | ||
| */ | ||
| abstract public class BasePackageManager { | ||
| public enum Commands { | ||
| INSTALL("install"), ENV("env"), LOCK("lock"), SYNC("sync"), UPDATE("update"); | ||
|
|
||
| private String command; | ||
|
|
||
| private Commands(String command) { | ||
| this.command = command; | ||
| } | ||
|
|
||
| public String command() { | ||
| return this.command; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Argument to use for changing to the project directory. | ||
| */ | ||
| private String chDirArg; | ||
|
|
||
| /** | ||
| * Name of the task | ||
| */ | ||
| protected String taskName; | ||
|
|
||
| /** | ||
| * Path to the project directory | ||
| */ | ||
| private String projectRoot; | ||
|
|
||
| /** | ||
| * Path to the binary | ||
| */ | ||
| private String binPath; | ||
|
|
||
| /** | ||
| * Title to use when binary can't be found. | ||
| */ | ||
| private String errorTitle; | ||
| /** | ||
| * Message to display. | ||
| */ | ||
| private String errorMsg; | ||
|
|
||
| public BasePackageManager(String projectRoot, String name, String prefsName, String chDirAarg) { | ||
| this.projectRoot = projectRoot; | ||
| this.chDirArg = chDirAarg; | ||
| binPath = Platform.getPreferencesService().getString("org.python.pydev", prefsName, null, null); | ||
| File f = null; | ||
| if (binPath != null) { | ||
| f = new File(binPath); | ||
| } | ||
| if (binPath == null | !(f != null && f.exists() && !f.isDirectory())) { | ||
| errorTitle = name + " not configured"; | ||
| errorMsg = "The path to " + name + "could not be found.\n"; | ||
| errorMsg += "Please configure the path to " + name; | ||
| } | ||
| } | ||
|
|
||
| private Boolean checkError() { | ||
| if (errorMsg != null) { | ||
| Log.log(errorTitle + "\n" + errorMsg); | ||
| return false; | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| protected ArrayList<String> getCommandArgs(String args) { | ||
| return new ArrayList<String>(Arrays.asList(args)); | ||
| } | ||
|
|
||
| protected ArrayList<String> getCommandArgs(String[] args) { | ||
| ArrayList<String> parsedArgs = new ArrayList<String>(); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Arrays.asList?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed to use Arrays.asList |
||
| for (String arg : args) { | ||
| parsedArgs.add(arg); | ||
| } | ||
| return parsedArgs; | ||
| } | ||
|
|
||
| public String add(String appName) { | ||
| List<String> args = getCommandArgs("add"); | ||
| String[] apps = appName.split(" "); | ||
| for (String app : apps) { | ||
| args.add(app); | ||
| } | ||
| return runCommand(args); | ||
| } | ||
|
|
||
| public String lock() { | ||
| return runCommand(getCommandArgs("lock")); | ||
| } | ||
|
|
||
| public String sync() { | ||
| return runCommand(getCommandArgs("sync")); | ||
| } | ||
|
|
||
| public String remove(String appName) { | ||
| List<String> args = getCommandArgs("remove"); | ||
| for (String app : appName.split(" ")) { | ||
| args.add(app); | ||
| } | ||
| return runCommand(args); | ||
| } | ||
|
|
||
| /** | ||
| * Returns the output of running `poetry args...` | ||
| * | ||
| * @param args List of arguments to pass to binPath e.g. "[poetry] env info" | ||
| * @return The command output | ||
| */ | ||
| public String runCommand(List<String> args) { | ||
| String output = null; | ||
| if (!checkError()) { | ||
| return output; | ||
| } | ||
| ArrayList<String> commandArgs = new ArrayList<String>(); | ||
|
|
||
| commandArgs.add(binPath); | ||
| commandArgs.add(chDirArg); | ||
| commandArgs.add(projectRoot); | ||
|
|
||
| for (String arg : args) { | ||
| commandArgs.add(arg); | ||
| } | ||
|
|
||
| ProcessBuilder pb = new ProcessBuilder(commandArgs); | ||
| Process p; | ||
|
|
||
| try { | ||
| p = pb.start(); | ||
| output = new String(p.getInputStream().readAllBytes()).strip(); | ||
| } catch (IOException e) { | ||
| Log.log(e); | ||
| } | ||
|
|
||
| return output; | ||
| } | ||
|
|
||
| } | ||
42 changes: 42 additions & 0 deletions
42
...org.python.pydev.core/src/org/python/pydev/core/package_manager/PoetryPackageManager.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| package org.python.pydev.core.package_manager; | ||
|
|
||
| import java.util.ArrayList; | ||
|
|
||
| public class PoetryPackageManager extends BasePackageManager { | ||
| final public static String PREFS_NAME = "POETRY_BIN"; | ||
| private String pythonPath; | ||
|
|
||
| public PoetryPackageManager(String projectRoot) { | ||
| super(projectRoot, "poetry", PREFS_NAME, "-C"); | ||
| } | ||
|
|
||
| public String install() { | ||
| return runCommand(getCommandArgs("install")); | ||
| } | ||
|
|
||
| @Override | ||
| public String add(String appName) { | ||
| ArrayList<String> args = getCommandArgs("add"); | ||
| String[] apps = appName.split(" "); | ||
| for (String app : apps) { | ||
| args.add(app); | ||
| } | ||
| return runCommand(args); | ||
| } | ||
|
|
||
| public String update() { | ||
| return runCommand(getCommandArgs("update")); | ||
| } | ||
|
|
||
| /** | ||
| * Returns the path to the python executable of a pyproject virtual environment. | ||
| * | ||
| * @return the path to python | ||
| */ | ||
| public String getPython() { | ||
| if (pythonPath == null) { | ||
| pythonPath = runCommand(getCommandArgs(new String[] { "env", "info", "-e" })); | ||
| } | ||
| return pythonPath; | ||
| } | ||
| } |
22 changes: 22 additions & 0 deletions
22
...ins/org.python.pydev.core/src/org/python/pydev/core/package_manager/UVPackageManager.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package org.python.pydev.core.package_manager; | ||
|
|
||
| public class UVPackageManager extends BasePackageManager { | ||
| final public static String PREFS_NAME = "UV_BIN"; | ||
| private String pythonPath; | ||
|
|
||
| public UVPackageManager(String projectRoot) { | ||
| super(projectRoot, "uv", PREFS_NAME, "--directory"); | ||
| } | ||
|
|
||
| /** | ||
| * Returns the path to the python executable of a pyproject virtual environment. | ||
| * | ||
| * @return the path to python | ||
| */ | ||
| public String getPython() { | ||
| if (pythonPath == null) { | ||
| pythonPath = runCommand(getCommandArgs(new String[] { "python", "find" })); | ||
| } | ||
| return pythonPath; | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,4 +41,3 @@ JAVA_LOCATION=/usr/bin/java | |
|
|
||
| #/usr/bin/cygpath.exe | ||
| #CYGWIN_UNIX_CYGPATH_LOCATION=null | ||
|
|
||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get
java.lang.NoClassDefFoundError: org/python/pydev/core/package_manager/PoetryPackageManagerwhen this is removed?