Skip to content

Commit

Permalink
HDX-9928 document running pyright in ckan container & ruff executables
Browse files Browse the repository at this point in the history
  • Loading branch information
ccataalin committed Aug 5, 2024
1 parent 0a5ec23 commit 5360c87
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ckanext-hdx_theme/docs/code_quality/linter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ Installing Ruff Linter

Since we utilize CKAN within a Docker container, you'll need Ruff installed locally on your development machine.

The PyCharm Ruff plugin doesn't know how to use the Ruff installation from the CKAN container. It needs a Ruff executable on the Docker host (the real machine). It also cannot execute Ruff from a Python virtual environment as there doesn't seem to be a way to activate a specific virtual env before running Ruff.

Please note that since Ruff is written in the Rust programming language, you don't necessarily need to install it as a Python package, although you can. Please see below the various options.

Ruff is available as ``ruff`` on PyPI:

::
Expand All @@ -36,6 +40,15 @@ For **macOS Homebrew** and **Linuxbrew** users, Ruff is also available as ``ruff

brew install ruff

Direct downloads of Ruff executables:

- `Linux x86_64 <https://github.com/astral-sh/ruff/releases/download/0.5.6/ruff-x86_64-unknown-linux-gnu.tar.gz>`_
- `Linux ARM64 <https://github.com/astral-sh/ruff/releases/download/0.5.6/ruff-aarch64-unknown-linux-gnu.tar.gz>`_
- `macOS x86_64 <https://github.com/astral-sh/ruff/releases/download/0.5.6/ruff-x86_64-apple-darwin.tar.gz>`_
- `macOS ARM64 <https://github.com/astral-sh/ruff/releases/download/0.5.6/ruff-aarch64-apple-darwin.tar.gz>`_
- `Windows x86_64 <https://github.com/astral-sh/ruff/releases/download/0.5.6/ruff-x86_64-pc-windows-msvc.zip>`_


Enabling Ruff Extension in PyCharm
----------------------------------

Expand Down
27 changes: 27 additions & 0 deletions ckanext-hdx_theme/docs/code_quality/type_checker.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,30 @@ Manually Running Type Checking Inspections

1. Go to `Code` > `Inspect Code`.
2. Choose the scope (e.g., `Current File` or `Whole Project`).

Running Pyright in the CKAN Container
-----------------------------------------------------------
To run Pyright manually within the CKAN Docker container, follow these steps:

1. Install Node.js and npm on the CKAN Docker container:

::

# Enter the CKAN Docker container
docker-compose exec -it ckan /bin/bash

# Install Node
curl -sL https://deb.nodesource.com/setup_22.x | bash -
apt-get install -y nodejs

2. Install Pyright globally using ``npm``:

::

npm install -g pyright

3. To run Pyright within the CKAN Docker container, execute the following command:

::

docker-compose exec -T ckan pyright /srv/ckan/<path>

0 comments on commit 5360c87

Please sign in to comment.