Skip to content

feat: migrate setup.py to pyproject (with hatch backend), update package metadata and update publish workflow #273

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ jobs:
working-directory: docs
run: make man

- name: Install pep517
- name: Install build
run:
python -m pip install pep517 --user
python -m pip install build --user

- name: Build a binary wheel and a source tarball
run: >-
python -m pep517.build
--source
--binary
--out-dir dist/
python -m build
--sdist
--wheel
--outdir dist/
.

- name: Attest generated files
Expand All @@ -61,6 +61,7 @@ jobs:

pypi-publish:
runs-on: ubuntu-latest
if: github.repository == 'tldr-pages/tldr-python-client'
needs: ['release-build']

environment:
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# tldr-python-client

[![PyPI Release](https://img.shields.io/pypi/v/tldr.svg)](https://pypi.python.org/pypi/tldr)
[![Build](https://github.com/tldr-pages/tldr-python-client/workflows/Test/badge.svg?branch=main)](https://github.com/tldr-pages/tldr-python-client/actions?query=branch%3Amain)
[![Test](https://github.com/tldr-pages/tldr-python-client/actions/workflows/test.yml/badge.svg)](https://github.com/tldr-pages/tldr-python-client/actions/workflows/test.yml)
[![CodeQL](https://github.com/tldr-pages/tldr-python-client/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/tldr-pages/tldr-python-client/actions/workflows/github-code-scanning/codeql)
[![Snap Release](https://snapcraft.io/tldr/badge.svg)](https://snapcraft.io/tldr)

Python command-line client for [tldr pages](https://github.com/tldr-pages/tldr).
Expand Down
90 changes: 87 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,88 @@
[build-system]
# Minimum requirements for the build system to execute.
requires = ["setuptools", "wheel"] # PEP 508 specifications.
build-backend = "setuptools.build_meta"
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "tldr"
dynamic = ["version"]
description = "Python command line client for tldr."
readme = "README.md"
license = "MIT"
requires-python = "~=3.9"
authors = [
{ name = "Felix Yan and tldr-pages contributors" },
]
keywords = [
"tldr",
"tldr-pages",
"cheatsheets",
"man",
"manpages",
"documentation"
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Intended Audience :: End Users/Desktop",
"Intended Audience :: Developers",
"Intended Audience :: Education",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Operating System :: Android",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX",
"Operating System :: POSIX :: BSD :: FreeBSD",
"Operating System :: POSIX :: BSD :: NetBSD",
"Operating System :: POSIX :: BSD :: OpenBSD",
"Operating System :: POSIX :: Linux",
"Operating System :: POSIX :: SunOS/Solaris",
"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",
"Topic :: Documentation",
"Topic :: Software Development :: Documentation",
"Topic :: System",
"Topic :: Utilities",
]
dependencies = [
"colorama; sys_platform=='win32'",
"shtab>=1.3.10",
"termcolor",
]
[project.optional-dependencies]
cli = [
"pytest",
"pytest-runner",
"flake8",
"sphinx",
"sphinx-argparse"
]

[project.scripts]
tldr = "tldr:cli"

[project.urls]
Homepage = "https://tldr.sh"
Source = "https://github.com/tldr-pages/tldr-python-client"
Issues = "https://github.com/tldr-pages/tldr-python-client/issues"
Changelog = "https://github.com/tldr-pages/tldr-python-client/blob/main/CHANGELOG.md"
Funding = "https://liberapay.com/tldr-pages"

[tool.hatch.version]
path = "tldr.py"
attr = "__version__"

[tool.hatch.build.targets.wheel.shared-data]
"docs/man" = "share/man/man1"

[tool.hatch.build.targets.sdist]
include = [
"tldr.py",
"README.md",
"LICENSE.md",
"CHANGELOG.md",
"docs/man/tldr.1",
]
60 changes: 0 additions & 60 deletions setup.py

This file was deleted.

4 changes: 2 additions & 2 deletions tldr.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
from zipfile import ZipFile
from datetime import datetime
from io import BytesIO
import ssl
from typing import List, Optional, Tuple, Union
from urllib.parse import quote
from urllib.request import urlopen, Request
from urllib.error import HTTPError, URLError
from termcolor import colored
import ssl
import shtab
import shutil

__version__ = "3.3.0"
__client_specification__ = "2.2"
__client_specification__ = "2.3"

REQUEST_HEADERS = {'User-Agent': 'tldr-python-client'}
PAGES_SOURCE_LOCATION = os.environ.get(
Expand Down