chore!: switch py_wheel flags to True to start enforcing PEP440 (#1513)
Towards #1498.
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 62a372d..4c1c0b7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -35,6 +35,10 @@
will fail by default. The API symbol is going to be removed in the next
version, please migrate to `pip_parse` as a replacement.
+* (py_wheel) switch `incompatible_normalize_name` and
+ `incompatible_normalize_version` to `True` by default to enforce `PEP440`
+ for wheel names built by `rules_python`.
+
### Fixed
* Skip aliases for unloaded toolchains. Some Python versions that don't have full
diff --git a/python/private/py_wheel.bzl b/python/private/py_wheel.bzl
index 4152e08..1f5792b 100644
--- a/python/private/py_wheel.bzl
+++ b/python/private/py_wheel.bzl
@@ -120,7 +120,7 @@
_feature_flags = {
"incompatible_normalize_name": attr.bool(
- default = False,
+ default = True,
doc = """\
Normalize the package distribution name according to latest
Python packaging standards.
@@ -133,7 +133,7 @@
""",
),
"incompatible_normalize_version": attr.bool(
- default = False,
+ default = True,
doc = "Normalize the package version according to PEP440 standard. " +
"With this option set to True, if the user wants to pass any " +
"stamp variables, they have to be enclosed in '{}', e.g. " +
@@ -344,10 +344,10 @@
args.add("--out", outfile)
args.add("--name_file", name_file)
args.add_all(ctx.attr.strip_path_prefixes, format_each = "--strip_path_prefix=%s")
- if ctx.attr.incompatible_normalize_name:
- args.add("--incompatible_normalize_name")
- if ctx.attr.incompatible_normalize_version:
- args.add("--incompatible_normalize_version")
+ if not ctx.attr.incompatible_normalize_name:
+ args.add("--noincompatible_normalize_name")
+ if not ctx.attr.incompatible_normalize_version:
+ args.add("--noincompatible_normalize_version")
# Pass workspace status files if stamping is enabled
if is_stamping_enabled(ctx.attr):
diff --git a/tools/wheelmaker.py b/tools/wheelmaker.py
index 66e86fb..62225b6 100644
--- a/tools/wheelmaker.py
+++ b/tools/wheelmaker.py
@@ -218,8 +218,8 @@
platform,
outfile=None,
strip_path_prefixes=None,
- incompatible_normalize_name=False,
- incompatible_normalize_version=False,
+ incompatible_normalize_name=True,
+ incompatible_normalize_version=True,
):
self._name = name
self._version = version
@@ -460,8 +460,10 @@
)
feature_group = parser.add_argument_group("Feature flags")
- feature_group.add_argument("--incompatible_normalize_name", action="store_true")
- feature_group.add_argument("--incompatible_normalize_version", action="store_true")
+ feature_group.add_argument("--noincompatible_normalize_name", action="store_true")
+ feature_group.add_argument(
+ "--noincompatible_normalize_version", action="store_true"
+ )
return parser.parse_args(sys.argv[1:])
@@ -519,8 +521,8 @@
platform=arguments.platform,
outfile=arguments.out,
strip_path_prefixes=strip_prefixes,
- incompatible_normalize_name=arguments.incompatible_normalize_name,
- incompatible_normalize_version=arguments.incompatible_normalize_version,
+ incompatible_normalize_name=not arguments.noincompatible_normalize_name,
+ incompatible_normalize_version=not arguments.noincompatible_normalize_version,
) as maker:
for package_filename, real_filename in all_files:
maker.add_file(package_filename, real_filename)
@@ -545,10 +547,10 @@
with open(arguments.metadata_file, "rt", encoding="utf-8") as metadata_file:
metadata = metadata_file.read()
- if arguments.incompatible_normalize_version:
- version_in_metadata = normalize_pep440(version)
- else:
+ if arguments.noincompatible_normalize_version:
version_in_metadata = version
+ else:
+ version_in_metadata = normalize_pep440(version)
maker.add_metadata(
metadata=metadata,
name=name,