11import platform
22import os
3+ import sys
34
45from urllib .request import urlopen
56
@@ -20,21 +21,31 @@ class PostInstallCommand(install):
2021
2122 def run (self ):
2223 version_tag = 'v{}' .format (version )
23- url_template = 'https://github.com/LeetCode-OpenSource/py-sourcemap/releases/download/{tag}/py_sourcemap.cpython- {py_ver}-{platform}.so '
24+ url_template = 'https://github.com/LeetCode-OpenSource/py-sourcemap/releases/download/{tag}/py_sourcemap.{py_ver}-{platform}.{ext} '
2425 (major , minor , _ ) = platform .python_version_tuple ()
2526 if major != '3' or not (minor in ['5' , '6' , '7' ]):
2627 raise Exception ('Only python 3.5, 3.6, 3.7 are supported' )
27- py_version = '{}{}m' .format (major , minor )
2828 system = platform .system ()
2929 if system == 'Linux' :
30+ py_version = 'cpython-{}{}m' .format (major , minor )
3031 usr_platform = 'x86_64-linux-gnu'
32+ ext = 'so'
3133 elif system == 'Darwin' :
34+ py_version = 'cpython-{}{}m' .format (major , minor )
3235 usr_platform = 'x86_64-apple-darwin'
36+ ext = 'so'
37+ elif system == 'Windows' :
38+ py_version = 'cp{}{}' .format (major , minor )
39+ # from https://docs.python.org/3/library/platform.html
40+ is_64bits = sys .maxsize > 2 ** 32
41+ usr_platform = 'win_amd64' if is_64bits else 'win32'
42+ ext = 'pyd'
3343 else :
34- raise Exception ('This lib is only supporting Linux & macOS for now.' )
44+ raise Exception ('Your system is unrecognized: {}' . format ( system ) )
3545 download_url = url_template .format (tag = version_tag ,
3646 py_ver = py_version ,
37- platform = usr_platform )
47+ platform = usr_platform ,
48+ ext = ext )
3849 dist = os .path .join (self .build_lib , 'py_sourcemap/py_sourcemap.so' )
3950 if not local_build :
4051 with open (dist , 'wb' ) as f :
0 commit comments