diff --git a/.github/workflows/lint-and-test.yml b/.github/workflows/lint-and-test.yml index d7132a4ff0..65a6ea7ce5 100644 --- a/.github/workflows/lint-and-test.yml +++ b/.github/workflows/lint-and-test.yml @@ -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 @@ -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 @@ -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] @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/.gitlint b/.gitlint index 9fec2d8393..5166150291 100644 --- a/.gitlint +++ b/.gitlint @@ -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 diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000000..a67e088cc4 --- /dev/null +++ b/MANIFEST.in @@ -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 diff --git a/docs/making-a-new-release.md b/docs/making-a-new-release.md index 763fd60bd2..6eb2f660e8 100644 --- a/docs/making-a-new-release.md +++ b/docs/making-a-new-release.md @@ -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: ``` diff --git a/makefile b/makefile index 13119cbe59..296a694a1d 100644 --- a/makefile +++ b/makefile @@ -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 @@ -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 diff --git a/pyproject.toml b/pyproject.toml index f01695735c..75626fe2f4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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="zulip-devel@googlegroups.com"} +] +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 @@ -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"] diff --git a/setup.py b/setup.py deleted file mode 100644 index 16a702930c..0000000000 --- a/setup.py +++ /dev/null @@ -1,120 +0,0 @@ -import codecs -import os - -from setuptools import find_packages, setup - -from zulipterminal.version import ZT_VERSION - - -def long_description(): - if not (os.path.isfile("README.md") and os.access("README.md", os.R_OK)): - return "" - - with codecs.open("README.md", encoding="utf8") as f: - source = f.read() - - # Skip first line (assumed to have title) to reduce duplication - return "\n".join(source.splitlines()[1:]) - - -testing_minimal_deps = [ - "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_plugin_deps = [ - "pytest-cov>=4.0.0,<5.0.0", # 5.0.0 drops support for Python 3.7 (6.0.0 drops 3.8) -] - -testing_deps = testing_minimal_deps + testing_plugin_deps - -linting_deps = [ - "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_deps = [ - "gitlint~=0.18.0", -] - -typing_deps = [ - "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", -] - -helper_deps = [ - "pudb==2022.1.1", - "snakeviz>=2.1.1", -] - -setup( - name="zulip-term", - version=ZT_VERSION, - description="Zulip's official terminal client", - long_description=long_description(), - long_description_content_type="text/markdown", - url="https://github.com/zulip/zulip-terminal", - author="Zulip Open Source Project", - author_email="zulip-devel@googlegroups.com", - 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", - ], - 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", - }, - python_requires=">=3.7, <3.12", - keywords="", - packages=find_packages(exclude=["tests", "tests.*"]), - zip_safe=True, - entry_points={ - "console_scripts": [ - "zulip-term = zulipterminal.cli.run:main", - "zulip-term-check-symbols = zulipterminal.scripts.render_symbols:main", - ], - }, - extras_require={ - "dev": testing_deps + linting_deps + typing_deps + helper_deps + gitlint_deps, - "testing": testing_deps, - "testing-minimal": testing_minimal_deps, # extra must be hyphenated - "linting": linting_deps, - "gitlint": gitlint_deps, - "typing": typing_deps, - }, - tests_require=testing_deps, - install_requires=[ - "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", - ], -) diff --git a/tools/lint-all b/tools/lint-all index b9a38462bb..fd8da13229 100755 --- a/tools/lint-all +++ b/tools/lint-all @@ -9,7 +9,6 @@ from python_tools import lintable_tools_files python_sources = [ "zulipterminal/", "tests/", - "setup.py", ] python_sources += lintable_tools_files diff --git a/tools/run-isort-check b/tools/run-isort-check index f75a6fa18b..9fbe301204 100755 --- a/tools/run-isort-check +++ b/tools/run-isort-check @@ -5,7 +5,7 @@ import sys cmds = ["isort"] -files = ["zulipterminal", "tests", "tools", "setup.py"] +files = ["zulipterminal", "tests", "tools"] result = subprocess.call(cmds + ["--check-only", "--diff"] + files) diff --git a/tools/run-spellcheck b/tools/run-spellcheck index 2b42de31d9..ecd430418e 100755 --- a/tools/run-spellcheck +++ b/tools/run-spellcheck @@ -20,7 +20,6 @@ SOURCE = [ "zulipterminal", "tests", "tools", - "setup.py", "docs", "docker", "README.md",