forked from PetterS/quickjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
executable file
·59 lines (48 loc) · 2.01 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
56
57
58
59
import glob
import sys
from typing import List
from setuptools import setup, Extension
CONFIG_VERSION = '2020-11-08'
extra_link_args: List[str] = []
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: []
# Make sure that pthreads is linked statically, otherwise we run into problems
# on computers where it is not installed.
extra_link_args = ["-static"]
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', f'"{CONFIG_VERSION}"'), ('CONFIG_BIGNUM', None)],
# HACK.
# See https://github.com/pypa/packaging-problems/issues/84.
sources=get_c_sources(include_headers=("sdist" in sys.argv)),
extra_compile_args=["-Werror=incompatible-pointer-types"],
extra_link_args=extra_link_args)
long_description = """
Python wrapper around https://bellard.org/quickjs/ .
Translates types like `str`, `float`, `bool`, `list`, `dict` and combinations
thereof to and from Javascript.
QuickJS is currently thread-hostile, so this wrapper makes sure that all calls
to the same JS runtime comes from the same thead.
"""
setup(author="Petter Strandmark",
author_email="[email protected]",
name='quickjs',
url='https://github.com/PetterS/quickjs',
version='1.19.0',
description='Wrapping the quickjs C library.',
long_description=long_description,
packages=["quickjs"],
ext_modules=[_quickjs])