How to use get_compatible_versions method in localstack

Best Python code snippet using localstack_python

resolve_versions.py

Source:resolve_versions.py Github

copy

Full Screen

...63 )64 parser_matrix.add_argument("-n", "--package-name", type=str, help="Package name")65 parser_matrix.add_argument("-s", "--specifiers", type=str, help="Specifiers")66 return parser.parse_args()67def get_compatible_versions(68 python_code: str, operating_system: str, package_name: str, specifier: str69) -> list[str]:70 implementation, python_version = get_python_version_and_implementation(python_code)71 versions = get_versions(72 package_name, operating_system, python_version, implementation73 )74 return filter_versions(versions, specifier)75def process_versions(args: Namespace) -> None:76 filtered_versions = get_compatible_versions(77 args.python_code, args.operating_system, args.package_name, args.specifier78 )79 if not filtered_versions:80 print(f"Found no {args.package_name} version.", file=sys.stderr)81 exit(1)82 print(83 f"Found the following {args.package_name} versions: {', '.join(v for v in filtered_versions)}",84 file=sys.stderr,85 )86def process_matrix(args: Namespace) -> None:87 python_codes = json.loads(args.python_codes)88 operating_systems = json.loads(args.operating_systems)89 package_name = args.package_name90 specifiers = json.loads(args.specifiers)91 matrix = itertools.product(92 python_codes, operating_systems, [package_name], specifiers93 )94 output = {"include": []}95 for c, o, n, s in matrix:96 compatible_versions = get_compatible_versions(c, o, n, s)97 if compatible_versions:98 # This is because celery 3 depends on use_2to3,99 # which is no longer supported by 3.9 and 3.10100 if (101 n == "celery"102 and (103 c.replace(".", "").startswith("39")104 or c.replace(".", "").startswith("310")105 )106 and all(cv.startswith("3") for cv in compatible_versions)107 ):108 continue109 output["include"].append(110 {...

Full Screen

Full Screen

repository.py

Source:repository.py Github

copy

Full Screen

...24 raise PackageNotFoundError(package_name, package_version)25 def get_package_releases(self, package_name: str) -> Dict[str, list]:26 return self.get_package_info(package_name)['releases']27 # Assumption: first requirement should have metadata or else I'll go and get it myself28 def get_compatible_versions(self, *requirements: Requirement) -> List[Union[LegacyVersion, Version]]:29 if not requirements:30 raise InvalidRequirementError('No requirements given.')31 names: Set[str] = set(map(lambda r: r.name.lower(), requirements))32 if len(names) > 1:33 raise InvalidRequirementError(f"Requirements must have the same package name. Names provided: {names}")34 name = names.pop()35 if requirements[0].project_metadata:36 all_versions = map(utils.convert_to_version, requirements[0].project_metadata['releases'].keys())37 else:38 all_versions = map(utils.convert_to_version, self.get_package_releases(name).keys())39 final_specifier = reduce(SpecifierSet.__and__, map(lambda r: r.specifier, requirements))40 return list(final_specifier.filter(all_versions))41 def populate_requirement(self, requirement: Requirement):42 requirement.project_metadata = self.get_package_info(requirement.name)43 requirement.compatible_versions = self.get_compatible_versions(requirement)...

Full Screen

Full Screen

test_repository.py

Source:test_repository.py Github

copy

Full Screen

1from snek.repository import Repository2from snek.requirement import Requirement3from tests.conftest import mock_repository_json4class TestRepository:5 def test_get_compatible_versions(self, mocker):6 mock_repository_json(mocker)7 repo = Repository()8 assert len(repo.get_compatible_versions(Requirement('Flask'))) == 329 assert len(repo.get_compatible_versions(Requirement('Flask'), Requirement('Flask > 1.0'))) == 610 assert len(repo.get_compatible_versions(Requirement('Flask'), Requirement('Flask > 1.0'),11 Requirement('Flask <= 1.1'))) == 512 assert len(repo.get_compatible_versions(Requirement('Flask'), Requirement('Flask ~= 1.0'))) == 7...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful