-
Notifications
You must be signed in to change notification settings - Fork 8
/
setup.py
90 lines (79 loc) · 2.99 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
89
90
from pathlib import Path
from subprocess import PIPE, Popen
from setuptools import setup
from setuptools_rust import Binding, RustExtension
PKG_ROOT = Path(__file__).parent
SETUP_REQUIRES = ["setuptools-rust", "wheel", "setuptools"]
SHORT_DESCRIPTION = "JsonLogic implemented with a Rust backend"
URL = "https://www.github.com/bestowinc/json-logic-rs"
AUTHOR = "Matthew Planchard"
EMAIL = "msplanchard@gmail.com"
def generate_lockfile():
if (PKG_ROOT / "Cargo.lock").exists():
return
print("Generating Cargo lockfile")
proc = Popen(("cargo", "generate-lockfile"), stdout=PIPE, stderr=PIPE)
_out, err = tuple(map(bytes.decode, proc.communicate()))
if proc.returncode != 0:
raise RuntimeError(f"Could not generate Cargo lockfile: {err}")
return
def get_version():
generate_lockfile()
proc = Popen(("cargo", "pkgid"), stdout=PIPE, stderr=PIPE)
out, err = tuple(map(bytes.decode, proc.communicate()))
if proc.returncode != 0:
raise RuntimeError(f"Could not get Cargo package info: {err}")
version = out.split("@")[-1]
return version.strip()
with open(PKG_ROOT / "README.md") as readme_f:
LONG_DESCRIPTION = readme_f.read()
VERSION = get_version()
setup(
name="jsonlogic-rs",
author=AUTHOR,
version=VERSION,
author_email=EMAIL,
maintainer_email=EMAIL,
url=URL,
description=SHORT_DESCRIPTION,
long_description=LONG_DESCRIPTION,
long_description_content_type="text/markdown",
keywords=["json", "jsonlogic", "s-expressions", "rust"],
classifiers=[
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers for all
# available setup classifiers
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"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 :: Rust",
# 'Programming Language :: Python :: Implementation :: PyPy',
],
rust_extensions=[
RustExtension(
# Python package name before the dot, name of C extension to
# stick inside of it after the dot.
"jsonlogic_rs.jsonlogic",
"Cargo.toml",
features=["python"],
binding=Binding.RustCPython,
)
],
packages=["jsonlogic_rs"],
package_dir={"": "py"},
include_package_data=True,
setup_requires=SETUP_REQUIRES,
# rust extensions are not zip safe, just like C-extensions.
zip_safe=False,
)