-
Notifications
You must be signed in to change notification settings - Fork 362
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(semver): improved support of the Python Version Identification pa…
…rt of PEP440 (#3474) The semver util's current version logic does not fully implement/adhere to PEP440 in two respects: * There is no support for "[local version identifiers](https://packaging.python.org/en/latest/specifications/version-specifiers/#local-version-identifiers)", which are basically the same as SemVer's build metadata (e.g. `1.2.3+foobar`), when used in conjunction with a pre-release label. * The current pre-release logic doesn't reflect the ability for python pre-releases to include [post-release](https://packaging.python.org/en/latest/specifications/version-specifiers/#post-releases) and [developmental release](https://packaging.python.org/en/latest/specifications/version-specifiers/#developmental-releases) labels in conjunction with the pre-release itself (e.g. `1.2.3.rc1.post2.dev3`) This PR addresses these gaps so that the python release supports these features. I've kept support for the `pre` label as a synonym for `dev`. Projen and JSII's logic diverged ever so slightly re: including a `.` between the version and pre-release labels (e.g. projen was yielding `1.2.3rc0` while JSII would yield `1.2.3.rc0`. I decided to update projen's logic to mirror that from JSII. E.g. now `1.2.3-rc.1.dev.2.post.3+foobar` will now yield `1.2.3.rc1.post3.dev2+foobar` for python packages. I have an identical PR open over in jsii: aws/jsii#4462 --- By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
- Loading branch information
Showing
3 changed files
with
105 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { toReleaseVersion, TargetName } from "../../src/util/semver"; | ||
|
||
describe(`toReleaseVersion (${TargetName.PYTHON})`, () => { | ||
test("supports standard versions", () => { | ||
expect(toReleaseVersion("1.2.3", TargetName.PYTHON)).toBe("1.2.3"); | ||
}); | ||
test("supports build metadata", () => { | ||
expect(toReleaseVersion("1.2.3+foobar", TargetName.PYTHON)).toBe( | ||
"1.2.3+foobar" | ||
); | ||
}); | ||
test("supports pre-releases", () => { | ||
expect(toReleaseVersion("1.2.3-rc.123", TargetName.PYTHON)).toBe( | ||
"1.2.3.rc123" | ||
); | ||
}); | ||
test("supports developmental releases", () => { | ||
expect(toReleaseVersion("1.2.3-dev.123", TargetName.PYTHON)).toBe( | ||
"1.2.3.dev123" | ||
); | ||
}); | ||
test("supports post releases", () => { | ||
expect(toReleaseVersion("1.2.3-post.123", TargetName.PYTHON)).toBe( | ||
"1.2.3.post123" | ||
); | ||
}); | ||
test("supports pre-releases with dev/post and build metadata", () => { | ||
expect( | ||
toReleaseVersion( | ||
"1.2.3-rc.123.post.456.dev.789+foobar", | ||
TargetName.PYTHON | ||
) | ||
).toBe("1.2.3.rc123.post456.dev789+foobar"); | ||
}); | ||
}); |