Skip to content

Commit

Permalink
Install pre-commit automatically (#763)
Browse files Browse the repository at this point in the history
* install pre-commit automatically

* add to build reqs
  • Loading branch information
blink1073 committed Mar 28, 2022
1 parent 7239666 commit c9476ab
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
7 changes: 5 additions & 2 deletions CONTRIBUTING.rst
Expand Up @@ -27,7 +27,7 @@ steps::
pip install --upgrade setuptools pip
git clone https://github.com/jupyter/jupyter_server
cd jupyter_server
pip install -e .
pip install -e ".[test]"

If you are using a system-wide Python installation and you only want to install the server for you,
you can add ``--user`` to the install commands.
Expand All @@ -44,7 +44,10 @@ Code Styling
need to worry too much about your code style.
As long as your code is valid,
the pre-commit hook should take care of how it should look.
To install `pre-commit`, run the following::
`pre-commit` and its associated hooks will automatically be installed when
you run ``pip install -e ".[test]"``

To install ``pre-commit`` manually, run the following::

pip install pre-commit
pre-commit install
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
@@ -1,5 +1,5 @@
[build-system]
requires = ["jupyter_packaging~=0.9"]
requires = ["jupyter_packaging~=0.9", "pre-commit"]
build-backend = "jupyter_packaging.build_api"

[tool.jupyter-packaging.builder]
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Expand Up @@ -57,6 +57,7 @@ test =
pytest-tornasync
pytest-console-scripts
ipykernel
pre-commit
# NOTE: we cannot auto install examples/simple here because of:
# https://github.com/pypa/pip/issues/6658

Expand Down
16 changes: 15 additions & 1 deletion setup.py
@@ -1,10 +1,24 @@
import subprocess
import sys

from setuptools import setup

try:
from jupyter_packaging import npm_builder, wrap_installers

ensured_targets = ["jupyter_server/static/style/bootstrap.min.css"]
cmdclass = wrap_installers(pre_develop=npm_builder(), ensured_targets=ensured_targets)

def post_develop(*args, **kwargs):
npm_builder()
try:
subprocess.run([sys.executable, "-m", "pre_commit", "install"])
subprocess.run(
[sys.executable, "-m", "pre_commit", "install", "--hook-type", "pre-push"]
)
except Exception:
pass

cmdclass = wrap_installers(post_develop=post_develop, ensured_targets=ensured_targets)
except ImportError:
cmdclass = {}

Expand Down

0 comments on commit c9476ab

Please sign in to comment.