Skip to content

Migrate fully to pyproject.toml (rebased #1324) #1586

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
51 changes: 27 additions & 24 deletions .github/workflows/lint-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
with:
python-version: ${{ env.LINTING_PYTHON_VERSION }}
cache: 'pip'
cache-dependency-path: 'setup.py'
cache-dependency-path: 'pyproject.toml'
- name: Install with type-checking tools, stubs & minimal test libraries
run: pip install .[typing,testing_minimal]
- name: Run mypy
Expand All @@ -48,11 +48,11 @@ jobs:
with:
python-version: ${{ env.LINTING_PYTHON_VERSION }}
cache: 'pip'
cache-dependency-path: 'setup.py'
cache-dependency-path: 'pyproject.toml'
- name: Install with linting tools
run: pip install .[linting]
- name: Run ruff
run: ruff zulipterminal/ tests/ setup.py `tools/python_tools.py`
run: ruff zulipterminal/ tests/ `tools/python_tools.py`

isort:
runs-on: ubuntu-latest
Expand All @@ -65,7 +65,7 @@ jobs:
with:
python-version: ${{ env.LINTING_PYTHON_VERSION }}
cache: 'pip'
cache-dependency-path: 'setup.py'
cache-dependency-path: 'pyproject.toml'
- name: Install with linting tools & minimal test libraries
# NOTE: Install pytest so that isort recognizes it as a known library
run: pip install .[linting,minimal_testing]
Expand All @@ -83,11 +83,11 @@ jobs:
with:
python-version: ${{ env.LINTING_PYTHON_VERSION }}
cache: 'pip'
cache-dependency-path: 'setup.py'
cache-dependency-path: 'pyproject.toml'
- name: Install with linting tools
run: pip install .[linting]
- name: Check code & tests meet black standards
run: black --check zulipterminal/ tests/ setup.py `tools/python_tools.py`
run: black --check zulipterminal/ tests/ `tools/python_tools.py`

spellcheck:
runs-on: ubuntu-latest
Expand All @@ -100,11 +100,12 @@ jobs:
with:
python-version: ${{ env.LINTING_PYTHON_VERSION }}
cache: 'pip'
cache-dependency-path: 'setup.py'
- name: Install with linting tools
run: pip install .[linting]
- name: Check spelling
run: ./tools/run-spellcheck
cache-dependency-path: 'pyproject.toml'
- name: Lint
run: |
make
. zt_venv/bin/activate
./tools/run-spellcheck

hotkeys:
runs-on: ubuntu-latest
Expand All @@ -117,11 +118,12 @@ jobs:
with:
python-version: ${{ env.LINTING_PYTHON_VERSION }}
cache: 'pip'
cache-dependency-path: 'setup.py'
- name: Minimal install
run: pip install .
- name: Run lint-hotkeys
run: ./tools/lint-hotkeys
cache-dependency-path: 'pyproject.toml'
- name: Lint
run: |
make
. zt_venv/bin/activate
./tools/lint-hotkeys

docstrings:
runs-on: ubuntu-latest
Expand All @@ -134,11 +136,12 @@ jobs:
with:
python-version: ${{ env.LINTING_PYTHON_VERSION }}
cache: 'pip'
cache-dependency-path: 'setup.py'
- name: Minimal install
run: pip install .
- name: Run lint-docstring
run: ./tools/lint-docstring
cache-dependency-path: 'pyproject.toml'
- name: Lint
run: |
make
. zt_venv/bin/activate
./tools/lint-docstring

gitlint:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -181,7 +184,7 @@ jobs:
with:
python-version: 3.7
cache: 'pip'
cache-dependency-path: 'setup.py'
cache-dependency-path: 'pyproject.toml'
- name: Output Python version
run: python --version
- name: Upgrade pip
Expand Down Expand Up @@ -220,7 +223,7 @@ jobs:
with:
python-version: ${{ env.LINTING_PYTHON_VERSION }}
cache: 'pip'
cache-dependency-path: 'setup.py'
cache-dependency-path: 'pyproject.toml'
- name: Run check-branch
if: github.event_name == 'pull_request'
# Note that we install at each step since dependencies may change
Expand Down Expand Up @@ -258,7 +261,7 @@ jobs:
with:
python-version: ${{ matrix.env.PYTHON }}
cache: 'pip'
cache-dependency-path: 'setup.py'
cache-dependency-path: 'pyproject.toml'
- name: Output Python version
run: python --version
- name: Upgrade pip
Expand Down
2 changes: 1 addition & 1 deletion .gitlint
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ line-length=76

[area-formatting]
# This is a ZT custom rule; these are excluded from the lower-case area rule
exclusions=WIP, DEBUG, README, CHANGELOG, LICENSE, FAQ
exclusions=WIP, DEBUG, README, CHANGELOG, LICENSE, FAQ, MANIFEST

[ignore-by-title]
# Ignore all rules for commits of which the title matches below
Expand Down
11 changes: 11 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
prune tools
prune tests
prune .github
exclude .git*
exclude makefile
exclude Pipfile
exclude .codecov.yml
exclude .mailmap
# May bring these back, but aiming to reproduce previous minimal sdist first
prune docs
prune docker
3 changes: 3 additions & 0 deletions docs/making-a-new-release.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
**NOTE: This has been out of date for some time, particularly now since we have
transitioned completely from setup.py to pyproject.toml.**

The thrilling process of making a new release has (sadly) been automated. Worry not, we still have a few things to check and a few steps to follow!
To install the required dependencies for making a release, in the venv activated zulip-terminal directory, run:
```
Expand Down
6 changes: 3 additions & 3 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ZT_VENV?=zt_venv
VENV_ACTIVATE=. $(ZT_VENV)/bin/activate
PYTHON=${ZT_VENV}/bin/$(BASEPYTHON)

SOURCES = zulipterminal tests setup.py
SOURCES = zulipterminal tests

# Default target at top
install-devel: venv
Expand Down Expand Up @@ -42,8 +42,8 @@ force-fix: venv
# Short name for file dependency
venv: $(ZT_VENV)/bin/activate

# If setup.py is updated or activate script doesn't exist, update virtual env
$(ZT_VENV)/bin/activate: setup.py
# If pyproject.toml is updated or activate script doesn't exist, update virtual env
$(ZT_VENV)/bin/activate: pyproject.toml
@echo "=== Installing development environment ==="
test -d $(ZT_VENV) || $(BASEPYTHON) -m venv $(ZT_VENV)
$(PYTHON) -m pip install wheel && $(PYTHON) -m pip install -U pip && $(PYTHON) -m pip install -e .[dev] && touch $(ZT_VENV)/bin/activate
100 changes: 98 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,101 @@
[build-system]
# setuptools added pyproject.toml support in v61.0.0
requires = ["setuptools >= 61", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "zulip-term"
description = "Zulip's official terminal client"
authors = [
{name="Zulip Open Source Project", email="[email protected]"}
]
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: End Users/Desktop",
"Topic :: Communications :: Chat",
"License :: OSI Approved :: Apache Software License",
"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 :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]
keywords = []
requires-python = ">=3.7, <3.12"
dynamic = ["version", "readme"]
dependencies = [
"urwid~=2.1.2",
"zulip>=0.8.2,<0.9.0", # Next release, 0.9.0, requires Python 3.9
"urwid_readline>=0.15.1",
"beautifulsoup4>=4.13.4",
"lxml==4.9.4",
"pygments>=2.17.2,<2.18.0", # 2.18.0 will drop support for Python 3.7
"typing_extensions~=4.5.0",
"python-dateutil>=2.8.2",
"pytz>=2025", # Can use native support from Python 3.9 onwards
"tzlocal>=5.0,<5.1", # 5.1 will drop support for Python 3.7
"pyperclip>=1.9.0",
]

[project.optional-dependencies]
dev = ["zulip-term[testing,linting,typing,dev-helper,gitlint]"]
testing = ["zulip-term[testing-minimal, testing-plugins]"]
testing-minimal = [
"pytest>=7.4.0,<8.0.0", # 8.0.0 drops support for Python 3.7
"pytest-mock>=3.10.0,<3.12.0", # 3.12.0 drops support for Python 3.7
]
testing-plugins = [
"pytest-cov>=4.0.0,<5.0.0", # 5.0.0 drops support for Python 3.7 (6.0.0 drops 3.8)
]
linting = [
"isort~=5.11.0,<5.12.0", # 5.12.0 drops support for Python 3.7, 6.0.0 drops 3.8
"black==23.3.0", # Later versions drop support for Python 3.7
"ruff==0.0.267",
"codespell[toml]==2.2.5,<2.2.6", # 2.2.6 drops support for Python 3.7
"typos>=1.32.0",
]
gitlint = [
"gitlint~=0.18.0",
]
typing = [
"lxml-stubs",
"mypy~=1.8.0", # >=1.9.0 requires Python 3.8+, >=1.15.0 requires 3.9+
"types-beautifulsoup4",
"types-pygments",
"types-python-dateutil",
"types-tzlocal",
"types-pytz",
"types-requests",
"types-setuptools",
]
dev-helper = [
"pudb==2022.1.1",
"snakeviz>=2.1.1",
]

[project.scripts]
zulip-term = "zulipterminal.cli.run:main"
zulip-term-check-symbols = "zulipterminal.scripts.render_symbols:main"

[project.urls]
Changelog = "https://github.com/zulip/zulip-terminal/blob/main/CHANGELOG.md"
FAQs = "https://github.com/zulip/zulip-terminal/blob/main/docs/FAQ.md"
Issues = "https://github.com/zulip/zulip-terminal/issues"
"Hot Keys" = "https://github.com/zulip/zulip-terminal/blob/main/docs/hotkeys.md"
# NOTE: This Was home-page, ie. url
Repository = "https://github.com/zulip/zulip-terminal"

[tool.setuptools.packages.find]
include=["zulipterminal"]

[tool.setuptools.dynamic]
version = {attr = "zulipterminal.version.ZT_VERSION"}
# FIXME ? This doesn't support losing the top title line, like with setup.py
readme = {file = ["README.md"], content-type = "text/markdown"}

[tool.black]
# Default line-length, but use explicit value here since used for isort & ruff
line-length = 88
Expand Down Expand Up @@ -191,8 +289,6 @@ select = [
"YTT", # Year TwentyTwenty (flake8-2020), sys.version checks
]
[tool.ruff.per-file-ignores]
# ANN: We don't consider this worth typing
"setup.py" = ["ANN"]
# ANN: These test files are not yet typed
"tests/model/test_model.py" = ["ANN"]
"tests/ui/test_ui_tools.py" = ["ANN"]
Expand Down
Loading
Loading