Skip to content

Commit eeec7bf

Browse files
committed
setup/pyproject/makefile/tools/lint-and-test: Setup with pyproject.toml.
This transfers details from setup.py to equivalent ones in pyproject.toml, and similarly removes or substitutes references to these files. The previous setup.py file is removed. Note: This introduces 3 other changes from the previous state: * Building packages no longer removes the top title line shown on GitHub * The `zip_safe` property is detected automatically by `setuptools` * The types-setuptools package is included for type-checking This also adds a note to the making-a-new-release doc, since while it was previously out of date, setup.py will now be absent completely.
1 parent 713faeb commit eeec7bf

File tree

8 files changed

+117
-140
lines changed

8 files changed

+117
-140
lines changed

.github/workflows/lint-and-test.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
with:
3232
python-version: ${{ env.LINTING_PYTHON_VERSION }}
3333
cache: 'pip'
34-
cache-dependency-path: 'setup.py'
34+
cache-dependency-path: 'pyproject.toml'
3535
- name: Install with type-checking tools, stubs & minimal test libraries
3636
run: pip install .[typing,testing_minimal]
3737
- name: Run mypy
@@ -48,11 +48,11 @@ jobs:
4848
with:
4949
python-version: ${{ env.LINTING_PYTHON_VERSION }}
5050
cache: 'pip'
51-
cache-dependency-path: 'setup.py'
51+
cache-dependency-path: 'pyproject.toml'
5252
- name: Install with linting tools
5353
run: pip install .[linting]
5454
- name: Run ruff
55-
run: ruff zulipterminal/ tests/ setup.py `tools/python_tools.py`
55+
run: ruff zulipterminal/ tests/ `tools/python_tools.py`
5656

5757
isort:
5858
runs-on: ubuntu-latest
@@ -65,7 +65,7 @@ jobs:
6565
with:
6666
python-version: ${{ env.LINTING_PYTHON_VERSION }}
6767
cache: 'pip'
68-
cache-dependency-path: 'setup.py'
68+
cache-dependency-path: 'pyproject.toml'
6969
- name: Install with linting tools & minimal test libraries
7070
# NOTE: Install pytest so that isort recognizes it as a known library
7171
run: pip install .[linting,minimal_testing]
@@ -83,11 +83,11 @@ jobs:
8383
with:
8484
python-version: ${{ env.LINTING_PYTHON_VERSION }}
8585
cache: 'pip'
86-
cache-dependency-path: 'setup.py'
86+
cache-dependency-path: 'pyproject.toml'
8787
- name: Install with linting tools
8888
run: pip install .[linting]
8989
- name: Check code & tests meet black standards
90-
run: black --check zulipterminal/ tests/ setup.py `tools/python_tools.py`
90+
run: black --check zulipterminal/ tests/ `tools/python_tools.py`
9191

9292
spellcheck:
9393
runs-on: ubuntu-latest
@@ -100,7 +100,7 @@ jobs:
100100
with:
101101
python-version: ${{ env.LINTING_PYTHON_VERSION }}
102102
cache: 'pip'
103-
cache-dependency-path: 'setup.py'
103+
cache-dependency-path: 'pyproject.toml'
104104
- name: Install with linting tools
105105
run: pip install .[linting]
106106
- name: Check spelling
@@ -117,7 +117,7 @@ jobs:
117117
with:
118118
python-version: ${{ env.LINTING_PYTHON_VERSION }}
119119
cache: 'pip'
120-
cache-dependency-path: 'setup.py'
120+
cache-dependency-path: 'pyproject.toml'
121121
- name: Minimal install
122122
run: pip install .
123123
- name: Run lint-hotkeys
@@ -134,7 +134,7 @@ jobs:
134134
with:
135135
python-version: ${{ env.LINTING_PYTHON_VERSION }}
136136
cache: 'pip'
137-
cache-dependency-path: 'setup.py'
137+
cache-dependency-path: 'pyproject.toml'
138138
- name: Minimal install
139139
run: pip install .
140140
- name: Run lint-docstring
@@ -181,7 +181,7 @@ jobs:
181181
with:
182182
python-version: 3.7
183183
cache: 'pip'
184-
cache-dependency-path: 'setup.py'
184+
cache-dependency-path: 'pyproject.toml'
185185
- name: Output Python version
186186
run: python --version
187187
- name: Upgrade pip
@@ -220,7 +220,7 @@ jobs:
220220
with:
221221
python-version: ${{ env.LINTING_PYTHON_VERSION }}
222222
cache: 'pip'
223-
cache-dependency-path: 'setup.py'
223+
cache-dependency-path: 'pyproject.toml'
224224
- name: Run check-branch
225225
if: github.event_name == 'pull_request'
226226
# Note that we install at each step since dependencies may change
@@ -258,7 +258,7 @@ jobs:
258258
with:
259259
python-version: ${{ matrix.env.PYTHON }}
260260
cache: 'pip'
261-
cache-dependency-path: 'setup.py'
261+
cache-dependency-path: 'pyproject.toml'
262262
- name: Output Python version
263263
run: python --version
264264
- name: Upgrade pip

docs/making-a-new-release.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
**NOTE: This has been out of date for some time, particularly now since we have
2+
transitioned completely from setup.py to pyproject.toml.**
3+
14
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!
25
To install the required dependencies for making a release, in the venv activated zulip-terminal directory, run:
36
```

makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ZT_VENV?=zt_venv
99
VENV_ACTIVATE=. $(ZT_VENV)/bin/activate
1010
PYTHON=${ZT_VENV}/bin/$(BASEPYTHON)
1111

12-
SOURCES = zulipterminal tests setup.py
12+
SOURCES = zulipterminal tests
1313

1414
# Default target at top
1515
install-devel: venv
@@ -42,8 +42,8 @@ force-fix: venv
4242
# Short name for file dependency
4343
venv: $(ZT_VENV)/bin/activate
4444

45-
# If setup.py is updated or activate script doesn't exist, update virtual env
46-
$(ZT_VENV)/bin/activate: setup.py
45+
# If pyproject.toml is updated or activate script doesn't exist, update virtual env
46+
$(ZT_VENV)/bin/activate: pyproject.toml
4747
@echo "=== Installing development environment ==="
4848
test -d $(ZT_VENV) || $(BASEPYTHON) -m venv $(ZT_VENV)
4949
$(PYTHON) -m pip install wheel && $(PYTHON) -m pip install -U pip && $(PYTHON) -m pip install -e .[dev] && touch $(ZT_VENV)/bin/activate

pyproject.toml

Lines changed: 98 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,101 @@
1+
[build-system]
2+
# setuptools added pyproject.toml support in v61.0.0
3+
requires = ["setuptools >= 61", "wheel"]
4+
build-backend = "setuptools.build_meta"
5+
6+
[project]
7+
name = "zulip-term"
8+
description = "Zulip's official terminal client"
9+
authors = [
10+
{name="Zulip Open Source Project", email="zulip-devel@googlegroups.com"}
11+
]
12+
classifiers = [
13+
"Development Status :: 4 - Beta",
14+
"Intended Audience :: End Users/Desktop",
15+
"Topic :: Communications :: Chat",
16+
"License :: OSI Approved :: Apache Software License",
17+
"Programming Language :: Python :: 3 :: Only",
18+
"Programming Language :: Python :: 3.7",
19+
"Programming Language :: Python :: 3.8",
20+
"Programming Language :: Python :: 3.9",
21+
"Programming Language :: Python :: 3.10",
22+
"Programming Language :: Python :: 3.11",
23+
"Programming Language :: Python :: Implementation :: CPython",
24+
"Programming Language :: Python :: Implementation :: PyPy",
25+
]
26+
keywords = []
27+
requires-python = ">=3.7, <3.12"
28+
dynamic = ["version", "readme"]
29+
dependencies = [
30+
"urwid~=2.1.2",
31+
"zulip>=0.8.2,<0.9.0", # Next release, 0.9.0, requires Python 3.9
32+
"urwid_readline>=0.15.1",
33+
"beautifulsoup4>=4.13.4",
34+
"lxml==4.9.4",
35+
"pygments>=2.17.2,<2.18.0", # 2.18.0 will drop support for Python 3.7
36+
"typing_extensions~=4.5.0",
37+
"python-dateutil>=2.8.2",
38+
"pytz>=2025", # Can use native support from Python 3.9 onwards
39+
"tzlocal>=5.0,<5.1", # 5.1 will drop support for Python 3.7
40+
"pyperclip>=1.9.0",
41+
]
42+
43+
[project.optional-dependencies]
44+
dev = ["zulip-term[testing,linting,typing,dev-helper,gitlint]"]
45+
testing = ["zulip-term[testing-minimal, testing-plugins]"]
46+
testing-minimal = [
47+
"pytest>=7.4.0,<8.0.0", # 8.0.0 drops support for Python 3.7
48+
"pytest-mock>=3.10.0,<3.12.0", # 3.12.0 drops support for Python 3.7
49+
]
50+
testing-plugins = [
51+
"pytest-cov>=4.0.0,<5.0.0", # 5.0.0 drops support for Python 3.7 (6.0.0 drops 3.8)
52+
]
53+
linting = [
54+
"isort~=5.11.0,<5.12.0", # 5.12.0 drops support for Python 3.7, 6.0.0 drops 3.8
55+
"black==23.3.0", # Later versions drop support for Python 3.7
56+
"ruff==0.0.267",
57+
"codespell[toml]==2.2.5,<2.2.6", # 2.2.6 drops support for Python 3.7
58+
"typos>=1.32.0",
59+
]
60+
gitlint = [
61+
"gitlint~=0.18.0",
62+
]
63+
typing = [
64+
"lxml-stubs",
65+
"mypy~=1.8.0", # >=1.9.0 requires Python 3.8+, >=1.15.0 requires 3.9+
66+
"types-beautifulsoup4",
67+
"types-pygments",
68+
"types-python-dateutil",
69+
"types-tzlocal",
70+
"types-pytz",
71+
"types-requests",
72+
"types-setuptools",
73+
]
74+
dev-helper = [
75+
"pudb==2022.1.1",
76+
"snakeviz>=2.1.1",
77+
]
78+
79+
[project.scripts]
80+
zulip-term = "zulipterminal.cli.run:main"
81+
zulip-term-check-symbols = "zulipterminal.scripts.render_symbols:main"
82+
83+
[project.urls]
84+
Changelog = "https://github.com/zulip/zulip-terminal/blob/main/CHANGELOG.md"
85+
FAQs = "https://github.com/zulip/zulip-terminal/blob/main/docs/FAQ.md"
86+
Issues = "https://github.com/zulip/zulip-terminal/issues"
87+
"Hot Keys" = "https://github.com/zulip/zulip-terminal/blob/main/docs/hotkeys.md"
88+
# NOTE: This Was home-page, ie. url
89+
Repository = "https://github.com/zulip/zulip-terminal"
90+
91+
[tool.setuptools.packages.find]
92+
include=["zulipterminal"]
93+
94+
[tool.setuptools.dynamic]
95+
version = {attr = "zulipterminal.version.ZT_VERSION"}
96+
# FIXME ? This doesn't support losing the top title line, like with setup.py
97+
readme = {file = ["README.md"], content-type = "text/markdown"}
98+
199
[tool.black]
2100
# Default line-length, but use explicit value here since used for isort & ruff
3101
line-length = 88
@@ -191,8 +289,6 @@ select = [
191289
"YTT", # Year TwentyTwenty (flake8-2020), sys.version checks
192290
]
193291
[tool.ruff.per-file-ignores]
194-
# ANN: We don't consider this worth typing
195-
"setup.py" = ["ANN"]
196292
# ANN: These test files are not yet typed
197293
"tests/model/test_model.py" = ["ANN"]
198294
"tests/ui/test_ui_tools.py" = ["ANN"]

setup.py

Lines changed: 0 additions & 120 deletions
This file was deleted.

tools/lint-all

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ from python_tools import lintable_tools_files
99
python_sources = [
1010
"zulipterminal/",
1111
"tests/",
12-
"setup.py",
1312
]
1413

1514
python_sources += lintable_tools_files

tools/run-isort-check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import sys
55

66

77
cmds = ["isort"]
8-
files = ["zulipterminal", "tests", "tools", "setup.py"]
8+
files = ["zulipterminal", "tests", "tools"]
99

1010
result = subprocess.call(cmds + ["--check-only", "--diff"] + files)
1111

tools/run-spellcheck

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ SOURCE = [
2020
"zulipterminal",
2121
"tests",
2222
"tools",
23-
"setup.py",
2423
"docs",
2524
"docker",
2625
"README.md",

0 commit comments

Comments
 (0)