Skip to content

Instantly share code, notes, and snippets.

@colinvh
Last active February 29, 2024 13:25
Show Gist options
  • Save colinvh/4aad5a96463f8556755f to your computer and use it in GitHub Desktop.
Save colinvh/4aad5a96463f8556755f to your computer and use it in GitHub Desktop.
440 Semantic

PEP-440-Compatible Semantic Versioning

This document attempts to refine Python's PEP 440 to include the principles of Semantic Versioning.

Specification

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

  1. Versions will first follow the specification described in PEP 440. Before interpreting a version according to this specification, it should be normalized per PEP 440.

  2. Software using Semantic Versioning MUST declare a public API. This API could be declared in the code itself or exist strictly in documentation. However it is done, it should be precise and comprehensive.

  3. A release segment MUST contain three values, which shall be referred to herein as the major version, the minor version, and the patch version.

  4. Once a versioned package has been released, the contents of that version MUST NOT be modified. Any modifications MUST be released as a new version.

  5. Major version zero (0.y.z) is for initial development. Anything may change at any time. The public API should not be considered stable.

  6. Version 1.0.0 defines the public API. The way in which the version number is incremented after this release is dependent on this public API and how it changes.

  7. Patch version Z (x.y.Z | x > 0) MUST be incremented if only backwards compatible bug fixes are introduced. A bug fix is defined as an internal change that fixes incorrect behavior.

  8. Minor version Y (x.Y.z | x > 0) MUST be incremented if new, backwards compatible functionality is introduced to the public API. It MUST be incremented if any public API functionality is marked as deprecated. It MAY be incremented if substantial new functionality or improvements are introduced within the private code. It MAY include patch level changes. Patch version MUST be reset to 0 when minor version is incremented.

  9. Major version X (X.y.z | X > 0) MUST be incremented if any backwards incompatible changes are introduced to the public API. It MAY include minor and patch level changes. Patch and minor version MUST be reset to 0 when major version is incremented.

Conversion

The following table demonstrates equivalent versions in Semver 2.0 and 440 Semver:

Semver 2.0 440 Semver
1.0.0-DEV.1 1.0.0.dev1
1.0.0-a.0.DEV.3 1.0.0a0.dev3
1.0.0-alpha.0 1.0.0a0
1.0.0-b.2.DEV.5 1.0.0b2.dev5
1.0.0-beta.2 1.0.0b2
1.0.0-c.4.DEV.7 1.0.0rc4.dev7
1.0.0-rc.4 1.0.0rc4
@colinvh
Copy link
Author

colinvh commented Oct 27, 2015

Other possible conversions to Semver 2.0 include:

D1: No DEV segment
D2: DEV lowercase except in initial position within pre-release version
R1: Short name of rc is pre
R2: rc renamed to preview, with short name pre

Option D1 Option D2 Current Option R1 Option R2
1.0.0-1 1.0.0-DEV.1 1.0.0-DEV.1 1.0.0-DEV.1 1.0.0-DEV.1
1.0.0-a.0.3 1.0.0-a.0.dev.3 1.0.0-a.0.DEV.3 1.0.0-a.0.DEV.3 1.0.0-a.0.DEV.3
1.0.0-alpha.0 1.0.0-alpha.0 1.0.0-alpha.0 1.0.0-alpha.0 1.0.0-alpha.0
1.0.0-b.2.5 1.0.0-b.2.dev.5 1.0.0-b.2.DEV.5 1.0.0-b.2.DEV.5 1.0.0-b.2.DEV.5
1.0.0-beta.2 1.0.0-beta.2 1.0.0-beta.2 1.0.0-beta.2 1.0.0-beta.2
1.0.0-c.4.7 1.0.0-c.4.dev.7 1.0.0-c.4.DEV.7 1.0.0-pre.4.DEV.7 1.0.0-pre.4.DEV.7
1.0.0-rc.4 1.0.0-rc.4 1.0.0-rc.4 1.0.0-rc.4 1.0.0-preview.4

@kingjames37
Copy link

Testing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment