Created
April 16, 2014 08:50
-
-
Save DanielOaks/10835439 to your computer and use it in GitHub Desktop.
Adds the correct extension to a provided library path
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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