Last active
October 7, 2025 15:58
-
-
Save Vizonex/51c31e0a69283e7af91c946781b465a6 to your computer and use it in GitHub Desktop.
Aiohttp Developer Tools For windows.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Compiler script written for windows because of the following problems. | |
| # | |
| # 1. `make` is not well supported on windows | |
| # | |
| # 2. llhttp uses a `rm` command that doesn't | |
| # work on windows so we need to make a script | |
| # for dealing with that that. | |
| # | |
| # 3. Some users prefer to using virtual enviornments so finding a rational way for using them would be an | |
| # ideal solution | |
| # | |
| # Installation | |
| # If your working with aiohttp put this powershell script in the "tools" directory! | |
| # | |
| # Be sure your running outside the tools directory otherwise it will not run correctly!!! | |
| # run this command for help | |
| # | |
| # .\tools\wintools -help | |
| # | |
| # This code is released under the Unlicense LICENSE unless aiohttp wants to adopt my script. | |
| # TODO: Didn't write the setup feature yet... | |
| param ( | |
| [switch]$help = $false, | |
| [switch]$h = $false, | |
| [switch]$uv = $false, | |
| [switch]$debug = $false, | |
| [switch]$gen = $false, | |
| [switch]$llhttp = $false, | |
| [switch]$compile = $false, | |
| [switch]$setup = $false, | |
| [switch]$install = $false, | |
| [switch]$nodeenv = $false | |
| ) | |
| function Cythonize-Code($FILENAME, $USE_DEBUG) { | |
| if ($USE_DEBUG){ | |
| Start-Process cythonize -ArgumentList "-a $FILENAME" -NoNewWindow -Wait | |
| } else { | |
| Start-Process cythonize -ArgumentList "$FILENAME" -NoNewWindow -Wait | |
| } | |
| } | |
| function PipSetup($use_uv) { | |
| if ($use_uv){ | |
| Start-Process uv -ArgumentList "pip install -e ." -NoNewWindow -Wait | |
| } else { | |
| Start-Process pip -ArgumentList "install -e ." -NoNewWindow -Wait | |
| } | |
| } | |
| function Install-Requirements($use_uv) { | |
| if ($use_uv){ | |
| Start-Process uv -ArgumentList "pip install -r requirements/dev.txt" -NoNewWindow -Wait | |
| } else { | |
| Start-Process pip -ArgumentList "install -r requirements/dev.txt" -NoNewWindow -Wait | |
| } | |
| } | |
| # Start Execution | |
| # Make sure we generate the C Headers Script | |
| function Print-Help { | |
| Write-Output "Tools for working with aiohttp in developer mode on windows" | |
| Write-Output "-help / -h Shows Help and Exits" | |
| Write-Output "-debug Allow Cython Scripts to Generate HTML files" | |
| Write-Output "-uv Tells script that your working with a uv virtual environment" | |
| Write-Output "-gen Generates the C Headers script" | |
| Write-Output "-llhttp Generates llhttp data and correctly performs cleanup" | |
| Write-Output "-compile Generates & Compiles Cython Code" | |
| Write-Output "-setup runs setup.py and installs aiohttp in developer-mode" | |
| Write-Output "-install installs python package requirements" | |
| # NOTE: Using a Modified version because uv virtual enviornments are not supported yet... | |
| Write-Output "-nodeenv sets up nodeenv virtual enviornment" | |
| } | |
| if ($debug){ | |
| Write-Output "[DEBUG ACTIVATED] CYTHON WILL GENERATE HTML FILES!" | |
| } | |
| if ($h) { | |
| Print-Help | |
| exit(0) | |
| } | |
| if ($help){ | |
| Print-Help | |
| exit(0) | |
| } | |
| if ($gen) { | |
| Write-Output "Generating _find_headers.c Script..." | |
| Start-Process python -ArgumentList "tools/gen.py" -NoNewWindow | |
| } | |
| if ($llhttp) { | |
| Write-Output "Generating llhttp scripts..." | |
| if (Test-Path -Path "vendor/llhttp/lib"){ | |
| Write-Output "Cleaning up previously Generated scripts" | |
| Start-Process "cmd" -ArgumentList "/s /c del vendor\llhttp\lib /S /Q" -NoNewWindow -Wait | |
| Start-Process "cmd" -ArgumentList "/s /c rmdir /S /Q vendor\llhttp\lib" -NoNewWindow -Wait | |
| } | |
| Write-Output "Generating C Files..." | |
| Start-Process "cmd" -ArgumentList "/s /c cd vendor\llhttp && npm run build-ts" -NoNewWindow -Wait | |
| Start-Process "cmd" -ArgumentList "/s /c cd vendor\llhttp && npm run build" -NoNewWindow -Wait | |
| } | |
| if ($compile) { | |
| Write-Output "Compiling Cython Scripts..." | |
| Cythonize-Code "aiohttp\_http_parser.pyx" $debug | |
| Cythonize-Code "aiohttp\_http_writer.pyx" $debug | |
| Cythonize-Code "aiohttp\_websocket\mask.pyx" $debug | |
| Cythonize-Code "aiohttp\_websocket\reader_c.py" $debug | |
| } | |
| if ($install) { | |
| Install-Requirements $uv | |
| } | |
| if ($nodeenv) { | |
| if ($uv) { | |
| Write-Output "WARNING! THIS IS CURRENTLY EXPERIMENTAL; Theres a fork on github that fixes this but no garaentees!" | |
| Write-Output "To install that version use pip install git+https://github.com/Vizonex/nodeenv" | |
| } | |
| # TODO: Make it install nodeenv | |
| Start-Process nodeenv -ArgumentList "-p -c" -NoNewWindow -Wait | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment