1+ import platform
2+ import os
3+ import sys
4+
5+ from urllib .request import urlopen
6+
17from setuptools import setup
28from setuptools .command .install import install
39
410
5- with open ("README.md" , "r" ) as fh :
6- long_description = fh .read ()
11+ version = '0.1.10'
12+ local_build = os .environ .get ('LOCAL' , 0 )
13+
14+
15+ with open ('README.md' , 'r' ) as f :
16+ long_description = f .read ()
717
818
919class PostInstallCommand (install ):
1020 """Post-installation for installation mode."""
1121
1222 def run (self ):
13- '''
14- Write downloading process here
15- mv target .so file into `py_sourcemap/py_sourcemap.so`
16- '''
23+ version_tag = 'v{}' .format (version )
24+ url_template = 'https://github.com/LeetCode-OpenSource/py-sourcemap/releases/download/{tag}/py_sourcemap.cpython-{py_ver}-{platform}.so'
25+ py_version = '{}{}m' .format (sys .version_info .major ,
26+ sys .version_info .minor )
27+ system = platform .system ()
28+ if system == 'Linux' :
29+ platform = 'x86_64-linux-gnu'
30+ else :
31+ raise Exception ('This lib is only supporting Linux for now.' )
32+ download_url = url_template .format (tag = version_tag ,
33+ py_ver = py_version ,
34+ platform = platform )
35+ dist = os .path .join (self .build_lib , 'py_sourcemap/py_sourcemap.so' )
36+ if not local_build :
37+ with open (dist , 'wb' ) as f :
38+ built_lib = urlopen (download_url ).read ()
39+ f .write (built_lib )
1740 install .run (self )
1841
1942
@@ -22,7 +45,7 @@ def run(self):
2245
2346setup (
2447 name = 'py-sourcemap' ,
25- version = '0.1.9' ,
48+ version = version ,
2649 packages = ['py_sourcemap' ],
2750 description = 'A tiny source-map-mappings bindings for python using PyO3' ,
2851 long_description = long_description ,
0 commit comments