-
Notifications
You must be signed in to change notification settings - Fork 57
Description
The ordering of system platform requirements in the marker section produced by poetry-plugin-export appears to be nondeterministic. Repeated invocations of poetry export --without-hashes -f requirements.txt in our project will at a roughly coin flip probability produce either of the following two requirement specs:
-colorama==0.4.6 ; (sys_platform == "win32" or platform_system == "Windows") and python_full_version == "3.9.21"
+colorama==0.4.6 ; (platform_system == "Windows" or sys_platform == "win32") and python_full_version == "3.9.21"
Obviously (a || b) && c and (b || a) && c are logically equivalent, so there's no problem here in terms of actually installing the project, but we have precommit hooks and CI tooling to ensure that requirements.txt is kept up to date with changes in poetry.lock, and the fact that the marker section may change arbitrarily is causing build and check failures.
Unfortunately this is also not currently easily possible to work around by using a "smarter" approach to checking equivalence with the existing packaging tooling; packaging.requirements.Marker.__eq__() appears to be a simple string comparison:
>>> from packaging.requirements import Requirement
>>> r1 = Requirement('colorama==0.4.6 ; (sys_platform == "win32" or platform_system == "Windows") and python_full_version >= "3.9.21"')
>>> r2 = Requirement('colorama==0.4.6 ; (platform_system == "Windows" or sys_platform == "win32") and python_full_version >= "3.9.21"')
>>> r1 == r2
False
Request: any (a || b) component of the generated marker should be sorted lexically.