Updated Python package management tools (PY-9700, PY-8681)

This commit is contained in:
Andrey Vlasovskikh
2013-09-13 21:04:01 +04:00
parent 9466db5e20
commit a1e5aa1a74
8 changed files with 603 additions and 718 deletions
Binary file not shown.
+2 -2
View File
@@ -5,7 +5,7 @@ import os
ERROR_WRONG_USAGE = 1
ERROR_NO_PIP = 2
ERROR_NO_DISTRIBUTE = 3
ERROR_NO_SETUPTOOLS = 3
ERROR_EXCEPTION = 4
def exit(retcode):
@@ -42,7 +42,7 @@ def do_list():
try:
import pkg_resources
except ImportError:
error("Python package management tool 'setuptools' or 'distribute' not found", ERROR_NO_DISTRIBUTE)
error("Python package management tool 'setuptools' or 'distribute' not found", ERROR_NO_SETUPTOOLS)
for pkg in pkg_resources.working_set:
requires = ':'.join([str(x) for x in pkg.requires()])
sys.stdout.write('\t'.join([pkg.project_name, pkg.version, pkg.location, requires])+chr(10))
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large Load Diff
@@ -71,7 +71,7 @@ public class PyPackageManagerImpl extends PyPackageManager {
public static final int OK = 0;
public static final int ERROR_WRONG_USAGE = 1;
public static final int ERROR_NO_PIP = 2;
public static final int ERROR_NO_DISTRIBUTE = 3;
public static final int ERROR_NO_SETUPTOOLS = 3;
public static final int ERROR_INVALID_SDK = -1;
public static final int ERROR_TOOL_NOT_FOUND = -2;
public static final int ERROR_TIMEOUT = -3;
@@ -97,9 +97,12 @@ public class PyPackageManagerImpl extends PyPackageManager {
public static final String UNINSTALL = "uninstall";
public static final String UNTAR = "untar";
// Bundled package management tools
public static final String DISTRIBUTE = "distribute-0.6.27";
public static final String PIP = "pip-1.1";
// Bundled versions of package management tools
public static final String SETUPTOOLS_VERSION = "1.1.5";
public static final String PIP_VERSION = "1.4.1";
public static final String SETUPTOOLS = PACKAGE_SETUPTOOLS + "-" + SETUPTOOLS_VERSION;
public static final String PIP = PACKAGE_PIP + "-" + PIP_VERSION;
private List<PyPackage> myPackagesCache = null;
private Map<String, Set<PyPackage>> myDependenciesCache = null;
@@ -604,7 +607,7 @@ public class PyPackageManagerImpl extends PyPackageManager {
if (useGlobalSite) {
args.add("--system-site-packages");
}
args.addAll(list("--never-download", "--distribute", destinationDir));
args.add(destinationDir);
runPythonHelper(VIRTUALENV, args);
}
@@ -619,7 +622,7 @@ public class PyPackageManagerImpl extends PyPackageManager {
final ProjectJdkImpl tmpSdk = new ProjectJdkImpl("", PythonSdkType.getInstance());
tmpSdk.setHomePath(path);
final PyPackageManagerImpl manager = new PyPackageManagerImpl(tmpSdk);
manager.installManagement(DISTRIBUTE);
manager.installManagement(SETUPTOOLS);
manager.installManagement(PIP);
}
}
@@ -26,22 +26,22 @@ import java.util.Set;
* @author yole
*/
public class PyInstalledPackagesPanel extends InstalledPackagesPanel {
public static final String INSTALL_DISTRIBUTE = "installDistribute";
public static final String INSTALL_SETUPTOOLS = "installSetuptools";
public static final String INSTALL_PIP = "installPip";
public static final String CREATE_VENV = "createVEnv";
private boolean myHasDistribute;
private boolean myHasSetuptools;
private boolean myHasPip = true;
public PyInstalledPackagesPanel(Project project, PackagesNotificationPanel area) {
super(project, area);
myNotificationArea.addLinkHandler(INSTALL_DISTRIBUTE, new Runnable() {
myNotificationArea.addLinkHandler(INSTALL_SETUPTOOLS, new Runnable() {
@Override
public void run() {
final Sdk sdk = getSelectedSdk();
if (sdk != null) {
installManagementTool(sdk, PyPackageManagerImpl.DISTRIBUTE);
installManagementTool(sdk, PyPackageManagerImpl.SETUPTOOLS);
}
}
});
@@ -69,9 +69,9 @@ public class PyInstalledPackagesPanel extends InstalledPackagesPanel {
PyExternalProcessException exc = null;
try {
PyPackageManagerImpl packageManager = (PyPackageManagerImpl)PyPackageManager.getInstance(selectedSdk);
myHasDistribute = packageManager.findPackage(PyPackageManagerImpl.PACKAGE_DISTRIBUTE) != null;
if (!myHasDistribute) {
myHasDistribute = packageManager.findPackage(PyPackageManagerImpl.PACKAGE_SETUPTOOLS) != null;
myHasSetuptools = packageManager.findPackage(PyPackageManagerImpl.PACKAGE_SETUPTOOLS) != null;
if (!myHasSetuptools) {
myHasSetuptools = packageManager.findPackage(PyPackageManagerImpl.PACKAGE_DISTRIBUTE) != null;
}
myHasPip = packageManager.findPackage(PyPackageManagerImpl.PACKAGE_PIP) != null;
}
@@ -98,18 +98,18 @@ public class PyInstalledPackagesPanel extends InstalledPackagesPanel {
if (retCode == PyPackageManagerImpl.ERROR_NO_PIP) {
myHasPip = false;
}
else if (retCode == PyPackageManagerImpl.ERROR_NO_DISTRIBUTE) {
myHasDistribute = false;
else if (retCode == PyPackageManagerImpl.ERROR_NO_SETUPTOOLS) {
myHasSetuptools = false;
}
else {
text = externalProcessException.getMessage();
}
final boolean hasPackagingTools = myHasPip && myHasDistribute;
final boolean hasPackagingTools = myHasPip && myHasSetuptools;
allowCreateVirtualEnv &= !hasPackagingTools;
}
if (text == null) {
if (!myHasDistribute) {
text = "Python package management tools not found. <a href=\"" + INSTALL_DISTRIBUTE + "\">Install 'distribute'</a>";
if (!myHasSetuptools) {
text = "Python package management tools not found. <a href=\"" + INSTALL_SETUPTOOLS + "\">Install 'setuptools'</a>";
}
else if (!myHasPip) {
text = "Python packaging tool 'pip' not found. <a href=\"" + INSTALL_PIP + "\">Install 'pip'</a>";
@@ -172,7 +172,10 @@ public class PyInstalledPackagesPanel extends InstalledPackagesPanel {
return false;
}
}
if ("pip".equals(pkg.getName()) || "distribute".equals(pkg.getName())) {
final String name = pkg.getName();
if (PyPackageManagerImpl.PACKAGE_PIP.equals(name) ||
PyPackageManagerImpl.PACKAGE_SETUPTOOLS.equals(name) ||
PyPackageManagerImpl.PACKAGE_DISTRIBUTE.equals(name)) {
return false;
}
return true;