mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Support per-requirement overrides in requirements.txt parsing
This commit is contained in:
@@ -135,6 +135,9 @@ public class PyRequirement {
|
||||
"(?<" + VERSIONS_SPECS_GROUP + ">" + REQUIREMENT_VERSION_SPEC_REGEXP +
|
||||
"(" + LINE_WS_REGEXP + "*," + LINE_WS_REGEXP + "*" + REQUIREMENT_VERSION_SPEC_REGEXP + ")*)?";
|
||||
|
||||
@NotNull
|
||||
private static final String REQUIREMENT_OPTIONS_REGEXP = "((" + LINE_WS_REGEXP + "+(--global-option|--install-option)=\"[^\"]*\")+)?";
|
||||
|
||||
@NotNull
|
||||
private static final Pattern REQUIREMENT = Pattern.compile(
|
||||
REQUIREMENT_NAME_REGEXP +
|
||||
@@ -142,6 +145,7 @@ public class PyRequirement {
|
||||
REQUIREMENT_EXTRAS_REGEXP +
|
||||
LINE_WS_REGEXP + "*" +
|
||||
REQUIREMENT_VERSIONS_SPECS_REGEXP +
|
||||
REQUIREMENT_OPTIONS_REGEXP +
|
||||
COMMENT_REGEXP);
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -1634,7 +1634,6 @@ public class PyRequirementTest extends PyTestCase {
|
||||
// TODO: name normalization
|
||||
// TODO: hashes
|
||||
// TODO: multiline
|
||||
// TODO: https://pip.pypa.io/en/stable/reference/pip_install/#per-requirement-overrides
|
||||
// https://www.python.org/dev/peps/pep-0508/#names
|
||||
public void testRequirement() {
|
||||
assertEquals(new PyRequirement("Orange-Bioinformatics"), PyRequirement.fromLine("Orange-Bioinformatics"));
|
||||
@@ -1866,6 +1865,25 @@ public class PyRequirementTest extends PyTestCase {
|
||||
Arrays.asList("0.8.4", "0.8.99", "0.9.7", "0.9.99"));
|
||||
}
|
||||
|
||||
// https://pip.pypa.io/en/stable/reference/pip_install/#per-requirement-overrides
|
||||
public void testRequirementOptions() {
|
||||
final String name = "MyProject1";
|
||||
final String version = "1.2";
|
||||
final String optionsPrefix = name + " >= " + version;
|
||||
|
||||
final List<PyRequirementVersionSpec> versionSpecs =
|
||||
Collections.singletonList(new PyRequirementVersionSpec(PyRequirementRelation.GTE, version));
|
||||
|
||||
final String options1 = optionsPrefix + " " +
|
||||
"--global-option=\"--no-user-cfg\" " +
|
||||
"--install-option=\"--prefix='/usr/local'\" " +
|
||||
"--install-option=\"--no-compile\"";
|
||||
assertEquals(new PyRequirement(name, versionSpecs, options1), PyRequirement.fromLine(options1));
|
||||
|
||||
final String options2 = optionsPrefix + " --install-option=\"--install-scripts=/usr/local/bin\"";
|
||||
assertEquals(new PyRequirement(name, versionSpecs, options2), PyRequirement.fromLine(options2));
|
||||
}
|
||||
|
||||
// PY-6355
|
||||
public void testTrailingZeroesInVersion() {
|
||||
final PyRequirement req080 = PyRequirement.fromLine("foo==0.8.0");
|
||||
|
||||
Reference in New Issue
Block a user