forked from PetterS/quickjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
executable file
·55 lines (46 loc) · 1.8 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import glob
import sys
from setuptools import setup, Extension
CONFIG_VERSION = '2019-08-10'
extra_link_args = []
if sys.platform == "win32":
# To build for Windows:
# 1. Install MingW-W64-builds from https://mingw-w64.org/doku.php/download
# It is important to change the default to 64-bit when installing if a
# 64-bit Python is installed in windows.
# 2. Put the bin/ folder inside x86_64-8.1.0-posix-seh-rt_v6-rev0 in your
# system PATH when compiling.
# 3. The code below will moneky-patch distutils to work.
import distutils.cygwinccompiler
distutils.cygwinccompiler.get_msvcr = lambda: []
# Escaping works differently.
CONFIG_VERSION = f'\\"{CONFIG_VERSION}\\"'
# Make sure that pthreads is linked statically, otherwise we run into problems
# on computers where it is not installed.
extra_link_args = ["-Wl,-Bstatic", "-lpthread"]
else:
CONFIG_VERSION = f'"{CONFIG_VERSION}"'
def get_c_sources(include_headers=False):
sources = ['module.c'] + glob.glob("third-party/*.c")
if include_headers:
sources += glob.glob("third-party/*.h")
return sources
_quickjs = Extension(
'_quickjs',
define_macros=[('CONFIG_VERSION', CONFIG_VERSION)],
# HACK.
# See https://github.com/pypa/packaging-problems/issues/84.
sources=get_c_sources(include_headers=("sdist" in sys.argv)),
extra_link_args=extra_link_args)
long_description = """
Thin Python wrapper around https://bellard.org/quickjs/ .
"""
setup(author="Petter Strandmark",
author_email="[email protected]",
name='quickjs',
url='https://github.com/PetterS/quickjs',
version='1.6.0',
description='Wrapping the quickjs C library.',
long_description=long_description,
packages=["quickjs"],
ext_modules=[_quickjs])