Skip to content

Commit 4f7e6cd

Browse files
authored
chore!: switch py_wheel flags to True to start enforcing PEP440 (#1513)
Towards #1498.
1 parent c0e18ed commit 4f7e6cd

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ Breaking changes:
3535
will fail by default. The API symbol is going to be removed in the next
3636
version, please migrate to `pip_parse` as a replacement.
3737

38+
* (py_wheel) switch `incompatible_normalize_name` and
39+
`incompatible_normalize_version` to `True` by default to enforce `PEP440`
40+
for wheel names built by `rules_python`.
41+
3842
### Fixed
3943

4044
* Skip aliases for unloaded toolchains. Some Python versions that don't have full

python/private/py_wheel.bzl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ See [`py_wheel_dist`](/docs/packaging.md#py_wheel_dist) for more info.
120120

121121
_feature_flags = {
122122
"incompatible_normalize_name": attr.bool(
123-
default = False,
123+
default = True,
124124
doc = """\
125125
Normalize the package distribution name according to latest
126126
Python packaging standards.
@@ -133,7 +133,7 @@ Apart from the valid names according to the above, we also accept
133133
""",
134134
),
135135
"incompatible_normalize_version": attr.bool(
136-
default = False,
136+
default = True,
137137
doc = "Normalize the package version according to PEP440 standard. " +
138138
"With this option set to True, if the user wants to pass any " +
139139
"stamp variables, they have to be enclosed in '{}', e.g. " +
@@ -344,10 +344,10 @@ def _py_wheel_impl(ctx):
344344
args.add("--out", outfile)
345345
args.add("--name_file", name_file)
346346
args.add_all(ctx.attr.strip_path_prefixes, format_each = "--strip_path_prefix=%s")
347-
if ctx.attr.incompatible_normalize_name:
348-
args.add("--incompatible_normalize_name")
349-
if ctx.attr.incompatible_normalize_version:
350-
args.add("--incompatible_normalize_version")
347+
if not ctx.attr.incompatible_normalize_name:
348+
args.add("--noincompatible_normalize_name")
349+
if not ctx.attr.incompatible_normalize_version:
350+
args.add("--noincompatible_normalize_version")
351351

352352
# Pass workspace status files if stamping is enabled
353353
if is_stamping_enabled(ctx.attr):

tools/wheelmaker.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ def __init__(
218218
platform,
219219
outfile=None,
220220
strip_path_prefixes=None,
221-
incompatible_normalize_name=False,
222-
incompatible_normalize_version=False,
221+
incompatible_normalize_name=True,
222+
incompatible_normalize_version=True,
223223
):
224224
self._name = name
225225
self._version = version
@@ -460,8 +460,10 @@ def parse_args() -> argparse.Namespace:
460460
)
461461

462462
feature_group = parser.add_argument_group("Feature flags")
463-
feature_group.add_argument("--incompatible_normalize_name", action="store_true")
464-
feature_group.add_argument("--incompatible_normalize_version", action="store_true")
463+
feature_group.add_argument("--noincompatible_normalize_name", action="store_true")
464+
feature_group.add_argument(
465+
"--noincompatible_normalize_version", action="store_true"
466+
)
465467

466468
return parser.parse_args(sys.argv[1:])
467469

@@ -519,8 +521,8 @@ def main() -> None:
519521
platform=arguments.platform,
520522
outfile=arguments.out,
521523
strip_path_prefixes=strip_prefixes,
522-
incompatible_normalize_name=arguments.incompatible_normalize_name,
523-
incompatible_normalize_version=arguments.incompatible_normalize_version,
524+
incompatible_normalize_name=not arguments.noincompatible_normalize_name,
525+
incompatible_normalize_version=not arguments.noincompatible_normalize_version,
524526
) as maker:
525527
for package_filename, real_filename in all_files:
526528
maker.add_file(package_filename, real_filename)
@@ -545,10 +547,10 @@ def main() -> None:
545547
with open(arguments.metadata_file, "rt", encoding="utf-8") as metadata_file:
546548
metadata = metadata_file.read()
547549

548-
if arguments.incompatible_normalize_version:
549-
version_in_metadata = normalize_pep440(version)
550-
else:
550+
if arguments.noincompatible_normalize_version:
551551
version_in_metadata = version
552+
else:
553+
version_in_metadata = normalize_pep440(version)
552554
maker.add_metadata(
553555
metadata=metadata,
554556
name=name,

0 commit comments

Comments
 (0)