]> git.madduck.net Git - etc/vim.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Add optional uvloop import (#2258)
authorCooper Lees <me@cooperlees.com>
Wed, 26 May 2021 12:52:09 +0000 (05:52 -0700)
committerGitHub <noreply@github.com>
Wed, 26 May 2021 12:52:09 +0000 (05:52 -0700)
* Add optional uvloop import

- If we find `uvloop` in the env for black, blackd or black-primer lets try and use it
- Add a uvloop extra install

Fixes #2257

Test:
- Add ci job to install black[uvloop] and run a primer run with uvloop
  - Only with latest python (3.9)
  - Will be handy to compare runtimes as a very unoffical benchmark

* Remove tox install

* Add to CHANGES/news

.github/workflows/uvloop_test.yml [new file with mode: 0644]
CHANGES.md
setup.py
src/black/__init__.py
src/black_primer/cli.py
src/blackd/__init__.py

diff --git a/.github/workflows/uvloop_test.yml b/.github/workflows/uvloop_test.yml
new file mode 100644 (file)
index 0000000..5d23ec6
--- /dev/null
@@ -0,0 +1,45 @@
+name: test uvloop
+
+on:
+  push:
+    paths-ignore:
+      - "docs/**"
+      - "*.md"
+
+  pull_request:
+    paths-ignore:
+      - "docs/**"
+      - "*.md"
+
+jobs:
+  build:
+    # We want to run on external PRs, but not on our own internal PRs as they'll be run
+    # by the push to the branch. Without this if check, checks are duplicated since
+    # internal PRs match both the push and pull_request events.
+    if:
+      github.event_name == 'push' || github.event.pull_request.head.repo.full_name !=
+      github.repository
+
+    runs-on: ${{ matrix.os }}
+    strategy:
+      fail-fast: false
+      matrix:
+        os: [ubuntu-latest, macOS-latest]
+
+    steps:
+      - uses: actions/checkout@v2
+
+      - name: Set up Python ${{ matrix.python-version }}
+        uses: actions/setup-python@v2
+
+      - name: Install latest pip
+        run: |
+          python -m pip install --upgrade pip
+
+      - name: Test uvloop Extra Install
+        run: |
+          python -m pip install -e ".[uvloop]"
+
+      - name: Primer uvloop run
+        run: |
+          black-primer
index 1b7a54a516d188a189d22d141861097b6e2a4476..de326e4ee7b4747b4bc1116b574740ef92ca7887 100644 (file)
@@ -9,6 +9,7 @@
 - Respect `.gitignore` files in all levels, not only `root/.gitignore` file (apply
   `.gitignore` rules like `git` does) (#2225)
 - Restored compatibility with Click 8.0 on Python 3.6 when LANG=C used (#2227)
 - Respect `.gitignore` files in all levels, not only `root/.gitignore` file (apply
   `.gitignore` rules like `git` does) (#2225)
 - Restored compatibility with Click 8.0 on Python 3.6 when LANG=C used (#2227)
+- Add extra uvloop install + import support if in python env (#2258)
 
 ### _Blackd_
 
 
 ### _Blackd_
 
index 2b5f71f56ddca1b84640ff21ba5bfeea266fb8f1..5549ae353423853023441343b82568e348d825ef 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -86,6 +86,7 @@ setup(
         "d": ["aiohttp>=3.6.0", "aiohttp-cors>=0.4.0"],
         "colorama": ["colorama>=0.4.3"],
         "python2": ["typed-ast>=1.4.2"],
         "d": ["aiohttp>=3.6.0", "aiohttp-cors>=0.4.0"],
         "colorama": ["colorama>=0.4.3"],
         "python2": ["typed-ast>=1.4.2"],
+        "uvloop": ["uvloop>=0.15.2"],
     },
     test_suite="tests.test_black",
     classifiers=[
     },
     test_suite="tests.test_black",
     classifiers=[
index f46b866c1bd0c28e516122a3952d53fad522bb81..90aad220a9cade11cde10c46ee1688e1f797ece9 100644 (file)
@@ -54,6 +54,13 @@ from blib2to3.pgen2 import token
 
 from _black_version import version as __version__
 
 
 from _black_version import version as __version__
 
+# If our environment has uvloop installed lets use it
+try:
+    import uvloop
+
+    uvloop.install()
+except ImportError:
+    pass
 
 # types
 FileContent = str
 
 # types
 FileContent = str
index 00b54d6511f0818642ecae60d05c18a2ac418caa..f0997049d2159c1bddfcfaaaba4a6809ea8e618e 100644 (file)
@@ -13,6 +13,14 @@ import click
 
 from black_primer import lib
 
 
 from black_primer import lib
 
+# If our environment has uvloop installed lets use it
+try:
+    import uvloop
+
+    uvloop.install()
+except ImportError:
+    pass
+
 
 DEFAULT_CONFIG = Path(__file__).parent / "primer.json"
 _timestamp = datetime.now().strftime("%Y%m%d%H%M%S")
 
 DEFAULT_CONFIG = Path(__file__).parent / "primer.json"
 _timestamp = datetime.now().strftime("%Y%m%d%H%M%S")
index fc684730e4b8a4dde8eb8cfabbe444999da235b0..10b616894dabbaa566691f42bcfa5017c8dd6eef 100644 (file)
@@ -22,6 +22,14 @@ except ImportError as ie:
 import black
 import click
 
 import black
 import click
 
+# If our environment has uvloop installed lets use it
+try:
+    import uvloop
+
+    uvloop.install()
+except ImportError:
+    pass
+
 from _black_version import version as __version__
 
 # This is used internally by tests to shut down the server prematurely
 from _black_version import version as __version__
 
 # This is used internally by tests to shut down the server prematurely