-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
60 lines (47 loc) · 1.71 KB
/
setup.py
File metadata and controls
60 lines (47 loc) · 1.71 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
import datetime
import re
from pathlib import Path
from setuptools import find_namespace_packages, setup
BASE_DIR = Path(__file__).resolve().parent
DIST_NAME = "cells-json"
MODULE_ROOT = "cells"
VERSION_FILE = BASE_DIR / MODULE_ROOT / "json" / "version.py"
README_FILE = BASE_DIR / "README.md"
def build_version() -> str:
"""Generate a timestamp-based version for fallback."""
return datetime.datetime.now().strftime("%Y.%m.%d.%H%M%S")
def read_version(version_file: Path) -> str:
"""Read __VERSION__ from the version module without importing the package."""
content = version_file.read_text(encoding="utf-8")
match = re.search(r'^__VERSION__\s*=\s*["\']([^"\']+)["\']', content, re.MULTILINE)
if match is None:
raise ValueError(f"Unable to find __VERSION__ in {version_file}")
return match.group(1)
def read_readme(readme_file: Path) -> str:
"""Read the project README for package metadata."""
return readme_file.read_text(encoding="utf-8")
try:
version = read_version(VERSION_FILE)
except Exception:
version = build_version()
try:
long_description = read_readme(README_FILE)
except Exception:
long_description = "Orjson-first JSON serialization utilities for the cells namespace."
setup(
name=DIST_NAME,
version=version,
license="MPL-2.0",
author="HarmonSir",
author_email="git@pylab.me",
description="Orjson-first JSON serialization utilities for the cells namespace",
long_description=long_description,
long_description_content_type="text/markdown",
packages=find_namespace_packages(include=[f"{MODULE_ROOT}.*"]),
include_package_data=True,
zip_safe=False,
python_requires=">=3.9",
install_requires=[
"orjson"
],
)