mirror of
https://github.com/jamesroberts/fastwsgi.git
synced 2025-12-20 13:49:31 -06:00
Fix setup.py for Windows (#44)
This commit is contained in:
34
setup.py
34
setup.py
@@ -1,20 +1,42 @@
|
||||
import os
|
||||
import glob
|
||||
from setuptools import setup
|
||||
from distutils.core import Extension
|
||||
from setup_libuv import build_libuv
|
||||
from distutils.command.build_ext import build_ext
|
||||
import setup_libuv
|
||||
|
||||
SOURCES = glob.glob("fastwsgi/*.c") + glob.glob("llhttp/src/*.c")
|
||||
|
||||
ext_compile_args = [ "-O3", "-fno-strict-aliasing", "-fcommon", "-g", "-Wall" ]
|
||||
ext_compile_args += [ "-Wno-unused-function", "-Wno-unused-variable" ]
|
||||
|
||||
module = Extension(
|
||||
"_fastwsgi",
|
||||
sources=SOURCES,
|
||||
include_dirs=["llhttp/include", "libuv/include"],
|
||||
extra_compile_args=ext_compile_args
|
||||
)
|
||||
|
||||
class build_all(build_ext):
|
||||
def initialize_options(self):
|
||||
build_ext.initialize_options(self)
|
||||
|
||||
def build_extensions(self):
|
||||
global module
|
||||
|
||||
setup_libuv.build_libuv(self)
|
||||
|
||||
compiler = self.compiler.compiler_type
|
||||
print("Current compiler:", compiler)
|
||||
|
||||
for ext in self.extensions:
|
||||
if ext == module:
|
||||
if compiler == 'msvc':
|
||||
ext.extra_compile_args = [ '/Oi', '/Oy-', '/W3', '/WX-', '/Gd', '/GS' ]
|
||||
ext.extra_compile_args += [ '/Zc:forScope', '/Zc:inline', '/fp:precise', '/analyze-' ]
|
||||
else:
|
||||
ext.extra_compile_args = [ "-O3", "-fno-strict-aliasing", "-fcommon", "-g", "-Wall" ]
|
||||
ext.extra_compile_args += [ "-Wno-unused-function", "-Wno-unused-variable" ]
|
||||
|
||||
build_ext.build_extensions(self)
|
||||
|
||||
|
||||
with open("README.md", "r", encoding="utf-8") as read_me:
|
||||
long_description = read_me.read()
|
||||
|
||||
@@ -43,7 +65,7 @@ setup(
|
||||
],
|
||||
python_requires=">=3.6",
|
||||
install_requires=["click>=7.0"],
|
||||
cmdclass={"build_ext": build_libuv},
|
||||
cmdclass={"build_ext": build_all},
|
||||
entry_points={
|
||||
"console_scripts": [
|
||||
"fastwsgi = fastwsgi:run_from_cli",
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
import os
|
||||
import sys
|
||||
import glob
|
||||
from distutils.command.build_ext import build_ext
|
||||
|
||||
SOURCES = glob.glob('libuv/src/*.c')
|
||||
|
||||
@@ -81,13 +80,10 @@ elif sys.platform.startswith('sunos'):
|
||||
]
|
||||
|
||||
|
||||
class build_libuv(build_ext):
|
||||
libuv_dir = os.path.join('libuv')
|
||||
|
||||
def initialize_options(self):
|
||||
build_ext.initialize_options(self)
|
||||
|
||||
def build_extensions(self):
|
||||
def build_libuv(build_ext):
|
||||
self = build_ext
|
||||
self.libuv_dir = os.path.join('libuv')
|
||||
if True:
|
||||
self.compiler.add_include_dir(os.path.join(self.libuv_dir, 'include'))
|
||||
self.compiler.add_include_dir(os.path.join(self.libuv_dir, 'src'))
|
||||
self.extensions[0].sources += SOURCES
|
||||
@@ -125,5 +121,3 @@ class build_libuv(build_ext):
|
||||
self.compiler.add_library('userenv')
|
||||
self.compiler.add_library('ws2_32')
|
||||
self.compiler.add_library('secur32')
|
||||
|
||||
build_ext.build_extensions(self)
|
||||
|
||||
Reference in New Issue
Block a user