1
+ import platform
2
+ import os
3
+ import sys
4
+
5
+ from urllib .request import urlopen
6
+
1
7
from setuptools import setup
2
8
from setuptools .command .install import install
3
9
4
10
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 ()
7
17
8
18
9
19
class PostInstallCommand (install ):
10
20
"""Post-installation for installation mode."""
11
21
12
22
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 )
17
40
install .run (self )
18
41
19
42
@@ -22,7 +45,7 @@ def run(self):
22
45
23
46
setup (
24
47
name = 'py-sourcemap' ,
25
- version = '0.1.9' ,
48
+ version = version ,
26
49
packages = ['py_sourcemap' ],
27
50
description = 'A tiny source-map-mappings bindings for python using PyO3' ,
28
51
long_description = long_description ,
0 commit comments