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

add libpcre2 support #2543

Closed
wants to merge 7 commits into from
Closed

add libpcre2 support #2543

wants to merge 7 commits into from

Conversation

niol
Copy link
Contributor

@niol niol commented Jul 21, 2023

I've started the work. It compiles.

I need to test if it works but wanted to share to avoid somebody else wasting time doing the same.

This would fix #2486

@niol niol changed the title switch to pcre2 (WIP, untested) switch to pcre2 Jul 25, 2023
@niol
Copy link
Contributor Author

niol commented Jul 25, 2023

I've played with the following configuration file and it seems to behave as expected.

[uwsgi]
master = False
cheap = True
http-socket = :9090

plugins = python,router_redirect, router_rewrite, router_cache

wsgi-file = helloworld.py

route-user-agent = .*curl.* redirect:http://uwsgi.it
route = ^/test log:someone called /test
route = (.*)\.php$ rewrite:/index.php/$1 log:$1
route = .* addheader:Server: my uWSGI server
route-host = ^localhost$ logvar:local=1
route-uri = ^/foo/(.*)\.jpg\?([0-9]{2})$ log:key=$1.$2.jpg
route-if = equal:${PATH_INFO};/bad break:500 Internal Server Error

helloworld.py:

def application(env, start_response):
    start_response('200 OK', [('Content-Type','text/html')])
    return [b"Hello World"]

@xrmx
Copy link
Collaborator

xrmx commented Jul 25, 2023

Thanks for the PR! Unfortunately we cannot remove pcre implementation and we need to support both to avoid breaking people deployments.

@niol
Copy link
Contributor Author

niol commented Jul 25, 2023

pcre is not maintained anymore, and being removed in distributions, that's why I did not work on all those #ifdef.

@xrmx
Copy link
Collaborator

xrmx commented Jul 25, 2023

But it's still available in the LTS distributions people is using now and uwsgi has been built against.

@niol
Copy link
Contributor Author

niol commented Jul 25, 2023

pcre2 is also available in LTS distributions. Anyway I'll update this PR with fixes as I get feedback (this just got integrated in Debian). I cannot commit time to update to support both but will hapilly help (answer questions) someone who would.

@xrmx
Copy link
Collaborator

xrmx commented Jul 25, 2023

@niol could you please cherry-pick and rebase on top of xrmx@7835662 so at least we avoid conflicts?

@xrmx
Copy link
Collaborator

xrmx commented Jul 25, 2023

pcre2 is also available in LTS distributions.

I know it's available, what I'm saying I don't like to break the build of the majority of uwsgi users that is pip installing uwsgi and not using uwsgi from the distribution.

@loqs
Copy link
Contributor

loqs commented Jul 27, 2023

@xrmx is this what you had in mind for retaining pcre1 support https://gist.github.com/loqs/f79a4095875defb294f6617ba06dcd41
I had to add an extra define to differentiate between the two versions of pcre.

@xrmx
Copy link
Collaborator

xrmx commented Jul 28, 2023

@loqs i thought more of two alternative definition (UWSGI_PCRE vs UWSGI_PCRE2) but that's fine too

Copy link
Contributor

@loqs loqs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please ignore the formatting comments if they are too pedantic.

core/regexp.c Show resolved Hide resolved
core/routing.c Show resolved Hide resolved
core/regexp.c Outdated Show resolved Hide resolved
@loqs
Copy link
Contributor

loqs commented Jul 28, 2023

@loqs i thought more of two alternative definition (UWSGI_PCRE vs UWSGI_PCRE2) but that's fine too

https://gist.github.com/loqs/0aa5f478b0c684c935b0b4f202298aa6 with two alternative definitions.

@niol niol changed the title switch to pcre2 add libpcre2 support Jul 29, 2023
@niol
Copy link
Contributor Author

niol commented Aug 30, 2023

Any more comments on this?

@xrmx
Copy link
Collaborator

xrmx commented Sep 1, 2023

Any more comments on this?

I'll try to give a review this afternoon

uwsgi.h Outdated Show resolved Hide resolved
core/regexp.c Outdated Show resolved Hide resolved
core/regexp.c Show resolved Hide resolved
uwsgi.h Outdated Show resolved Hide resolved
@BKPepe
Copy link

BKPepe commented Sep 22, 2023

Kind reminder, what needs to be done to have this merged, please?

@rockdrilla
Copy link

@matejsp
Copy link

matejsp commented Jan 2, 2024

I would really like pcre2 support merged in uwsgi. We are currently doing bundling of .so files with auditwheel because pcre is not even installed by default in most if not all latest distros.

dnf install patchelf
pip install auditwheel wheel
pip wheel uwsgi-2.0.23.tar.gz
auditwheel repair uWSGI-2.0.23-cp311-cp311-linux_x86_64.whl --plat manylinux_2_34_$(uname -m) --wheel-dir bla --exclude libssl.so.3 --exclude libcrypt.so.2 --exclude libcrypto.so.3

@niol niol force-pushed the pcre2 branch 7 times, most recently from ee6bb72 to 0d31786 Compare February 13, 2024 11:26
@RemiCardona
Copy link

got bit by this (silently because pip hides the build output by default, it seems) and it took me a long time to figure out why the "Expires" settings for static files was not being set.

So a kind +1 from me. TIA

@svenstaro
Copy link

@xrmx friendly ping. Could we merge this and get a release out? pcre is going to be dropped sooner or later from all major distros.

@xrmx
Copy link
Collaborator

xrmx commented Apr 6, 2024

Squashed and merged to master in #2624. Thanks!

@xrmx xrmx closed this Apr 6, 2024
@xrmx
Copy link
Collaborator

xrmx commented Apr 7, 2024

@niol just noticed that when squashing I erased your authorship, sorry about that. Will fix for 2.0 backport at least.

@svenstaro
Copy link

@xrmx could we please get a new release including this?

@niol niol deleted the pcre2 branch May 7, 2024 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider porting to PCRE2
8 participants