Skip to content

Commit 225e786

Browse files
zry656565Brooooooklyn
authored andcommitted
chore: read host enviroment
1 parent c92f30f commit 225e786

File tree

2 files changed

+31
-8
lines changed

2 files changed

+31
-8
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.1.9
2+
current_version = 0.1.10
33
commit = True
44
tag = True
55

setup.py

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,42 @@
1+
import platform
2+
import os
3+
import sys
4+
5+
from urllib.request import urlopen
6+
17
from setuptools import setup
28
from 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

919
class 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

2346
setup(
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

Comments
 (0)