File tree Expand file tree Collapse file tree 2 files changed +21
-14
lines changed Expand file tree Collapse file tree 2 files changed +21
-14
lines changed Original file line number Diff line number Diff line change @@ -62,28 +62,36 @@ def load_libgmt(lib_fullnames=None):
62
62
return libgmt
63
63
64
64
65
- def clib_names (os_name ) :
65
+ def clib_names (os_name : str ) -> list [ str ] :
66
66
"""
67
- Return the name of GMT's shared library for the current OS .
67
+ Return the name(s) of GMT's shared library for the current operating system .
68
68
69
69
Parameters
70
70
----------
71
- os_name : str
71
+ os_name
72
72
The operating system name as given by ``sys.platform``.
73
73
74
74
Returns
75
75
-------
76
- libnames : list of str
76
+ libnames
77
77
List of possible names of GMT's shared library.
78
+
79
+ Raises
80
+ ------
81
+ GMTOSError
82
+ If the operating system is not supported yet.
78
83
"""
79
- if os_name .startswith (("linux" , "freebsd" )):
80
- libnames = ["libgmt.so" ]
81
- elif os_name == "darwin" : # Darwin is macOS
82
- libnames = ["libgmt.dylib" ]
83
- elif os_name == "win32" :
84
- libnames = ["gmt.dll" , "gmt_w64.dll" , "gmt_w32.dll" ]
85
- else :
86
- raise GMTOSError (f"Operating system '{ os_name } ' not supported." )
84
+ match os_name :
85
+ case "linux" : # Linux
86
+ libnames = ["libgmt.so" ]
87
+ case "darwin" : # macOS
88
+ libnames = ["libgmt.dylib" ]
89
+ case "win32" : # Windows
90
+ libnames = ["gmt.dll" , "gmt_w64.dll" , "gmt_w32.dll" ]
91
+ case name if name .startswith ("freebsd" ): # FreeBSD
92
+ libnames = ["libgmt.so" ]
93
+ case _:
94
+ raise GMTOSError (f"Operating system '{ os_name } ' is not supported." )
87
95
return libnames
88
96
89
97
Original file line number Diff line number Diff line change @@ -50,8 +50,7 @@ def test_clib_names():
50
50
"""
51
51
Make sure we get the correct library name for different OS names.
52
52
"""
53
- for linux in ["linux" , "linux2" , "linux3" ]:
54
- assert clib_names (linux ) == ["libgmt.so" ]
53
+ assert clib_names ("linux" ) == ["libgmt.so" ]
55
54
assert clib_names ("darwin" ) == ["libgmt.dylib" ]
56
55
assert clib_names ("win32" ) == ["gmt.dll" , "gmt_w64.dll" , "gmt_w32.dll" ]
57
56
for freebsd in ["freebsd10" , "freebsd11" , "freebsd12" ]:
You can’t perform that action at this time.
0 commit comments