File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change 1
1
Release notes
2
2
=============
3
3
4
+ Version 31.1.0 - (2024-05-15)
5
+ ------------------------------
6
+
7
+ - Add ``on_macos_arm64 `` and ``on_ubuntu_22 `` markers to ``commoncode.system ``.
8
+
9
+
4
10
Version 31.0.3 - (2023-08-25)
5
11
------------------------------
6
12
Original file line number Diff line number Diff line change @@ -71,6 +71,49 @@ def is_on_macos_14_or_higher():
71
71
del is_on_macos_14_or_higher
72
72
73
73
74
+ def is_on_macos_arm64 ():
75
+ """
76
+ Return True if the current OS is macOS running on Apple Silicon.
77
+ """
78
+ import platform
79
+ return on_mac and platform .machine () == 'arm64'
80
+
81
+
82
+ on_macos_arm64 = is_on_macos_arm64 ()
83
+
84
+ del is_on_macos_arm64
85
+
86
+
87
+ def get_etc_os_release_info (os_release_path = '/etc/os-release' ):
88
+ """
89
+ Return a dictionary of key-value pairs from /etc/os-release
90
+ """
91
+ os_release_data = {}
92
+ with open (os_release_path ) as f :
93
+ for line in f :
94
+ split_line = line .split ('=' )
95
+ if not split_line :
96
+ continue
97
+ k = split_line [0 ].strip ()
98
+ v = split_line [- 1 ].strip ()
99
+ os_release_data [k ] = v
100
+ return os_release_data
101
+
102
+
103
+ def is_on_ubuntu_22 ():
104
+ """
105
+ Return True if the current OS is Ubuntu 22.XX.
106
+ """
107
+ if not on_linux :
108
+ return False
109
+ os_release_info = get_etc_os_release_info ()
110
+ return os_release_info ['ID' ] == 'ubuntu' and '22' in os_release_info ['VERSION_ID' ]
111
+
112
+ on_ubuntu_22 = is_on_ubuntu_22 ()
113
+
114
+ del is_on_ubuntu_22
115
+
116
+
74
117
def has_case_sensitive_fs ():
75
118
"""
76
119
Return True if the current FS is case sensitive.
You can’t perform that action at this time.
0 commit comments