Skip to content
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

Handle Python Dependency Versions Correctly #1078

Closed

Conversation

MrArnoldPalmer
Copy link
Contributor

Change logic of python dependency version ranges. Parse semver number either as specific version or range and output to setup.py.

Fix #676


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Change logic of python dependency version ranges. Parse semver number
either as specific version or range and output to setup.py.

Fix aws#676
@MrArnoldPalmer MrArnoldPalmer requested review from RomainMuller, eladb and a team November 28, 2019 00:06
@mergify
Copy link
Contributor

mergify bot commented Nov 28, 2019

The title of this Pull Request does not conform with [Conventional Commits] guidelines. It will need to be adjusted before the PR can be merged.
[Conventional Commits]: https://www.conventionalcommits.org

@MrArnoldPalmer
Copy link
Contributor Author

Some questions for reviewers:

  1. Is throwing an error from the write method the best thing to do when an unknown version string is found?
  2. Is diff testing enough coverage here or should we separate this into some free floating funciton and unit test separately.
  3. jsii-calc currently declares "^0.28.0" for base dependencies but the .jsii output is 0.28.0. Should we preserve semver range shorthand in jsii output for code generation to leverage?

If we want to keep limiting the version numbers in jsii to not be ranges we can remove one of the branches here.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@@ -32,7 +32,7 @@
"install_requires": [
"jsii~=0.20.8",
"publication>=0.0.3",
"scope.jsii-calc-base-of-base~=0.20.8"
"scope.jsii-calc-base-of-base==0.20.8"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original dependency is a caret dependency (^), does == means the same thing in Python?

"@scope/jsii-calc-base-of-base": "^0.20.8"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that looks suspicious; but I reckon because the jsii compiler forwards the "resolved" (not "declared") version. That needs to be fixed as well (possibly in a separate PR, but then we probably shouldn't merge this without that).

Comment on lines +1172 to 1178
if (parsedVersion) {
versionSpecifier = `==${version}`;
} else if (parsedVersionRange) {
versionSpecifier = parsedVersionRange.replace(' ', ', ');
} else {
versionSpecifier = `~=${versionParts.slice(0, 2).join('.')},>=${versionParts.slice(0, 3).join('.')}`;
throw new Error(`Unexpected version format '${version}' for dependency: 'depName'`);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like it should have tests. Also - similar work should be done on Java and .NET dependencies.

@@ -32,7 +32,7 @@
"install_requires": [
"jsii~=0.20.8",
"publication>=0.0.3",
"scope.jsii-calc-base-of-base~=0.20.8"
"scope.jsii-calc-base-of-base==0.20.8"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that looks suspicious; but I reckon because the jsii compiler forwards the "resolved" (not "declared") version. That needs to be fixed as well (possibly in a separate PR, but then we probably shouldn't merge this without that).

@MrArnoldPalmer
Copy link
Contributor Author

So seems like solution here is:

  • Change output in .jsii to be the declared version and not the resolved one
  • Check that the resolved version overlaps with the declared version range
  • Output correct version range formats to target language dependency manifests
    • Python
    • Dotnet
    • Java
  • Test coverage

Will reopen when this is ready for review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Python dependency versions not handled correctly
4 participants