Skip to content
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
5 changes: 3 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ jobs:
uses: actions/setup-python@v6
with:
python-version: '3.9'
- name: Set up uv
uses: astral-sh/setup-uv@v7
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip3 install .
uv pip install --system -e .
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
Expand Down
69 changes: 28 additions & 41 deletions .github/workflows/lint-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ jobs:
- uses: actions/setup-python@v6
with:
python-version: ${{ env.LINTING_PYTHON_VERSION }}
cache: 'pip'
cache-dependency-path: 'setup.py'
- uses: astral-sh/setup-uv@v7
- name: Install with type-checking tools, stubs & minimal test libraries
run: pip install .[typing,testing_minimal]
run: uv pip install --system -e ".[typing,testing-minimal]"
- name: Run mypy
run: ./tools/run-mypy

Expand All @@ -47,12 +46,11 @@ jobs:
- uses: actions/setup-python@v6
with:
python-version: ${{ env.LINTING_PYTHON_VERSION }}
cache: 'pip'
cache-dependency-path: 'setup.py'
- uses: astral-sh/setup-uv@v7
- name: Install with linting tools
run: pip install .[linting]
run: uv pip install --system -e ".[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 @@ -64,11 +62,10 @@ jobs:
- uses: actions/setup-python@v6
with:
python-version: ${{ env.LINTING_PYTHON_VERSION }}
cache: 'pip'
cache-dependency-path: 'setup.py'
- uses: astral-sh/setup-uv@v7
- 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]
run: uv pip install --system -e ".[linting,testing-minimal]"
- name: Run isort
run: ./tools/run-isort-check

Expand All @@ -82,12 +79,11 @@ jobs:
- uses: actions/setup-python@v6
with:
python-version: ${{ env.LINTING_PYTHON_VERSION }}
cache: 'pip'
cache-dependency-path: 'setup.py'
- uses: astral-sh/setup-uv@v7
- name: Install with linting tools
run: pip install .[linting]
run: uv pip install --system -e ".[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 @@ -99,10 +95,9 @@ jobs:
- uses: actions/setup-python@v6
with:
python-version: ${{ env.LINTING_PYTHON_VERSION }}
cache: 'pip'
cache-dependency-path: 'setup.py'
- uses: astral-sh/setup-uv@v7
- name: Install with linting tools
run: pip install .[linting]
run: uv pip install --system -e ".[linting]"
- name: Check spelling
run: ./tools/run-spellcheck

Expand All @@ -116,10 +111,9 @@ jobs:
- uses: actions/setup-python@v6
with:
python-version: ${{ env.LINTING_PYTHON_VERSION }}
cache: 'pip'
cache-dependency-path: 'setup.py'
- uses: astral-sh/setup-uv@v7
- name: Minimal install
run: pip install .
run: uv pip install --system -e .
- name: Run lint-hotkeys
run: ./tools/lint-hotkeys

Expand All @@ -133,10 +127,9 @@ jobs:
- uses: actions/setup-python@v6
with:
python-version: ${{ env.LINTING_PYTHON_VERSION }}
cache: 'pip'
cache-dependency-path: 'setup.py'
- uses: astral-sh/setup-uv@v7
- name: Minimal install
run: pip install .
run: uv pip install --system -e .
- name: Run lint-docstring
run: ./tools/lint-docstring

Expand All @@ -158,11 +151,11 @@ jobs:
if: github.event_name == 'pull_request'
with:
python-version: ${{ env.LINTING_PYTHON_VERSION }}
cache: 'pip'
cache-dependency-path: 'setup.py'
- uses: astral-sh/setup-uv@v7
if: github.event_name == 'pull_request'
- name: Install with gitlint
if: github.event_name == 'pull_request'
run: pip install .[gitlint]
run: uv pip install --system -e ".[gitlint]"
- name: Run gitlint
if: github.event_name == 'pull_request'
run:
Expand All @@ -180,16 +173,13 @@ jobs:
uses: actions/setup-python@v6
with:
python-version: 3.7
cache: 'pip'
cache-dependency-path: 'setup.py'
- uses: astral-sh/setup-uv@v7
- name: Output Python version
run: python --version
- name: Upgrade pip
run: python -m pip install --upgrade pip
- name: Ensure regular package installs from checkout
run: pip install .
run: uv pip install --system -e .
- name: Install test dependencies
run: pip install .[testing]
run: uv pip install --system -e ".[testing]"
- name: Run tests with pytest
run: pytest --cov-report=xml
- name: Upload coverage to Codecov
Expand Down Expand Up @@ -221,14 +211,14 @@ jobs:
if: github.event_name == 'pull_request'
with:
python-version: ${{ env.LINTING_PYTHON_VERSION }}
cache: 'pip'
cache-dependency-path: 'setup.py'
- uses: astral-sh/setup-uv@v7
if: github.event_name == 'pull_request'
- name: Run check-branch
if: github.event_name == 'pull_request'
# Note that we install at each step since dependencies may change
run:
git fetch https://github.com/zulip/zulip-terminal main;
CHECK="pip install .[linting,testing,typing] && ./tools/lint-all && pytest" ./tools/check-branch FETCH_HEAD
CHECK="uv pip install --system -e '.[linting,testing,typing]' && ./tools/lint-all && pytest" ./tools/check-branch FETCH_HEAD

pytest-on-other-platforms:
needs: isolated-commits
Expand Down Expand Up @@ -259,22 +249,19 @@ jobs:
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.env.PYTHON }}
cache: 'pip'
cache-dependency-path: 'setup.py'
- uses: astral-sh/setup-uv@v7
- name: Output Python version
run: python --version
- name: Upgrade pip
run: python -m pip install --upgrade pip
- name: Ensure libxml-related libraries are installed (some pypy versions don't have wheels)
if: startsWith(matrix.env.PYTHON, 'pypy-')
run: sudo apt install libxml2-dev libxslt1-dev
- name: Ensure regular package installs from checkout
run: pip install .
run: uv pip install --system -e .
- name: Check we detect the python environment correctly
run: python -c "from zulipterminal.platform_code import detected_python_short; import os; e, d = os.environ['PYTHON'], detected_python_short(); assert d == e, f'{d} != {e}'"
- name: Check we detect the platform correctly
run: python -c "from zulipterminal.platform_code import detected_platform; import os; e, d = os.environ['EXPECT'], detected_platform(); assert d == e, f'{d} != {e}'"
- name: Install test dependencies
run: pip install .[testing]
run: uv pip install --system -e ".[testing]"
- name: Run tests with pytest
run: pytest --cov-report=
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
cov_html/*
.coverage
.mypy_cache
Pipfile.lock
zulipterminal.egg-info
dist/*
build/*
zulip_term.egg-info
*.log
zt_venv/*
zulip-terminal-venv/*
.venv/
zt_venv/
zulip-terminal-venv/

## Config files
zuliprc
Expand Down
10 changes: 0 additions & 10 deletions Pipfile

This file was deleted.

104 changes: 28 additions & 76 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ or using an automated option such as [pipx](https://pypi.python.org/pypi/pipx)
* **Stable releases** - These are available on PyPI as the package
[zulip-term](https://pypi.python.org/pypi/zulip-term)

To install, run a command like: `pip3 install zulip-term`
To install, run a command like: `uv tool install zulip-term`

* **Latest (git) versions** - The latest development version can be installed
from the git repository `main` branch

To install, run a command like:
`pip3 install git+https://github.com/zulip/zulip-terminal.git@main`
`uv tool install git+https://github.com/zulip/zulip-terminal.git@main`

We also provide some sample Dockerfiles to build docker images in
[docker/](https://github.com/zulip/zulip-terminal/tree/main/docker).
Expand All @@ -103,9 +103,10 @@ We also provide some sample Dockerfiles to build docker images in

With the python 3.6+ required for running, the following should work on most
systems:
1. `python3 -m venv zt_venv`
(creates a virtual environment named `zt_venv` in the current directory)
2. `source zt_venv/bin/activate`

1. `uv venv .venv`
(creates a virtual environment named `.venv` in the current directory)
2. `source .venv/bin/activate`
(activates the virtual environment; this assumes a bash-like shell)
3. Run one of the install commands above.

Expand Down Expand Up @@ -438,85 +439,43 @@ section of Zulip's Git guide.

### Setting up a development environment

Various options are available; we are exploring the benefits of each and would
appreciate feedback on which you use or feel works best.

Note that the tools used in each case are typically the same, but are called in
different ways.

The following commands should be run in the repository directory, created by a
process similar to that in the previous section.

#### Pipenv

1. Install pipenv
(see the [recommended installation notes](https://pipenv.readthedocs.io/en/latest/installation);
pipenv can be installed in a virtual environment, if you wish)
```
$ pip3 install --user pipenv
```
2. Initialize the pipenv virtual environment for zulip-term (using the default
python 3; use eg. `--python 3.6` to be more specific)
1. Install uv
(see [uv installation docs](https://docs.astral.sh/uv/getting-started/installation/))
2. Set up the local environment with all development tools

```
$ pipenv --three
```

3. Install zulip-term, with the development requirements

```
$ pipenv install --dev
$ pipenv run pip3 install -e '.[dev]'
```

4. Connect the gitlint commit-message hook

```
$ pipenv run gitlint install-hook
```

#### Pip

1. Manually create & activate a virtual environment; any method should work,
such as that used in the above simple installation

1. `python3 -m venv zt_venv` (creates a venv named `zt_venv` in the current directory)
2. `source zt_venv/bin/activate` (activates the venv; this assumes a bash-like shell)

2. Install zulip-term, with the development requirements
```
$ pip3 install -e '.[dev]'
$ uv sync --extra dev
```

3. Connect the gitlint commit-message hook
```
$ gitlint install-hook
$ uv run gitlint install-hook
```

#### make/pip

This is the newest and simplest approach, if you have `make` installed:
If you have `make` installed, this provides a short wrapper around uv:

1. `make` (sets up an installed virtual environment in `zt_venv` in the current directory)
2. `source zt_venv/bin/activate` (activates the venv; this assumes a bash-like shell)
3. `gitlint install-hook` (connect the gitlint commit-message hook)
1. `make` (creates/synchronizes `.venv` with the development dependencies)
2. `source .venv/bin/activate` (activates the venv; this assumes a bash-like shell)
3. `uv run gitlint install-hook` (connect the gitlint commit-message hook)

### Development tasks

Once you have a development environment set up, you might find the following useful, depending upon your type of environment:
Once you have a development environment set up, you might find the following useful:

| Task | Make & Pip | Pipenv |
|-|-|-|
| Run normally | `zulip-term` | `pipenv run zulip-term` |
| Run in debug mode | `zulip-term -d` | `pipenv run zulip-term -d` |
| Run with profiling | `zulip-term --profile` | `pipenv run zulip-term --profile` |
| Run all linters | `./tools/lint-all` | `pipenv run ./tools/lint-all` |
| Run all tests | `pytest` | `pipenv run pytest` |
| Build test coverage report | `pytest --cov-report html:cov_html --cov=./` | `pipenv run pytest --cov-report html:cov_html --cov=./` |
| Task | command |
| -------------------------- | --------------------------------------------------- |
| Run normally | `uv run zulip-term` |
| Run in debug mode | `uv run zulip-term -d` |
| Run with profiling | `uv run zulip-term --profile` |
| Run all linters | `uv run ./tools/lint-all` |
| Run all tests | `uv run pytest` |
| Build test coverage report | `uv run pytest --cov-report html:cov_html --cov=./` |

If using make with pip, running `make` will ensure the development environment
is up to date with the specified dependencies, useful after fetching from git
and rebasing.
If using make, running `make` will ensure the development environment is up to
date with the specified dependencies, useful after fetching from git and rebasing.

### Editing the source

Expand Down Expand Up @@ -708,7 +667,7 @@ The tool can check specific commits manually, eg. `gitlint` for the latest
commit, or `gitlint --commits main..` for commits leading from `main`.
However, we highly recommend running `gitlint install-hook` to install the
`gitlint` commit-message hook
(or `pipenv run gitlint install-hook` with pipenv setups).
(or `uv run gitlint install-hook` with uv setups).

If the hook is installed as described above, then after completing the text for
a commit, it will be checked by gitlint against the style we have set up, and
Expand Down Expand Up @@ -804,12 +763,5 @@ find in `./debug.log`.
This likely means that you have installed both normal and development versions
of zulip-terminal.

To ensure you run the development version:
* If using pipenv, call `pipenv run zulip-term` from the cloned/downloaded
`zulip-terminal` directory;
To ensure you run the development version, use `uv run zulip-term`.

* If using pip (pip3), ensure you have activated the correct virtual
environment (venv); depending on how your shell is configured, the name of
the venv may appear in the command prompt.
Note that not including the `-e` in the pip3 command will also cause this
problem.
Loading
Loading