-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup.py
88 lines (75 loc) · 2.98 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import glob
import sys
from typing import List
from setuptools import setup, Extension
CONFIG_VERSION = open("upstream-quickjs/VERSION").read().strip()
extra_link_args: List[str] = []
if sys.platform == "win32":
# To build for Windows:
# 1. Install MingW-W64-builds from https://www.mingw-w64.org/downloads/
# 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.
# python setup.py build -c mingw32 bdist_wheel
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",
"upstream-quickjs/cutils.c",
"upstream-quickjs/libbf.c",
"upstream-quickjs/libregexp.c",
"upstream-quickjs/libunicode.c",
"upstream-quickjs/quickjs.c",
# "upstream-quickjs/quickjs-libc.c",
# "upstream-quickjs/qjsc.c",
]
if include_headers:
sources += [
"upstream-quickjs/cutils.h",
"upstream-quickjs/libbf.h",
"upstream-quickjs/libregexp-opcode.h",
"upstream-quickjs/libregexp.h",
"upstream-quickjs/libunicode-table.h",
"upstream-quickjs/libunicode.h",
"upstream-quickjs/list.h",
"upstream-quickjs/quickjs-atom.h",
"upstream-quickjs/quickjs-opcode.h",
"upstream-quickjs/quickjs.h",
"module.h",
# "upstream-quickjs/quickjs-libc.h",
"upstream-quickjs/VERSION",
]
return sources
_pyquickjs = Extension(
'_pyquickjs',
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 = f"""
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.
Version:{CONFIG_VERSION}
"""
setup(author="Petter Strandmark",
author_email="[email protected]",
maintainer="hjdhnx",
maintainer_email="[email protected]",
name='pyquickjs',
url='https://github.com/hjdhnx/pyquickjs',
version='1.24.4.4',
description='Wrapping the quickjs C library.',
long_description=long_description,
packages=["pyquickjs"],
ext_modules=[_pyquickjs])