Skip to content

Commit 42afba6

Browse files
authored
ENH: Add dynamic python package metadata (#7)
1 parent a1dda29 commit 42afba6

File tree

1 file changed

+67
-3
lines changed

1 file changed

+67
-3
lines changed

setup.py

+67-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,75 @@
1+
from pathlib import Path
12
from setuptools import setup
23
from setuptools_rust import Binding, RustExtension
4+
from subprocess import Popen, PIPE
5+
6+
PKG_ROOT = Path(__file__).parent
7+
SETUP_REQUIRES = ["setuptools-rust", "wheel", "setuptools"]
8+
SHORT_DESCRIPTION = "JsonLogic implemented with a Rust backend"
9+
URL = "https://www.github.com/bestowinc/json-logic-rs"
10+
AUTHOR = "Matthew Planchard"
11+
12+
13+
14+
def get_version():
15+
proc = Popen(("cargo", "pkgid"), stdout=PIPE, stderr=PIPE)
16+
out, _err = tuple(map(bytes.decode, proc.communicate()))
17+
if proc.returncode != 0:
18+
raise RuntimeError("Could not get Cargo package info")
19+
version = out.split(":")[-1]
20+
return version.strip()
21+
22+
23+
with open(PKG_ROOT / "README.md") as readme_f:
24+
LONG_DESCRIPTION = readme_f.read()
25+
26+
VERSION = get_version()
327

4-
setup_requires = ["setuptools-rust", "wheel", "setuptools"]
528

629
setup(
730
name="jsonlogic-rs",
8-
version="1.0",
31+
author=AUTHOR,
32+
version=VERSION,
33+
author_email=EMAIL,
34+
maintainer_email=EMAIL,
35+
url=URL,
36+
description=SHORT_DESCRIPTION,
37+
long_description=LONG_DESCRIPTION,
38+
long_description_content_type="text/markdown",
39+
keywords=["json", "jsonlogic", "s-expressions", "rust"],
40+
classifiers=[
41+
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers for all
42+
# available setup classifiers
43+
# "Development Status :: 1 - Planning",
44+
# 'Development Status :: 2 - Pre-Alpha',
45+
"Development Status :: 3 - Alpha",
46+
# "Development Status :: 4 - Beta",
47+
# 'Development Status :: 5 - Production/Stable',
48+
# 'Development Status :: 6 - Mature',
49+
# 'Framework :: AsyncIO',
50+
# 'Framework :: Flask',
51+
# 'Framework :: Sphinx',
52+
# 'Environment :: Web Environment',
53+
"Intended Audience :: Developers",
54+
# 'Intended Audience :: End Users/Desktop',
55+
# 'Intended Audience :: Science/Research',
56+
# 'Intended Audience :: System Administrators',
57+
# 'License :: Other/Proprietary License',
58+
# 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
59+
"License :: OSI Approved :: MIT License",
60+
# "License :: OSI Approved :: Apache Software License",
61+
"Natural Language :: English",
62+
"Operating System :: POSIX :: Linux",
63+
"Operating System :: MacOS :: MacOS X",
64+
"Operating System :: Microsoft :: Windows",
65+
"Programming Language :: Python",
66+
"Programming Language :: Python :: 3 :: Only",
67+
"Programming Language :: Python :: 3.6",
68+
"Programming Language :: Python :: 3.7",
69+
"Programming Language :: Python :: 3.8",
70+
"Programming Language :: Rust",
71+
# 'Programming Language :: Python :: Implementation :: PyPy',
72+
],
973
rust_extensions=[
1074
RustExtension(
1175
# Python package name before the dot, name of C extension to
@@ -19,7 +83,7 @@
1983
packages=["jsonlogic_rs"],
2084
package_dir={"": "py"},
2185
include_package_data=True,
22-
setup_requires=setup_requires,
86+
setup_requires=SETUP_REQUIRES,
2387
# rust extensions are not zip safe, just like C-extensions.
2488
zip_safe=False,
2589
)

0 commit comments

Comments
 (0)