# Locally execute pre-commit linting locally

**URL:** <https://discourse.slicer.org/t/locally-execute-pre-commit-linting-locally/22837>\
**Category:** Development\
**Created:** [April 5, 2022, 2:35pm UTC](https://discourse.slicer.org/t/locally-execute-pre-commit-linting-locally/22837 "2022-04-05T14:35:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [April 5, 2022, 2:35pm UTC](https://discourse.slicer.org/t/locally-execute-pre-commit-linting-locally/22837/1 "2022-04-05T14:35:34Z")

</div>

Following pull request [PR-6262](https://github.com/Slicer/Slicer/pull/6262), we integrated a linting workflow to our continuous integration.

Waiting we update the `Utilities/SetupForDevelopment.sh` to automatically install the requirements, the linting could be performed locally following these steps:

```bash
pip install pre-commit

```

```bash
cd Slicer
pre-commit run --all-files

```

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [April 5, 2022, 2:56pm UTC](https://discourse.slicer.org/t/locally-execute-pre-commit-linting-locally/22837/2 "2022-04-05T14:56:07Z")

</div>

And to install the tool within the Slicer environment:

```bash
./Slicer-Release/python-install/bin/PythonSlicer -m pip install pre_commit

```

and to perform the check:

```bash
cd Slicer
../Slicer-Release/python-install/bin/PythonSlicer -m pre_commit run --all-files

```

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [April 6, 2022, 3:54pm UTC](https://discourse.slicer.org/t/locally-execute-pre-commit-linting-locally/22837/3 "2022-04-06T15:54:24Z")

</div>

Thank you @jcfr, this is very useful. I’ve tried to execute this on Windows and I got two errors:

1. The script complained that `DLLs` folder is missing.

- In Slicer install tree: `c:\\Users\\andra\\AppData\\Local\\NA-MIC\\Slicer 4.13.0-2022-03-19\\lib\\Python\DLLs`
- In Slicer build tree: `C:\\D\\S4R\\python-install\\DLLs`

I created an empty folder at the not found location and restarted the script and it seemed to solve this issue.

1. `pythonw.exe` not found

I copied `PythonSlicer.exe` to `pythonw.exe` and it seemed to solve this issue.

@jcfr do you know what may require this folder and file? Should we add them to the build tree or add a module to the Sandbox (DebuggingTools or DeveloperToolsForExtensions) extension that can create these folders, install the pre-commit package, and run the checks on a single click?
