Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set dlopen flags so uwsgi plugins work #17

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions patch-uwsgi-packaging.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ SRC=$1
APPEND_VERSION=${APPEND_VERSION:-""}

cp setup.py $SRC/setup.py
cp pyuwsgi_main.py $SRC/pyuwsgi_main.py
sed -i.bak 's/uwsgiconfig\.uwsgi_version/uwsgiconfig.uwsgi_version + "'$APPEND_VERSION'"/' $SRC/setup.py
rm $SRC/setup.py.bak
cp $SRC/buildconf/pyuwsgi.ini $SRC/buildconf/pyuwsginossl.ini
Expand Down
16 changes: 16 additions & 0 deletions pyuwsgi_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import os
import sys

# we import `pyuwsgi` with `dlopen` flags set to `os.RTLD_GLOBAL` such that
# uwsgi plugins can discover uwsgi's globals (notably `extern ... uwsgi`)
if hasattr(sys, 'setdlopenflags'):
orig = sys.getdlopenflags()
try:
sys.setdlopenflags(orig | os.RTLD_GLOBAL)
import pyuwsgi
finally:
sys.setdlopenflags(orig)
else: # ah well, can't control how dlopen works here
import pyuwsgi

run = pyuwsgi.run
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,13 @@ def uwsgi_build(self):
},
py_modules=[
'uwsgidecorators',
'pyuwsgi_main',
],
ext_modules=[
Extension('pyuwsgi', sources=[]),
],
entry_points={
'console_scripts': ['pyuwsgi=pyuwsgi:run', 'uwsgi=pyuwsgi:run'],
'console_scripts': ['pyuwsgi=pyuwsgi_main:run', 'uwsgi=pyuwsgi_main:run'],
},
classifiers=[
'Development Status :: 5 - Production/Stable',
Expand Down