-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.py
More file actions
executable file
·98 lines (92 loc) · 2.84 KB
/
Copy pathsetup.py
File metadata and controls
executable file
·98 lines (92 loc) · 2.84 KB
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
89
90
91
92
93
94
95
96
97
98
# encoding: utf-8
# SEE: https://packaging.python.org/en/latest/distributing.html#id23
# SEE: https://pythonhosted.org/setuptools/setuptools.html
# --
# Create source distribution: python setup.py sdist
# Upload using twine: twine upload dist/*
# Upload using setup.py: setup.py sdist bdist_wheel upload
from setuptools import setup
import sys
import os
import tempfile
import subprocess
# We make sure `build_libparsing` is within the path
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "bin"))
sys.path.insert(
0,
os.path.join(
os.path.dirname(os.path.abspath(__file__)), "src", "py", "libparsing"
),
)
from _buildext import FFI_BUILDER
VERSION = "0.9.3"
if os.path.exists("src/h/parsing.h"):
LONG_DESCRIPTION = "\n".join(
_[2:].strip()
for _ in open("src/h/parsing.h")
.read()
.split("[START:INTRO]", 1)[1]
.split("[END:INTRO]")[0]
.split("\n")
)
else:
LONG_DESCRIPTION = ""
# If pandoc is installed, we translate the documentation to RST. This is really
# only useful for publishing, not for building.
if LONG_DESCRIPTION:
try:
subprocess.run(["which", "pandoc"], check=True, capture_output=True)
p = tempfile.mktemp()
with open(p, "w") as f:
f.write(LONG_DESCRIPTION)
result = subprocess.run(
["pandoc", "-f", "markdown", "-t", "rst", p], capture_output=True, text=True
)
LONG_DESCRIPTION = result.stdout
os.unlink(p)
except (subprocess.CalledProcessError, FileNotFoundError):
pass
setup(
name="libparsing",
version=VERSION,
url="https://github.com/sebastien/libparsing",
# download_url = "",
author="Sébastien Pierre",
author_email="sebastien.pierre@gmail.com",
license="BSD",
description="Python wrapper for libparsing, a PEG-based parsing library written in C",
keywords="parsing PEG grammar libparsing",
long_description=LONG_DESCRIPTION,
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Topic :: Software Development :: Build Tools",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
],
packages=["libparsing"],
package_dir={"libparsing": "src/py/libparsing"},
package_data={
"libparsing": [
"_libparsing.c",
"_libparsing.h",
"_libparsing.ffi",
"_buildext.py",
]
},
# Build the CFFI extension as a native binary module when building wheels.
ext_modules=[FFI_BUILDER.distutils_extension()],
zip_safe=False,
install_requires=["cffi>=1.9.1"],
)
# EOF