Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Adds the correct extension to a provided library path
# platform library extension adder for Python or something
import os
import sys
__PLATFORM_LIBRARY_EXTENSIONS = {
'windows': 'dll',
'darwin': 'dylib',
'linux': 'so',
}
def add_library_extension(original_name):
"""Add the platform's library file extension to the given file name.
If we don't know what extension this platform uses, returns None.
"""
if sys.platform in __PLATFORM_LIBRARY_EXTENSIONS:
return '{}{}{}'.format(original_name, os.extsep, __PLATFORM_LIBRARY_EXTENSIONS[sys.platform])
return None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.