Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 72 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,79 @@ jobs:
name: dist-wheels-${{ matrix.os }}-${{ matrix.python }}-${{ matrix.cibw_arch }}
path: wheelhouse/*.whl

build-windows-wheels:
needs: validate-release-request
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
arch: AMD64
build: "cp38-* cp39-* cp310-* cp311-* cp312-* cp313-* cp314-* cp314t-*"
constraint: ""
- os: windows-11-arm
arch: ARM64
build: "cp311-* cp312-* cp313-* cp314-* cp314t-*"
constraint: PIP_CONSTRAINT=${{ github.workspace }}\constraints-windows-arm64.txt

env:
PIP_DISABLE_PIP_VERSION_CHECK: 1

steps:
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
with:
fetch-depth: 50
submodules: true

- uses: pypa/cibuildwheel@7c619efba910c04005a835b110b057fc28fd6e93 # v3.2.0
env:
CIBW_BUILD_VERBOSITY: 1
CIBW_BUILD: ${{ matrix.build }}
CIBW_ARCHS: ${{ matrix.arch }}
CIBW_ENVIRONMENT: ${{ matrix.constraint }}

- name: Verify Windows ARM64 wheels
if: matrix.arch == 'ARM64'
shell: pwsh
run: |
Add-Type -AssemblyName System.IO.Compression.FileSystem
Get-ChildItem wheelhouse/*.whl | ForEach-Object {
$archive = [System.IO.Compression.ZipFile]::OpenRead($_.FullName)
try {
$nativeEntry = $archive.Entries |
Where-Object FullName -Like 'uvloop/*.pyd' |
Select-Object -First 1
if (-not $nativeEntry) {
throw "Missing native extension in $($_.Name)"
}

$reader = [System.IO.BinaryReader]::new($nativeEntry.Open())
try {
$bytes = $reader.ReadBytes([int]$nativeEntry.Length)
} finally {
$reader.Dispose()
}
$peOffset = [BitConverter]::ToInt32($bytes, 0x3c)
$machine = [BitConverter]::ToUInt16($bytes, $peOffset + 4)
if ($machine -ne 0xAA64) {
throw ('Expected ARM64 PE machine 0xAA64 in {0}, found 0x{1:X4}' -f $_.Name, $machine)
}
} finally {
$archive.Dispose()
}
}

- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: dist-wheels-windows-${{ matrix.arch }}
path: wheelhouse/*.whl

publish:
needs: [build-sdist, build-wheels]
needs:
- build-sdist
- build-wheels
- build-windows-wheels
runs-on: ubuntu-latest

steps:
Expand Down
17 changes: 16 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,18 @@ jobs:
- "3.13"
- "3.14"
- "3.14t"
# TODO: (Vizonex) windows-11-arm
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: windows-11-arm
python-version: "3.11.9"
- os: windows-11-arm
python-version: "3.12.10"
- os: windows-11-arm
python-version: "3.13.15"
- os: windows-11-arm
python-version: "3.14.7"
- os: windows-11-arm
python-version: "3.14t"

env:
PIP_DISABLE_PIP_VERSION_CHECK: 1
Expand Down Expand Up @@ -58,6 +68,11 @@ jobs:
run: |
brew install gnu-sed libtool autoconf automake

- name: Install Windows ARM64 test prerequisite
if: matrix.os == 'windows-11-arm' && steps.release.outputs.version == 0
run: |
pip install --only-binary cryptography --constraint constraints-windows-arm64.txt cryptography

- name: Install Python Deps
if: steps.release.outputs.version == 0
run: |
Expand Down
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

PYTHON ?= python
ROOT = $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
DEBUG_BUILD = --debug
ifeq ($(OS),Windows_NT)
DEBUG_BUILD =
endif


_default: compile
Expand Down Expand Up @@ -34,14 +38,12 @@ setup-build:
compile: clean setup-build


# NOTE: --debug will not work on windows since it asks for a non-existant _d.lib file.
# TODO: Fix workflows for missing debug binaries in the future.
debug: clean
$(PYTHON) setup.py build_ext --inplace \
$(PYTHON) setup.py build_ext --inplace $(DEBUG_BUILD) \
--cython-always \
--cython-annotate \
--cython-directives="linetrace=True" \
--define UVLOOP_DEBUG --define CYTHON_TRACE --define CYTHON_TRACE_NOGIL
--define UVLOOP_DEBUG,CYTHON_TRACE,CYTHON_TRACE_NOGIL


docs:
Expand Down
1 change: 1 addition & 0 deletions constraints-windows-arm64.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cryptography==46.0.3
90 changes: 32 additions & 58 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
if vi < (3, 8):
raise RuntimeError('uvloop requires Python 3.8 or greater')

# TODO: Remove Completely because Winloop Author is mergeing his project to uvloop.
# if sys.platform in ('win32', 'cygwin', 'cli'):
# raise RuntimeError('uvloop does not support Windows at the moment')

import os
import os.path
import pathlib
Expand All @@ -30,10 +26,6 @@
LIBUV_DIR = str(_ROOT / 'vendor' / 'libuv')
LIBUV_BUILD_DIR = str(_ROOT / 'build' / 'libuv-{}'.format(MACHINE))

# NOTE: Mingw was added by another contributor in the winloop project.
MINGW = bool(os.environ.get("MINGW_PREFIX", ""))


def _libuv_build_env():
env = os.environ.copy()

Expand Down Expand Up @@ -88,9 +80,7 @@ class uvloop_build_ext(build_ext):

def initialize_options(self):
super().initialize_options()
# Use mingw if prefix was given for it otherwise it
# will always be false.
self.use_system_libuv = MINGW
self.use_system_libuv = False
self.cython_always = False
self.cython_annotate = None
self.cython_directives = None
Expand Down Expand Up @@ -125,21 +115,17 @@ def finalize_options(self):
import Cython
except ImportError:
raise RuntimeError(
"please install {} to compile uvloop from source".format(
CYTHON_DEPENDENCY
)
)
'please install {} to compile uvloop from source'.format(
CYTHON_DEPENDENCY))

cython_dep = Requirement(CYTHON_DEPENDENCY)
if not cython_dep.specifier.contains(Cython.__version__):
raise RuntimeError(
"uvloop requires {}, got Cython=={}".format(
'uvloop requires {}, got Cython=={}'.format(
CYTHON_DEPENDENCY, Cython.__version__
)
)
))

from Cython.Build import cythonize


directives = {}
if self.cython_directives:
Expand Down Expand Up @@ -201,7 +187,7 @@ def build_libuv(self):
cwd=LIBUV_BUILD_DIR, env=env, check=True)

def build_extensions(self):
if sys.platform == "win32" and not MINGW:
if sys.platform == "win32":
path = pathlib.Path("vendor", "libuv", "src")
c_files = [p.as_posix() for p in path.iterdir() if p.suffix == ".c"]
c_files += [
Expand Down Expand Up @@ -249,41 +235,26 @@ def build_extensions(self):
raise RuntimeError(
'unable to read the version from uvloop/_version.py')

if sys.platform == "win32":
from Cython.Build import cythonize
from Cython.Compiler.Main import default_options

default_options["compile_time_env"] = dict(DEFAULT_FREELIST_SIZE=250)
ext = cythonize(
[
Extension(
"uvloop.loop",
sources=["uvloop/loop.pyx"],
include_dirs=[]
if MINGW
else [
"vendor/libuv/src",
"vendor/libuv/src/win",
"vendor/libuv/include",
],
# subset of libuv Windows libraries:
extra_link_args=[
(f"-l{lib}" if MINGW else f"{lib}.lib")
for lib in (
"Shell32",
"Ws2_32",
"Advapi32",
"iphlpapi",
"Userenv",
"User32",
"Dbghelp",
"Ole32",
)
],
define_macros=[("WIN32_LEAN_AND_MEAN", 1), ("_WIN32_WINNT", "0x0602")],
),
]
)
if sys.platform == 'win32':
ext = [
Extension(
'uvloop.loop',
sources=['uvloop/loop.pyx'],
include_dirs=[
'vendor/libuv/src',
'vendor/libuv/src/win',
'vendor/libuv/include',
],
libraries=[
'Shell32', 'Ws2_32', 'Advapi32', 'iphlpapi',
'Userenv', 'User32', 'Dbghelp', 'Ole32',
],
define_macros=[
('WIN32_LEAN_AND_MEAN', 1),
('_WIN32_WINNT', '0x0602'),
],
),
]
else:
ext = [
Extension(
Expand All @@ -297,14 +268,17 @@ def build_extensions(self):

setup_requires = []

if not (_ROOT / "uvloop" / "loop.c").exists() or "--cython-always" in sys.argv:
if not (_ROOT / 'uvloop' / 'loop.c').exists() or '--cython-always' in sys.argv:
# No Cython output, require Cython to build.
setup_requires.append(CYTHON_DEPENDENCY)


setup(
version=VERSION,
cmdclass={"sdist": uvloop_sdist, "build_ext": uvloop_build_ext},
cmdclass={
'sdist': uvloop_sdist,
'build_ext': uvloop_build_ext
},
ext_modules=ext,
setup_requires=setup_requires,
)
2 changes: 1 addition & 1 deletion tests/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def suite():
return test_suite


if __name__ == "__main__":
if __name__ == '__main__':
runner = unittest.runner.TextTestRunner()
result = runner.run(suite())
sys.exit(not result.wasSuccessful())
Loading