mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Updated pip and setuptools, added legacy versions for Python 2.4-2.5 (PY-13244)
This commit is contained in:
@@ -75,15 +75,14 @@ def do_pyvenv(path, system_site_packages):
|
||||
venv.create(path, system_site_packages=system_site_packages)
|
||||
|
||||
|
||||
def untarDirectory(name):
|
||||
def do_untar(name):
|
||||
import tempfile
|
||||
|
||||
directory_name = tempfile.mkdtemp("pycharm-management")
|
||||
|
||||
import tarfile
|
||||
|
||||
filename = name + ".tar.gz"
|
||||
tar = tarfile.open(filename)
|
||||
tar = tarfile.open(name)
|
||||
for item in tar:
|
||||
tar.extract(item, directory_name)
|
||||
|
||||
@@ -91,6 +90,7 @@ def untarDirectory(name):
|
||||
sys.stdout.flush()
|
||||
return 0
|
||||
|
||||
|
||||
def mkdtemp_ifneeded():
|
||||
try:
|
||||
ind = sys.argv.index('--build-dir')
|
||||
@@ -133,7 +133,7 @@ def main():
|
||||
if len(sys.argv) < 2:
|
||||
usage()
|
||||
name = sys.argv[2]
|
||||
retcode = untarDirectory(name)
|
||||
retcode = do_untar(name)
|
||||
elif cmd == 'uninstall':
|
||||
if len(sys.argv) < 2:
|
||||
usage()
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -30,9 +30,9 @@ import java.util.Set;
|
||||
public abstract class PyPackageManager {
|
||||
public static final Key<Boolean> RUNNING_PACKAGING_TASKS = Key.create("PyPackageRequirementsInspection.RunningPackagingTasks");
|
||||
|
||||
public static final String PACKAGE_SETUPTOOLS = "setuptools";
|
||||
public static final String PACKAGE_PIP = "pip";
|
||||
public static final String PACKAGE_DISTRIBUTE = "distribute";
|
||||
public static final String SETUPTOOLS = "setuptools";
|
||||
public static final String PIP = "pip";
|
||||
public static final String DISTRIBUTE = "distribute";
|
||||
|
||||
public static final String USE_USER_SITE = "--user";
|
||||
|
||||
|
||||
@@ -160,7 +160,7 @@ public class PyPackageRequirementsInspection extends PyInspection {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (PyPackageManager.PACKAGE_SETUPTOOLS.equals(packageName)) {
|
||||
if (PyPackageManager.SETUPTOOLS.equals(packageName)) {
|
||||
return;
|
||||
}
|
||||
final Module module = ModuleUtilCore.findModuleForPsiElement(packageReferenceExpression);
|
||||
|
||||
@@ -60,12 +60,9 @@ import java.util.*;
|
||||
* @author vlan
|
||||
*/
|
||||
public class PyPackageManagerImpl extends PyPackageManager {
|
||||
// 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;
|
||||
// Python 2.4-2.5 compatible versions
|
||||
public static final String SETUPTOOLS_PRE_26_VERSION = "1.4.2";
|
||||
public static final String PIP_PRE_26_VERSION = "1.1";
|
||||
|
||||
public static final int OK = 0;
|
||||
public static final int ERROR_NO_PIP = 2;
|
||||
@@ -118,18 +115,21 @@ public class PyPackageManagerImpl extends PyPackageManager {
|
||||
|
||||
@Override
|
||||
public void installManagement() throws PyExternalProcessException {
|
||||
if (!hasPackage(PACKAGE_SETUPTOOLS, false) && !hasPackage(PACKAGE_DISTRIBUTE, false)) {
|
||||
installManagement(SETUPTOOLS);
|
||||
final boolean pre26 = PythonSdkType.getLanguageLevelForSdk(mySdk).isOlderThan(LanguageLevel.PYTHON26);
|
||||
if (!hasPackage(SETUPTOOLS, false) && !hasPackage(DISTRIBUTE, false)) {
|
||||
final String name = SETUPTOOLS + (pre26 ? "-" + SETUPTOOLS_PRE_26_VERSION : "") + ".tar.gz";
|
||||
installManagement(name);
|
||||
}
|
||||
if (!hasPackage(PACKAGE_PIP, false)) {
|
||||
installManagement(PIP);
|
||||
if (!hasPackage(PIP, false)) {
|
||||
final String name = PIP + (pre26 ? "-" + PIP_PRE_26_VERSION : "") + ".tar.gz";
|
||||
installManagement(name);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasManagement(boolean cachedOnly) {
|
||||
return (hasPackage(PACKAGE_SETUPTOOLS, cachedOnly) || hasPackage(PACKAGE_DISTRIBUTE, cachedOnly)) &&
|
||||
hasPackage(PACKAGE_PIP, cachedOnly);
|
||||
return (hasPackage(SETUPTOOLS, cachedOnly) || hasPackage(DISTRIBUTE, cachedOnly)) &&
|
||||
hasPackage(PIP, cachedOnly);
|
||||
}
|
||||
|
||||
protected void installManagement(@NotNull String name) throws PyExternalProcessException {
|
||||
@@ -346,7 +346,7 @@ public class PyPackageManagerImpl extends PyPackageManager {
|
||||
args.add("--system-site-packages");
|
||||
}
|
||||
args.add(destinationDir);
|
||||
runPythonHelper(VIRTUALENV, args);
|
||||
runPythonHelper(VIRTUALENV, args);
|
||||
}
|
||||
|
||||
final String binary = PythonSdkType.getPythonExecutable(destinationDir);
|
||||
|
||||
@@ -156,9 +156,9 @@ public class PyInstalledPackagesPanel extends InstalledPackagesPanel {
|
||||
}
|
||||
}
|
||||
final String name = pkg.getName();
|
||||
if (PyPackageManager.PACKAGE_PIP.equals(name) ||
|
||||
PyPackageManager.PACKAGE_SETUPTOOLS.equals(name) ||
|
||||
PyPackageManager.PACKAGE_DISTRIBUTE.equals(name)) {
|
||||
if (PyPackageManager.PIP.equals(name) ||
|
||||
PyPackageManager.SETUPTOOLS.equals(name) ||
|
||||
PyPackageManager.DISTRIBUTE.equals(name)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -84,11 +84,11 @@ public class PyPackagingTest extends PyEnvTestCase {
|
||||
final PyPackage setuptools = findPackage("setuptools", packages);
|
||||
assertNotNull(setuptools);
|
||||
assertEquals("setuptools", setuptools.getName());
|
||||
assertEquals(PyPackageManagerImpl.SETUPTOOLS_VERSION, setuptools.getVersion());
|
||||
assertEquals(PyPackageManager.SETUPTOOLS, setuptools.getVersion());
|
||||
final PyPackage pip = findPackage("pip", packages);
|
||||
assertNotNull(pip);
|
||||
assertEquals("pip", pip.getName());
|
||||
assertEquals(PyPackageManagerImpl.PIP_VERSION, pip.getVersion());
|
||||
assertEquals(PyPackageManager.PIP, pip.getVersion());
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
@@ -124,7 +124,6 @@ public class PyPackagingTest extends PyEnvTestCase {
|
||||
final PyPackage pip1 = findPackage("pip", packages1);
|
||||
assertNotNull(pip1);
|
||||
assertEquals("pip", pip1.getName());
|
||||
assertEquals(PyPackageManagerImpl.PIP_VERSION, pip1.getVersion());
|
||||
manager.uninstall(list(pip1));
|
||||
final List<PyPackage> packages3 = manager.getPackages(false);
|
||||
final PyPackage pip2 = findPackage("pip", packages3);
|
||||
|
||||
Reference in New Issue
Block a user