Files
CLI-Anything/cli-hub/setup.py
T
Rāna(Bass Ver.) b04a4ebe26 Fix: Python 3.11 compatibility issue with f-string backslash in cli_hub/preview.py (#377)
* Fix Python 3.11 compatibility issue in cli_hub/preview.py

* fix(cli-hub): remove backslash from f-string expression for pre-3.12

The prior change swapped the inner double quotes for single quotes, but
pre-3.12 (before PEP 701) prohibits a backslash ANYWHERE in the
expression part of an f-string — the escaped quote left a backslash in
place, so preview.py still raised SyntaxError on Python 3.10/3.11.

Hoist the fallback markup into an empty_message variable so the f-string
expression contains no backslash. This also restores the original
double-quoted HTML (class="artifact-file"); the rendered output is now
byte-for-byte identical to origin/main.

* chore(cli-hub): bump version to 0.4.1

Ships the pre-3.12 f-string fix in preview.py to PyPI. Without a version
bump publish-cli-hub.yml sees 0.4.0 already on PyPI and skips, so users on
Python 3.10/3.11 would keep installing the broken release.

---------

Co-authored-by: yuhao <itsyuhao@icloud.com>
2026-07-09 20:03:58 +08:00

105 lines
3.5 KiB
Python

"""cli-hub — package manager for CLI-Anything harnesses."""
import shutil
from pathlib import Path
from setuptools import setup, find_packages
from setuptools.command.build_py import build_py as _build_py
from setuptools.command.sdist import sdist as _sdist
HERE = Path(__file__).resolve().parent
# Matrix skill content lives at the repo root (outside this package dir).
# It is vendored into cli_hub/_matrix_data/ at build time so wheels and
# sdists ship real matrix content for users without a repo checkout.
# Editable installs (`pip install -e`) do not need the vendored copy: the
# runtime lookup chain in cli_hub/matrix_skill.py finds the checkout first.
MATRIX_CONTENT_SOURCE = HERE.parent / "cli-hub-matrix"
MATRIX_DATA_DIR = HERE / "cli_hub" / "_matrix_data"
def _sync_matrix_data():
"""Vendor cli-hub-matrix/ into cli_hub/_matrix_data/ (build artifact).
No-op when building from an sdist (the data is already vendored) or when
the repo content is unavailable (runtime falls back to the published URL
or a stub).
"""
if not MATRIX_CONTENT_SOURCE.is_dir():
return
if MATRIX_DATA_DIR.exists():
shutil.rmtree(MATRIX_DATA_DIR)
shutil.copytree(
MATRIX_CONTENT_SOURCE,
MATRIX_DATA_DIR,
ignore=shutil.ignore_patterns("__pycache__", "*.pyc", "*.pyo"),
)
class build_py(_build_py):
def run(self):
_sync_matrix_data()
super().run()
class sdist(_sdist):
def run(self):
_sync_matrix_data()
super().run()
setup(
name="cli-anything-hub",
version="0.4.1",
description="Package manager for CLI-Anything — browse, install, and manage 40+ agent-native CLI interfaces for GUI applications",
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
author="HKUDS",
author_email="hkuds@connect.hku.hk",
url="https://github.com/HKUDS/CLI-Anything",
project_urls={
"Homepage": "https://clianything.cc",
"Repository": "https://github.com/HKUDS/CLI-Anything",
"Bug Tracker": "https://github.com/HKUDS/CLI-Anything/issues",
"Catalog": "https://reeceyang.sgp1.cdn.digitaloceanspaces.com/SKILL.md",
},
license="MIT",
packages=find_packages(exclude=["tests", "tests.*"]),
cmdclass={"build_py": build_py, "sdist": sdist},
include_package_data=True,
package_data={
"cli_hub": [
"_matrix_data/*/SKILL.md",
"_matrix_data/*/references/*",
"_matrix_data/*/scripts/*",
],
},
python_requires=">=3.10",
install_requires=[
"click>=8.0",
"requests>=2.28",
],
entry_points={
"console_scripts": [
"cli-hub=cli_hub.cli:main",
],
},
classifiers=[
"Development Status :: 4 - Beta",
"Environment :: Console",
"Intended Audience :: Developers",
"Intended Audience :: System Administrators",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Software Development :: Libraries :: Application Frameworks",
"Topic :: System :: Installation/Setup",
"Topic :: Utilities",
],
keywords="cli, agent, gui, automation, package-manager, cli-anything",
)