@@ -619,7 +619,7 @@ def add_str(content, to_):
619
619
620
620
# Update <name>-<version>.dist-info/RECORD. This must be last.
621
621
#
622
- z .writestr (f'{ dist_info_dir } /RECORD' , record .get ())
622
+ z .writestr (f'{ dist_info_dir } /RECORD' , record .get (f' { dist_info_dir } /RECORD' ))
623
623
624
624
st = os .stat (path )
625
625
_log ( f'Have created wheel size={ st .st_size } : { path } ' )
@@ -1596,6 +1596,7 @@ def base_compiler(vs=None, pythonflags=None, cpp=False, use_env=True):
1596
1596
cc = 'em++' if cpp else 'emcc'
1597
1597
else :
1598
1598
cc = 'c++' if cpp else 'cc'
1599
+ cc = macos_add_cross_flags ( cc )
1599
1600
return cc , pythonflags
1600
1601
1601
1602
@@ -1636,6 +1637,7 @@ def base_linker(vs=None, pythonflags=None, cpp=False, use_env=True):
1636
1637
linker = 'em++' if cpp else 'emcc'
1637
1638
else :
1638
1639
linker = 'c++' if cpp else 'cc'
1640
+ linker = macos_add_cross_flags ( linker )
1639
1641
return linker , pythonflags
1640
1642
1641
1643
@@ -1730,6 +1732,9 @@ def wasm():
1730
1732
def pyodide ():
1731
1733
return os .environ .get ( 'PYODIDE' ) == '1'
1732
1734
1735
+ def linux ():
1736
+ return platform .system () == 'Linux'
1737
+
1733
1738
class PythonFlags :
1734
1739
'''
1735
1740
Compile/link flags for the current python, for example the include path
@@ -1775,11 +1780,38 @@ def __init__(self):
1775
1780
#if darwin():
1776
1781
# self.ldflags =
1777
1782
self .ldflags = run ( f'{ python_config } --ldflags' , capture = 1 ).strip ()
1783
+ if linux ():
1784
+ # It seems that with python-3.10 on Linux, we can get an
1785
+ # incorrect -lcrypt flag that on some systems (e.g. WSL)
1786
+ # causes:
1787
+ #
1788
+ # ImportError: libcrypt.so.2: cannot open shared object file: No such file or directory
1789
+ #
1790
+ ldflags2 = self .ldflags .replace (' -lcrypt ' , ' ' )
1791
+ if ldflags2 != self .ldflags :
1792
+ _log (f'### Have removed `-lcrypt` from ldflags: { self .ldflags !r} -> { ldflags2 !r} ' )
1793
+ self .ldflags = ldflags2
1778
1794
1779
1795
_log (f'self.includes={ self .includes !r} ' )
1780
1796
_log (f'self.ldflags={ self .ldflags !r} ' )
1781
1797
1782
1798
1799
+ def macos_add_cross_flags (command ):
1800
+ '''
1801
+ If running on MacOS and environment variables ARCHFLAGS is set
1802
+ (indicating we are cross-building, e.g. for arm64), returns
1803
+ `command` with extra flags appended. Otherwise returns unchanged
1804
+ `command`.
1805
+ '''
1806
+ if darwin ():
1807
+ archflags = os .environ .get ( 'ARCHFLAGS' )
1808
+ if archflags :
1809
+ command = f'{ command } { archflags } '
1810
+ _log (f'Appending ARCHFLAGS to command: { command } ' )
1811
+ return command
1812
+ return command
1813
+
1814
+
1783
1815
def macos_patch ( library , * sublibraries ):
1784
1816
'''
1785
1817
If running on MacOS, patches `library` so that all references to items in
@@ -1998,5 +2030,14 @@ def add_file(self, from_, to_, verbose=False):
1998
2030
if verbose :
1999
2031
_log (f'Adding file: { os .path .relpath (from_ )} => { to_ } ' )
2000
2032
2001
- def get (self ):
2002
- return self .text
2033
+ def get (self , record_path = None ):
2034
+ '''
2035
+ Returns contents of the RECORD file. If `record_path` is
2036
+ specified we append a final line `<record_path>,,`; this can be
2037
+ used to include the RECORD file itself in the contents, with
2038
+ empty hash and size fields.
2039
+ '''
2040
+ ret = self .text
2041
+ if record_path :
2042
+ ret += f'{ record_path } ,,\n '
2043
+ return ret
0 commit comments