@@ -611,6 +611,20 @@ def add_create_lock_options(cls, create_parser):
611611 "extras deps that are never activated, but may trim more in the future."
612612 ),
613613 )
614+ create_parser .add_argument (
615+ "--lock-build-systems" ,
616+ "--no-lock-build-systems" ,
617+ dest = "lock_build_systems" ,
618+ default = False ,
619+ action = HandleBoolAction ,
620+ type = bool ,
621+ help = (
622+ "When creating a lock that includes sdists, VCS requirements or local project "
623+ "directories that will later need to be built into wheels when using the lock, "
624+ "also lock the build system for each of these source tree artifacts to ensure "
625+ "consistent build environments at future times."
626+ ),
627+ )
614628 cls ._add_lock_options (create_parser )
615629 cls ._add_resolve_options (create_parser )
616630 cls .add_json_options (create_parser , entity = "lock" , include_switch = False )
@@ -905,6 +919,33 @@ def add_extra_arguments(
905919 ) as sync_parser :
906920 cls ._add_sync_arguments (sync_parser )
907921
922+ def _get_lock_configuration (self , target_configuration ):
923+ # type: (TargetConfiguration) -> Union[LockConfiguration, Error]
924+ if self .options .style is LockStyle .UNIVERSAL :
925+ return LockConfiguration (
926+ style = LockStyle .UNIVERSAL ,
927+ requires_python = tuple (
928+ str (interpreter_constraint .requires_python )
929+ for interpreter_constraint in target_configuration .interpreter_constraints
930+ ),
931+ target_systems = tuple (self .options .target_systems ),
932+ elide_unused_requires_dist = self .options .elide_unused_requires_dist ,
933+ lock_build_systems = self .options .lock_build_systems ,
934+ )
935+
936+ if self .options .target_systems :
937+ return Error (
938+ "The --target-system option only applies to --style {universal} locks." .format (
939+ universal = LockStyle .UNIVERSAL .value
940+ )
941+ )
942+
943+ return LockConfiguration (
944+ style = self .options .style ,
945+ elide_unused_requires_dist = self .options .elide_unused_requires_dist ,
946+ lock_build_systems = self .options .lock_build_systems ,
947+ )
948+
908949 def _resolve_targets (
909950 self ,
910951 action , # type: str
@@ -987,6 +1028,7 @@ def _merge_project_requirements(
9871028
9881029 def _locking_configuration (self , pip_configuration ):
9891030 # type: (PipConfiguration) -> Union[LockingConfiguration, Error]
1031+
9901032 requirement_configuration = requirement_options .configure (self .options )
9911033 target_configuration = target_options .configure (
9921034 self .options , pip_configuration = pip_configuration
@@ -998,27 +1040,7 @@ def _locking_configuration(self, pip_configuration):
9981040 )
9991041 requirement_configuration = script_metadata_application .requirement_configuration
10001042 target_configuration = script_metadata_application .target_configuration
1001- if self .options .style == LockStyle .UNIVERSAL :
1002- lock_configuration = LockConfiguration (
1003- style = LockStyle .UNIVERSAL ,
1004- requires_python = tuple (
1005- str (interpreter_constraint .requires_python )
1006- for interpreter_constraint in target_configuration .interpreter_constraints
1007- ),
1008- target_systems = tuple (self .options .target_systems ),
1009- elide_unused_requires_dist = self .options .elide_unused_requires_dist ,
1010- )
1011- elif self .options .target_systems :
1012- return Error (
1013- "The --target-system option only applies to --style {universal} locks." .format (
1014- universal = LockStyle .UNIVERSAL .value
1015- )
1016- )
1017- else :
1018- lock_configuration = LockConfiguration (
1019- style = self .options .style ,
1020- elide_unused_requires_dist = self .options .elide_unused_requires_dist ,
1021- )
1043+ lock_configuration = try_ (self ._get_lock_configuration (target_configuration ))
10221044 return LockingConfiguration (
10231045 requirement_configuration ,
10241046 target_configuration ,
@@ -1840,8 +1862,8 @@ def process_req_edits(
18401862 lock_file = attr .evolve (
18411863 lock_file ,
18421864 pex_version = __version__ ,
1843- requirements = SortedTuple (requirements_by_project_name .values (), key = str ),
1844- constraints = SortedTuple (constraints_by_project_name .values (), key = str ),
1865+ requirements = SortedTuple (requirements_by_project_name .values ()),
1866+ constraints = SortedTuple (constraints_by_project_name .values ()),
18451867 locked_resolves = SortedTuple (
18461868 resolve_update .updated_resolve for resolve_update in lock_update .resolves
18471869 ),
0 commit comments