@@ -68,6 +68,7 @@ def _detect_python_nox_id() -> str:
6868DOCKER_TEMPLATE = pathlib .Path ('docker/Dockerfile.template' )
6969
7070SYSTEM = platform .system ().lower ()
71+ MACHINE = platform .machine ().lower ()
7172
7273WINDOWS_TIMESTAMP_SERVER = 'http://timestamp.digicert.com'
7374WINDOWS_SIGNTOOL_PATH = 'C:/Program Files (x86)/Windows Kits/10/bin/10.0.17763.0/x86/signtool.exe'
@@ -84,13 +85,19 @@ def _detect_python_nox_id() -> str:
8485
8586
8687def pdm_install (
87- session : nox .Session , * groups : str , dev : bool = True , editable : bool = False
88+ session : nox .Session ,
89+ * groups : str ,
90+ dev : bool = True ,
91+ editable : bool = False ,
92+ no_isolated : bool = False ,
8893) -> None :
8994 args = []
9095 if not dev :
9196 args .append ('--prod' )
9297 if not editable :
9398 args .append ('--no-editable' )
99+ if no_isolated :
100+ args .extend (['--no-isolated' , '--no-self' ])
94101 for group in groups :
95102 args .extend (['--group' , group ])
96103 session .run ('pdm' , 'install' , * args , external = True )
@@ -139,6 +146,18 @@ def get_versions() -> list[str]:
139146 ]
140147
141148
149+ def is_x86_64_architecture ():
150+ """
151+ Determines if the machine's architecture is x86-based.
152+
153+ This function checks the current machine's architecture and returns
154+ whether it belongs to the x86 64-bit family (including x86_64 or amd64).
155+ """
156+ if MACHINE in ('x86_64' , 'amd64' ):
157+ return True
158+ return False
159+
160+
142161@nox .session (name = 'format' , python = PYTHON_DEFAULT_VERSION )
143162def format_ (session ):
144163 """Lint the code and apply fixes in-place whenever possible."""
@@ -298,20 +317,22 @@ def build(session):
298317
299318@nox .session (python = PYTHON_DEFAULT_VERSION )
300319def dump_license (session : nox .Session ):
301- pdm_install (session , 'license' , editable = True )
320+ pdm_install (session , 'license' , editable = True , dev = False )
302321 session .run ('b2' , 'license' , '--dump' , '--with-packages' )
303322
304323
305324@nox .session (python = PYTHON_DEFAULT_VERSION )
306325def bundle (session : nox .Session ):
307326 """Bundle the distribution."""
308327
328+ # We need no isolated mode to be able to compile staticx, particularly on ARM machines.
329+ pdm_install (session , 'bundle' , 'full' , no_isolated = True )
330+
309331 # We're running dump_license in another session because:
310332 # 1. `b2 license --dump` dumps the licence where the module is installed.
311333 # 2. We don't want to install b2 as editable module in the current session
312334 # because that would make `b2 versions` show the versions as editable.
313335 session .run ('nox' , '-s' , 'dump_license' , '-fb' , 'venv' , external = True )
314- pdm_install (session , 'bundle' , 'full' )
315336
316337 template_spec = string .Template (pathlib .Path ('b2.spec.template' ).read_text ())
317338 versions = get_versions ()
@@ -405,11 +426,15 @@ def sign_windows(keypair_alias, cert_fingerprint):
405426 else :
406427 session .error (f'unrecognized platform: { SYSTEM } ' )
407428
408- # Append OS name to all the binaries.
429+ # Append OS name and optionally an architecture to all the binaries.
409430 for asset in pathlib .Path ('dist' ).glob ('*' ):
410431 name = asset .stem
411432 ext = asset .suffix
412- asset_path = f'dist/{ name } -{ SYSTEM } { ext } '
433+ if is_x86_64_architecture ():
434+ asset_path = f'dist/{ name } -{ SYSTEM } { ext } '
435+ else :
436+ asset_path = f'dist/{ name } -{ SYSTEM } -{ MACHINE } { ext } '
437+
413438 session .run ('mv' , '-f' , asset , asset_path , external = True )
414439
415440 # Path have to be specified with unix style slashes even for windows,
0 commit comments