liburlparser 1.4.5__tar.gz → 1.5.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {liburlparser-1.4.5 → liburlparser-1.5.0}/.github/workflows/cmake.yml +2 -3
- {liburlparser-1.4.5 → liburlparser-1.5.0}/.github/workflows/wheels.yml +8 -8
- liburlparser-1.5.0/.ruff_cache/.gitignore +2 -0
- liburlparser-1.5.0/.ruff_cache/0.7.0/1045475550077068025 +0 -0
- liburlparser-1.5.0/.ruff_cache/0.7.0/4604544773037589564 +0 -0
- liburlparser-1.5.0/CMakeLists.txt +230 -0
- {liburlparser-1.4.5 → liburlparser-1.5.0}/PKG-INFO +112 -57
- {liburlparser-1.4.5 → liburlparser-1.5.0}/README.md +110 -55
- {liburlparser-1.4.5/cmake/modules → liburlparser-1.5.0/cmake}/PyProject.cmake +0 -0
- {liburlparser-1.4.5 → liburlparser-1.5.0}/examples/main.cpp +1 -1
- {liburlparser-1.4.5 → liburlparser-1.5.0}/pyproject.toml +2 -2
- liburlparser-1.5.0/src/binding/about.cpp +19 -0
- {liburlparser-1.4.5/src/binding → liburlparser-1.5.0/src/binding/bind_core}/main.cpp +2 -6
- {liburlparser-1.4.5 → liburlparser-1.5.0}/src/liburlparser/__init__.py +2 -1
- {liburlparser-1.4.5 → liburlparser-1.5.0}/src/liburlparser/core.py +1 -1
- {liburlparser-1.4.5 → liburlparser-1.5.0}/tests/python/test_extra.py +1 -1
- liburlparser-1.4.5/.ruff_cache/.gitignore +0 -1
- liburlparser-1.4.5/.ruff_cache/0.1.6/3317816331866568629 +0 -0
- liburlparser-1.4.5/.ruff_cache/0.1.6/9292255169009148407 +0 -0
- liburlparser-1.4.5/CMakeLists.txt +0 -175
- {liburlparser-1.4.5 → liburlparser-1.5.0}/.clang-format +0 -0
- {liburlparser-1.4.5 → liburlparser-1.5.0}/.gitignore +0 -0
- {liburlparser-1.4.5 → liburlparser-1.5.0}/.gitmodules +0 -0
- {liburlparser-1.4.5 → liburlparser-1.5.0}/.ruff_cache/CACHEDIR.TAG +0 -0
- {liburlparser-1.4.5 → liburlparser-1.5.0}/LICENSE +0 -0
- {liburlparser-1.4.5 → liburlparser-1.5.0}/conda.recipe/meta.yaml +0 -0
- {liburlparser-1.4.5 → liburlparser-1.5.0}/docs/Doxyfile.in +0 -0
- {liburlparser-1.4.5 → liburlparser-1.5.0}/docs/images/logo/liburlparser-logo-1.svg +0 -0
- {liburlparser-1.4.5 → liburlparser-1.5.0}/docs/images/logo/liburlparser-logo-2.svg +0 -0
- {liburlparser-1.4.5 → liburlparser-1.5.0}/examples/common.h +0 -0
- {liburlparser-1.4.5 → liburlparser-1.5.0}/include/urlparser.h +0 -0
- {liburlparser-1.4.5 → liburlparser-1.5.0}/src/liburlparser/__main__.py +0 -0
- {liburlparser-1.4.5 → liburlparser-1.5.0}/src/psl.cpp +0 -0
- {liburlparser-1.4.5 → liburlparser-1.5.0}/src/psl.h +0 -0
- {liburlparser-1.4.5 → liburlparser-1.5.0}/src/url.cpp +0 -0
- {liburlparser-1.4.5 → liburlparser-1.5.0}/src/url.h +0 -0
- {liburlparser-1.4.5 → liburlparser-1.5.0}/src/urlparser_host.cpp +0 -0
- {liburlparser-1.4.5 → liburlparser-1.5.0}/src/urlparser_url.cpp +0 -0
- {liburlparser-1.4.5 → liburlparser-1.5.0}/tests/cpp/common.h +0 -0
- {liburlparser-1.4.5 → liburlparser-1.5.0}/tests/cpp/test_host.cpp +0 -0
- {liburlparser-1.4.5 → liburlparser-1.5.0}/tests/cpp/test_url.cpp +0 -0
- {liburlparser-1.4.5 → liburlparser-1.5.0}/tests/data/host_data.csv +0 -0
- {liburlparser-1.4.5 → liburlparser-1.5.0}/tests/data/url_data.csv +0 -0
- {liburlparser-1.4.5 → liburlparser-1.5.0}/tests/python/test_host.py +0 -0
- {liburlparser-1.4.5 → liburlparser-1.5.0}/tests/python/test_url.py +0 -0
|
@@ -13,7 +13,7 @@ env:
|
|
|
13
13
|
FORCE_COLOR: 3
|
|
14
14
|
|
|
15
15
|
concurrency:
|
|
16
|
-
group:
|
|
16
|
+
group: github.workflow−{{ github.workflow }}-{{ github.ref }}
|
|
17
17
|
cancel-in-progress: true
|
|
18
18
|
|
|
19
19
|
jobs:
|
|
@@ -25,8 +25,12 @@ jobs:
|
|
|
25
25
|
with:
|
|
26
26
|
submodules: false
|
|
27
27
|
|
|
28
|
+
- uses: actions/setup-python@v4
|
|
29
|
+
with:
|
|
30
|
+
python-version: "3.x"
|
|
31
|
+
|
|
28
32
|
- name: Ruff Check
|
|
29
|
-
|
|
33
|
+
run: pipx run ruff check .
|
|
30
34
|
|
|
31
35
|
- name: Build SDist
|
|
32
36
|
run: pipx run build --sdist
|
|
@@ -43,7 +47,7 @@ jobs:
|
|
|
43
47
|
name: Wheels on ${{ matrix.os }}
|
|
44
48
|
runs-on: ${{ matrix.os }}
|
|
45
49
|
strategy:
|
|
46
|
-
fail-fast:
|
|
50
|
+
fail-fast: true
|
|
47
51
|
matrix:
|
|
48
52
|
os: [ubuntu-latest, windows-latest]
|
|
49
53
|
|
|
@@ -53,7 +57,7 @@ jobs:
|
|
|
53
57
|
submodules: true
|
|
54
58
|
|
|
55
59
|
- name: Build wheels
|
|
56
|
-
uses: pypa/cibuildwheel@v2.
|
|
60
|
+
uses: pypa/cibuildwheel@v2.16.5
|
|
57
61
|
env:
|
|
58
62
|
# CIBW_ARCHS_MACOS: universal2
|
|
59
63
|
# CIBW_ARCHS_WINDOWS: auto ARM64
|
|
@@ -77,10 +81,6 @@ jobs:
|
|
|
77
81
|
if: startsWith(github.ref, 'refs/tags/')
|
|
78
82
|
|
|
79
83
|
steps:
|
|
80
|
-
- uses: actions/setup-python@v4
|
|
81
|
-
with:
|
|
82
|
-
python-version: "3.x"
|
|
83
|
-
|
|
84
84
|
- uses: actions/download-artifact@v3
|
|
85
85
|
with:
|
|
86
86
|
name: artifact
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.19)
|
|
2
|
+
|
|
3
|
+
option(BUILD_PYTHON "export python module" off)
|
|
4
|
+
|
|
5
|
+
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ version selection")
|
|
6
|
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
7
|
+
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
|
|
11
|
+
include(PyProject)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
if(NOT CMAKE_BUILD_TYPE)
|
|
15
|
+
set(CMAKE_BUILD_TYPE Release)
|
|
16
|
+
endif()
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}" CACHE STRING "" FORCE)
|
|
21
|
+
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING "" FORCE)
|
|
22
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "" FORCE)
|
|
23
|
+
|
|
24
|
+
project(${PyProject_NAME} LANGUAGES CXX VERSION ${PyProject_VERSION})
|
|
25
|
+
message(STATUS "Project: ${PROJECT_NAME}@v${PROJECT_VERSION}")
|
|
26
|
+
|
|
27
|
+
find_package(Python3 REQUIRED COMPONENTS Interpreter)
|
|
28
|
+
|
|
29
|
+
if(DEFINED SKBUILD)
|
|
30
|
+
set(PYTHON_PROJECT_NAME "${SKBUILD_PROJECT_NAME}")
|
|
31
|
+
elseif(BUILD_PYTHON)
|
|
32
|
+
set(PYTHON_PROJECT_NAME "${CMAKE_BINARY_DIR}")
|
|
33
|
+
|
|
34
|
+
if(NOT PYTHON_REQUIREMENT_INSTALLED)
|
|
35
|
+
execute_process(
|
|
36
|
+
COMMAND "${Python3_EXECUTABLE}" -m pip install
|
|
37
|
+
nanobind ninja pytest-xdist pip-tools # build requirements
|
|
38
|
+
OUTPUT_QUIET COMMAND_ERROR_IS_FATAL ANY
|
|
39
|
+
)
|
|
40
|
+
execute_process(
|
|
41
|
+
COMMAND "${Python3_EXECUTABLE}" -m piptools compile --output-file ${CMAKE_CURRENT_BINARY_DIR}/requirements.txt pyproject.toml
|
|
42
|
+
--no-emit-options --quiet --no-strip-extras --extra test
|
|
43
|
+
OUTPUT_QUIET COMMAND_ERROR_IS_FATAL ANY
|
|
44
|
+
)
|
|
45
|
+
execute_process(
|
|
46
|
+
COMMAND "${Python3_EXECUTABLE}" -m pip install -r ${CMAKE_CURRENT_BINARY_DIR}/requirements.txt
|
|
47
|
+
OUTPUT_QUIET COMMAND_ERROR_IS_FATAL ANY
|
|
48
|
+
)
|
|
49
|
+
set(PYTHON_REQUIREMENT_INSTALLED TRUE CACHE INTERNAL "Python requirements installed")
|
|
50
|
+
endif()
|
|
51
|
+
|
|
52
|
+
execute_process(
|
|
53
|
+
COMMAND "${Python3_EXECUTABLE}" -m nanobind --cmake_dir
|
|
54
|
+
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE NB_DIR)
|
|
55
|
+
|
|
56
|
+
message(STATUS "Found NanoBind at ${NB_DIR}")
|
|
57
|
+
list(APPEND CMAKE_PREFIX_PATH "${NB_DIR}")
|
|
58
|
+
endif()
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
# Download the public suffix list file from the internet
|
|
63
|
+
set(PUBLIC_SUFFIX_LIST_URL "https://publicsuffix.org/list/public_suffix_list.dat")
|
|
64
|
+
set(PUBLIC_SUFFIX_LIST_DAT "public_suffix_list.dat")
|
|
65
|
+
if(NOT DEFINED SKBUILD)
|
|
66
|
+
set(PUBLIC_SUFFIX_LIST_DAT "${CMAKE_CURRENT_BINARY_DIR}/${PUBLIC_SUFFIX_LIST_DAT}")
|
|
67
|
+
endif()
|
|
68
|
+
|
|
69
|
+
# Download the public suffix list file from the internet if not already exists
|
|
70
|
+
if(EXISTS "${PUBLIC_SUFFIX_LIST_DAT}")
|
|
71
|
+
message(STATUS "[DATA] ${PUBLIC_SUFFIX_LIST_DAT} is found.")
|
|
72
|
+
else()
|
|
73
|
+
message(WARNING "[DATA] ${PUBLIC_SUFFIX_LIST_DAT} is not found. Trying to download it.")
|
|
74
|
+
file(DOWNLOAD "${PUBLIC_SUFFIX_LIST_URL}" ${PUBLIC_SUFFIX_LIST_DAT})
|
|
75
|
+
if(EXISTS "${PUBLIC_SUFFIX_LIST_DAT}")
|
|
76
|
+
message(STATUS "[DATA] ${PUBLIC_SUFFIX_LIST_DAT} is downloaded.")
|
|
77
|
+
else()
|
|
78
|
+
message(FATAL_ERROR "[DATA] Failed to download ${PUBLIC_SUFFIX_LIST_DAT}.")
|
|
79
|
+
endif()
|
|
80
|
+
endif()
|
|
81
|
+
|
|
82
|
+
file(GLOB SOURCES ${PROJECT_SOURCE_DIR}/src/*.cpp)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
if(DEFINED PYTHON_PROJECT_NAME)
|
|
86
|
+
# Try to import all Python components potentially needed by nanobind
|
|
87
|
+
#set(Python3_FIND_STRATEGY LOCATION)
|
|
88
|
+
find_package(Python 3.8
|
|
89
|
+
REQUIRED COMPONENTS Interpreter Development.Module
|
|
90
|
+
OPTIONAL_COMPONENTS Development.SABIModule)
|
|
91
|
+
# Import nanobind through CMake's find_package mechanism
|
|
92
|
+
find_package(nanobind CONFIG REQUIRED)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
set(NB_MODULE _about)
|
|
96
|
+
nanobind_add_module(${NB_MODULE} STABLE_ABI NB_STATIC ${PROJECT_SOURCE_DIR}/src/binding/about.cpp)
|
|
97
|
+
target_compile_definitions(${NB_MODULE} PRIVATE
|
|
98
|
+
VERSION_INFO=${PROJECT_VERSION}
|
|
99
|
+
NB_MODULE_NAME=${NB_MODULE})
|
|
100
|
+
|
|
101
|
+
file(GLOB PYTHON_BIND_MODULES_PATH ${PROJECT_SOURCE_DIR}/src/binding/bind_*)
|
|
102
|
+
set(PYTHON_BIND_MODULES "${NB_MODULE}")
|
|
103
|
+
foreach(NB_MODULE_PATH IN LISTS PYTHON_BIND_MODULES_PATH)
|
|
104
|
+
get_filename_component(NB_MODULE ${NB_MODULE_PATH} NAME)
|
|
105
|
+
string(REGEX REPLACE "bind(.*)" "\\1" NB_MODULE ${NB_MODULE})
|
|
106
|
+
list(APPEND PYTHON_BIND_MODULES ${NB_MODULE})
|
|
107
|
+
file(GLOB NB_MODULE_SOURCES ${NB_MODULE_PATH}/*.cpp)
|
|
108
|
+
|
|
109
|
+
message(STATUS "Found module: ${NB_MODULE}")
|
|
110
|
+
|
|
111
|
+
# Add more commands here to process each directory as needed
|
|
112
|
+
|
|
113
|
+
# We are now ready to compile the actual extension module
|
|
114
|
+
nanobind_add_module(
|
|
115
|
+
# Name of the extension
|
|
116
|
+
${NB_MODULE}
|
|
117
|
+
|
|
118
|
+
# Target the stable ABI for Python 3.12+, which reduces
|
|
119
|
+
# the number of binary wheels that must be built. This
|
|
120
|
+
# does nothing on older Python versions
|
|
121
|
+
STABLE_ABI
|
|
122
|
+
|
|
123
|
+
# Build libnanobind statically and merge it into the
|
|
124
|
+
# extension (which itself remains a shared library)
|
|
125
|
+
#
|
|
126
|
+
# If your project builds multiple extensions, you can
|
|
127
|
+
# replace this flag by NB_SHARED to conserve space by
|
|
128
|
+
# reusing a shared libnanobind across libraries
|
|
129
|
+
NB_STATIC
|
|
130
|
+
|
|
131
|
+
# Source code goes here
|
|
132
|
+
${NB_MODULE_SOURCES} ${SOURCES}
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
target_include_directories(${NB_MODULE} PRIVATE include src)
|
|
136
|
+
target_compile_definitions(${NB_MODULE} PRIVATE NB_MODULE_NAME=${NB_MODULE})
|
|
137
|
+
target_compile_definitions(${NB_MODULE} PRIVATE
|
|
138
|
+
DONT_INIT_PSL
|
|
139
|
+
PUBLIC_SUFFIX_LIST_URL="${PUBLIC_SUFFIX_LIST_URL}"
|
|
140
|
+
PUBLIC_SUFFIX_LIST_DAT="${PUBLIC_SUFFIX_LIST_DAT}"
|
|
141
|
+
)
|
|
142
|
+
endforeach()
|
|
143
|
+
|
|
144
|
+
if(DEFINED SKBUILD)
|
|
145
|
+
install(TARGETS ${PYTHON_BIND_MODULES}
|
|
146
|
+
CONFIGURATIONS Release
|
|
147
|
+
LIBRARY DESTINATION
|
|
148
|
+
${PYTHON_PROJECT_NAME})
|
|
149
|
+
install (FILES ${PUBLIC_SUFFIX_LIST_DAT}
|
|
150
|
+
DESTINATION ${SKBUILD_PROJECT_NAME})
|
|
151
|
+
else()
|
|
152
|
+
file(COPY ${PROJECT_SOURCE_DIR}/src/${PROJECT_NAME} DESTINATION ${PYTHON_PROJECT_NAME})
|
|
153
|
+
file(COPY ${PUBLIC_SUFFIX_LIST_DAT} DESTINATION ${PYTHON_PROJECT_NAME}/${PROJECT_NAME} )
|
|
154
|
+
|
|
155
|
+
foreach(_core IN LISTS PYTHON_BIND_MODULES)
|
|
156
|
+
set_target_properties(${_core} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PYTHON_PROJECT_NAME}/${PROJECT_NAME})
|
|
157
|
+
endforeach()
|
|
158
|
+
endif()
|
|
159
|
+
endif()
|
|
160
|
+
|
|
161
|
+
if(DEFINED SKBUILD)
|
|
162
|
+
RETURN()
|
|
163
|
+
endif()
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
add_library(urlparser SHARED ${SOURCES})
|
|
168
|
+
add_library(url::base ALIAS urlparser)
|
|
169
|
+
target_compile_definitions(urlparser PRIVATE
|
|
170
|
+
PUBLIC_SUFFIX_LIST_DAT="${PUBLIC_SUFFIX_LIST_DAT}"
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
target_include_directories(urlparser
|
|
174
|
+
PUBLIC
|
|
175
|
+
${PROJECT_SOURCE_DIR}/include
|
|
176
|
+
PRIVATE
|
|
177
|
+
${PROJECT_SOURCE_DIR}/src)
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
add_executable(example examples/main.cpp)
|
|
181
|
+
target_link_libraries(example PRIVATE url::base)
|
|
182
|
+
|
|
183
|
+
install(TARGETS urlparser
|
|
184
|
+
LIBRARY DESTINATION lib
|
|
185
|
+
ARCHIVE DESTINATION lib
|
|
186
|
+
INCLUDES DESTINATION include
|
|
187
|
+
)
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
enable_testing()
|
|
192
|
+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party/googletest)
|
|
193
|
+
file(GLOB TEST_SOURCES ${PROJECT_SOURCE_DIR}/tests/cpp/*.cpp)
|
|
194
|
+
|
|
195
|
+
add_executable(test_liburlparser ${TEST_SOURCES})
|
|
196
|
+
target_link_libraries(test_liburlparser PRIVATE url::base gtest gtest_main pthread)
|
|
197
|
+
target_include_directories(test_liburlparser PRIVATE ${PROJECT_SOURCE_DIR}/tests/cpp)
|
|
198
|
+
add_test(NAME unitTests COMMAND test_liburlparser)
|
|
199
|
+
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} -V DEPENDS test_liburlparser)
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
if(BUILD_PYTHON)
|
|
203
|
+
add_test(NAME pythonTests
|
|
204
|
+
COMMAND ${Python3_EXECUTABLE} -m pytest -n auto ${PROJECT_SOURCE_DIR}/tests/python
|
|
205
|
+
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
|
206
|
+
)
|
|
207
|
+
endif()
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
# Find Doxygen package
|
|
212
|
+
find_package(Doxygen)
|
|
213
|
+
message(STATUS "Doxygen_FOUND : ${Doxygen_FOUND}")
|
|
214
|
+
# Find Doxygen package
|
|
215
|
+
if (Doxygen_FOUND)
|
|
216
|
+
# Configure Doxyfile.in template
|
|
217
|
+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
|
|
218
|
+
|
|
219
|
+
# Add target to generate documentation
|
|
220
|
+
add_custom_target(docs
|
|
221
|
+
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
|
|
222
|
+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
|
223
|
+
COMMENT "Generating Doxygen documentation"
|
|
224
|
+
VERBATIM
|
|
225
|
+
)
|
|
226
|
+
endif ()
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: liburlparser
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.5.0
|
|
4
4
|
Summary: Fastest Url parser in the world
|
|
5
5
|
Author-Email: Mohammad Raziei <mohammadraziei1375@gmail.com>
|
|
6
6
|
Classifier: Development Status :: 4 - Beta
|
|
@@ -18,7 +18,7 @@ Project-URL: Bug tracker, https://github.com/mohammadraziei/liburlparser/issues
|
|
|
18
18
|
Project-URL: Document, https://mohammadraziei.github.io/liburlparser/latest
|
|
19
19
|
Requires-Python: >=3.8
|
|
20
20
|
Requires-Dist: filelock
|
|
21
|
-
Requires-Dist: pytest; extra == "test"
|
|
21
|
+
Requires-Dist: pytest-xdist; extra == "test"
|
|
22
22
|
Requires-Dist: requests; extra == "test"
|
|
23
23
|
Requires-Dist: requests; extra == "online"
|
|
24
24
|
Provides-Extra: test
|
|
@@ -37,9 +37,29 @@ Description-Content-Type: text/markdown
|
|
|
37
37
|
</h4>
|
|
38
38
|
</p>
|
|
39
39
|
|
|
40
|
-
](https://github.com/mohammadraziei/liburlparser "Go to GitHub repo")
|
|
41
|
+
[](https://github.com/mohammadraziei/liburlparser)
|
|
42
|
+
[](https://github.com/mohammadraziei/liburlparser)
|
|
43
|
+
|
|
44
|
+
[](https://pypi.org/project/liburlparser/)
|
|
45
|
+

|
|
46
|
+

|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
[](https://github.com/mohammadraziei/liburlparser/releases/)
|
|
50
|
+
[](#license)
|
|
51
|
+
[](https://github.com/mohammadraziei/liburlparser/issues)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
[](https://sonarcloud.io/summary/new_code?id=MohammadRaziei_liburlparser)
|
|
55
|
+
|
|
56
|
+
[](https://sonarcloud.io/summary/new_code?id=MohammadRaziei_liburlparser)
|
|
57
|
+
[](https://snyk.io/advisor/python/liburlparser)
|
|
58
|
+
|
|
59
|
+
[//]: # ([](https://mohammadraziei.github.io/liburlparser/))
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
43
63
|
<!--
|
|
44
64
|

|
|
45
65
|
[](https://pypi.org/project/PyDomainExtractor/)
|
|
@@ -65,13 +85,42 @@ Description-Content-Type: text/markdown
|
|
|
65
85
|
|
|
66
86
|
## About The Project
|
|
67
87
|
|
|
88
|
+
**liburlparser** is a powerful domain extractor library written in C++ with Python bindings. It provides efficient URL parsing capabilities for both C++ and Python, making it a valuable tool for projects that involve working with web addresses.
|
|
89
|
+
|
|
68
90
|
### Features
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
Here are some key features of **liburlparser**:
|
|
94
|
+
|
|
95
|
+
1. **Multiple Language Support**:
|
|
96
|
+
- liburlparser can be used in multiple programming languages, including `Python`, `C++`, and `Shell`.
|
|
97
|
+
- It offers an intuitive interface that remains consistent across both C++ and Python.
|
|
98
|
+
|
|
99
|
+
2. **Clean Code Design**:
|
|
100
|
+
- The library provides two separate classes: `Url` and `Host`.
|
|
101
|
+
- This separation allows for cleaner and more organized code when dealing with URLs.
|
|
102
|
+
|
|
103
|
+
3. **Public Suffix List Support**:
|
|
104
|
+
- liburlparser supports known combinatorial suffixes (e.g., "ac.ir") using the public_suffix_list.
|
|
105
|
+
- It can also handle unknown suffixes (e.g., "comm" in "google.comm").
|
|
106
|
+
|
|
107
|
+
4. **Automatic Public Suffix List Updates**:
|
|
108
|
+
- Before each build and deployment, liburlparser updates the public_suffix_list automatically.
|
|
109
|
+
|
|
110
|
+
5. **Host Properties**:
|
|
111
|
+
- The `Host` class includes properties such as subdomain, domain, domain name, and suffix.
|
|
112
|
+
|
|
113
|
+
6. **URL Properties**:
|
|
114
|
+
- The `Url` class provides properties like protocol, userinfo, host (and all host properties), port, path, query parameters, and fragment.
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
<!--
|
|
69
118
|
* Multiple programming language supported such as `Python`, `C++` and `Shell`
|
|
70
119
|
* Intuitive interface and identical in C++ and Python
|
|
71
120
|
* Provide two seperated class Url and Host for the purpose of clean code
|
|
72
121
|
* Also support [public_suffix_list](https://publicsuffix.org/list/public_suffix_list.dat) for known combinatorial suffix such as "ac.ir"
|
|
73
122
|
* Support unknown suffix like "google.comm" (it detect "comm" as suffix)
|
|
74
|
-
* Update public_suffix_list automatically before each build and deploy
|
|
123
|
+
* Update public_suffix_list automatically before each build and deploy
|
|
75
124
|
* Host properties:
|
|
76
125
|
* subdomain
|
|
77
126
|
* domain
|
|
@@ -86,54 +135,7 @@ Description-Content-Type: text/markdown
|
|
|
86
135
|
* query
|
|
87
136
|
* params
|
|
88
137
|
* fragment
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
## Setup
|
|
92
|
-
### C++:
|
|
93
|
-
|
|
94
|
-
#### build steps:
|
|
95
|
-
```sh
|
|
96
|
-
git clone https://github.com/mohammadraziei/liburlparser
|
|
97
|
-
mkdir -p build; cd build
|
|
98
|
-
cmake ..
|
|
99
|
-
# Build the project:
|
|
100
|
-
make
|
|
101
|
-
# [Optional] run tests:
|
|
102
|
-
make test
|
|
103
|
-
# [Optional] make documents:
|
|
104
|
-
make docs
|
|
105
|
-
# [Optional] Run examples:
|
|
106
|
-
./example
|
|
107
|
-
# Make install
|
|
108
|
-
sudo make install
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
### Python and Command Line:
|
|
114
|
-
Be aware that it required `python>=3.8`
|
|
115
|
-
#### Installation
|
|
116
|
-
###### pip by [pypi](https://pypi.org/project/liburlparser/)
|
|
117
|
-
```sh
|
|
118
|
-
pip install liburlparser
|
|
119
|
-
```
|
|
120
|
-
if you want to use psl.update to update the public suffix list, you must install the `online` version
|
|
121
|
-
```sh
|
|
122
|
-
pip install "liburlparser[online]"
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
Or
|
|
127
|
-
###### pip by [git](https://github.com/mohammadraziei/liburlparser)
|
|
128
|
-
```sh
|
|
129
|
-
pip install git+https://github.com/mohammadraziei/liburlparser
|
|
130
|
-
```
|
|
131
|
-
Or
|
|
132
|
-
###### manually
|
|
133
|
-
```sh
|
|
134
|
-
git clone https://github.com/mohammadraziei/liburlparser
|
|
135
|
-
pip install ./liburlparser
|
|
136
|
-
```
|
|
138
|
+
-->
|
|
137
139
|
|
|
138
140
|
## Usage
|
|
139
141
|
|
|
@@ -200,7 +202,7 @@ Host.extract_from_url("https://ee.aut.ac.ir/about") # from url
|
|
|
200
202
|
there is some examples in [examples](https://github.com/MohammadRaziei/liburlparser/tree/master/examples) folder
|
|
201
203
|
|
|
202
204
|
```c++
|
|
203
|
-
#include "
|
|
205
|
+
#include "urlparser.h"
|
|
204
206
|
...
|
|
205
207
|
/// for parsing url
|
|
206
208
|
TLD::Url url("https://ee.aut.ac.ir/about");
|
|
@@ -215,6 +217,56 @@ TLD::Host host = TLD::Host::fromUrl("https://ee.aut.ac.ir/about");
|
|
|
215
217
|
you can see all methods in python we can use in c++ very easily
|
|
216
218
|
|
|
217
219
|
|
|
220
|
+
|
|
221
|
+
## Installation
|
|
222
|
+
### C++:
|
|
223
|
+
|
|
224
|
+
#### build steps:
|
|
225
|
+
```sh
|
|
226
|
+
git clone https://github.com/mohammadraziei/liburlparser
|
|
227
|
+
mkdir -p build; cd build
|
|
228
|
+
cmake ..
|
|
229
|
+
# Build the project:
|
|
230
|
+
make
|
|
231
|
+
# [Optional] run tests:
|
|
232
|
+
make test
|
|
233
|
+
# [Optional] make documents:
|
|
234
|
+
make docs
|
|
235
|
+
# [Optional] Run examples:
|
|
236
|
+
./example
|
|
237
|
+
# Make install
|
|
238
|
+
sudo make install
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
### Python and Command Line:
|
|
244
|
+
Be aware that it required `python>=3.8`
|
|
245
|
+
#### Installation
|
|
246
|
+
###### pip by [pypi](https://pypi.org/project/liburlparser/)
|
|
247
|
+
```sh
|
|
248
|
+
pip install liburlparser
|
|
249
|
+
```
|
|
250
|
+
if you want to use psl.update to update the public suffix list, you must install the `online` version
|
|
251
|
+
```sh
|
|
252
|
+
pip install "liburlparser[online]"
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
Or
|
|
257
|
+
###### pip by [git](https://github.com/mohammadraziei/liburlparser)
|
|
258
|
+
```sh
|
|
259
|
+
pip install git+https://github.com/mohammadraziei/liburlparser
|
|
260
|
+
```
|
|
261
|
+
Or
|
|
262
|
+
###### manually
|
|
263
|
+
```sh
|
|
264
|
+
git clone https://github.com/mohammadraziei/liburlparser
|
|
265
|
+
pip install ./liburlparser
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
218
270
|
### Performance
|
|
219
271
|
|
|
220
272
|
|
|
@@ -250,14 +302,17 @@ The test was conducted on a file containing 1 million random urls (Mar. 13rd 202
|
|
|
250
302
|
Distributed under the MIT License. See [LICENSE](LICENSE) for more information.
|
|
251
303
|
|
|
252
304
|
|
|
305
|
+
## Stats
|
|
306
|
+
[](https://starchart.cc/mohammadraziei/liburlparser)
|
|
307
|
+
|
|
253
308
|
## Contact
|
|
254
309
|
|
|
255
310
|
<!-- Gal Ben David - gal@intsights.com -->
|
|
256
311
|
|
|
257
|
-
Project Link:
|
|
312
|
+
Project Link:
|
|
258
313
|
- [https://github.com/mohammadraziei/liburlparser](https://github.com/mohammadraziei/liburlparser)
|
|
259
314
|
- [https://pypi.org/project/liburlparser](https://pypi.org/project/liburlparser)
|
|
260
315
|
|
|
261
316
|
|
|
262
317
|
|
|
263
|
-
[license-shield]: https://img.shields.io/github/license/othneildrew/Best-README-Template.svg?style=flat-square
|
|
318
|
+
[license-shield]: https://img.shields.io/github/license/othneildrew/Best-README-Template.svg?style=flat-square
|
|
@@ -10,9 +10,29 @@
|
|
|
10
10
|
</h4>
|
|
11
11
|
</p>
|
|
12
12
|
|
|
13
|
-
](https://github.com/mohammadraziei/liburlparser "Go to GitHub repo")
|
|
14
|
+
[](https://github.com/mohammadraziei/liburlparser)
|
|
15
|
+
[](https://github.com/mohammadraziei/liburlparser)
|
|
16
|
+
|
|
17
|
+
[](https://pypi.org/project/liburlparser/)
|
|
18
|
+

|
|
19
|
+

|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
[](https://github.com/mohammadraziei/liburlparser/releases/)
|
|
23
|
+
[](#license)
|
|
24
|
+
[](https://github.com/mohammadraziei/liburlparser/issues)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
[](https://sonarcloud.io/summary/new_code?id=MohammadRaziei_liburlparser)
|
|
28
|
+
|
|
29
|
+
[](https://sonarcloud.io/summary/new_code?id=MohammadRaziei_liburlparser)
|
|
30
|
+
[](https://snyk.io/advisor/python/liburlparser)
|
|
31
|
+
|
|
32
|
+
[//]: # ([](https://mohammadraziei.github.io/liburlparser/))
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
16
36
|
<!--
|
|
17
37
|

|
|
18
38
|
[](https://pypi.org/project/PyDomainExtractor/)
|
|
@@ -38,13 +58,42 @@
|
|
|
38
58
|
|
|
39
59
|
## About The Project
|
|
40
60
|
|
|
61
|
+
**liburlparser** is a powerful domain extractor library written in C++ with Python bindings. It provides efficient URL parsing capabilities for both C++ and Python, making it a valuable tool for projects that involve working with web addresses.
|
|
62
|
+
|
|
41
63
|
### Features
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
Here are some key features of **liburlparser**:
|
|
67
|
+
|
|
68
|
+
1. **Multiple Language Support**:
|
|
69
|
+
- liburlparser can be used in multiple programming languages, including `Python`, `C++`, and `Shell`.
|
|
70
|
+
- It offers an intuitive interface that remains consistent across both C++ and Python.
|
|
71
|
+
|
|
72
|
+
2. **Clean Code Design**:
|
|
73
|
+
- The library provides two separate classes: `Url` and `Host`.
|
|
74
|
+
- This separation allows for cleaner and more organized code when dealing with URLs.
|
|
75
|
+
|
|
76
|
+
3. **Public Suffix List Support**:
|
|
77
|
+
- liburlparser supports known combinatorial suffixes (e.g., "ac.ir") using the public_suffix_list.
|
|
78
|
+
- It can also handle unknown suffixes (e.g., "comm" in "google.comm").
|
|
79
|
+
|
|
80
|
+
4. **Automatic Public Suffix List Updates**:
|
|
81
|
+
- Before each build and deployment, liburlparser updates the public_suffix_list automatically.
|
|
82
|
+
|
|
83
|
+
5. **Host Properties**:
|
|
84
|
+
- The `Host` class includes properties such as subdomain, domain, domain name, and suffix.
|
|
85
|
+
|
|
86
|
+
6. **URL Properties**:
|
|
87
|
+
- The `Url` class provides properties like protocol, userinfo, host (and all host properties), port, path, query parameters, and fragment.
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
<!--
|
|
42
91
|
* Multiple programming language supported such as `Python`, `C++` and `Shell`
|
|
43
92
|
* Intuitive interface and identical in C++ and Python
|
|
44
93
|
* Provide two seperated class Url and Host for the purpose of clean code
|
|
45
94
|
* Also support [public_suffix_list](https://publicsuffix.org/list/public_suffix_list.dat) for known combinatorial suffix such as "ac.ir"
|
|
46
95
|
* Support unknown suffix like "google.comm" (it detect "comm" as suffix)
|
|
47
|
-
* Update public_suffix_list automatically before each build and deploy
|
|
96
|
+
* Update public_suffix_list automatically before each build and deploy
|
|
48
97
|
* Host properties:
|
|
49
98
|
* subdomain
|
|
50
99
|
* domain
|
|
@@ -59,54 +108,7 @@
|
|
|
59
108
|
* query
|
|
60
109
|
* params
|
|
61
110
|
* fragment
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
## Setup
|
|
65
|
-
### C++:
|
|
66
|
-
|
|
67
|
-
#### build steps:
|
|
68
|
-
```sh
|
|
69
|
-
git clone https://github.com/mohammadraziei/liburlparser
|
|
70
|
-
mkdir -p build; cd build
|
|
71
|
-
cmake ..
|
|
72
|
-
# Build the project:
|
|
73
|
-
make
|
|
74
|
-
# [Optional] run tests:
|
|
75
|
-
make test
|
|
76
|
-
# [Optional] make documents:
|
|
77
|
-
make docs
|
|
78
|
-
# [Optional] Run examples:
|
|
79
|
-
./example
|
|
80
|
-
# Make install
|
|
81
|
-
sudo make install
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
### Python and Command Line:
|
|
87
|
-
Be aware that it required `python>=3.8`
|
|
88
|
-
#### Installation
|
|
89
|
-
###### pip by [pypi](https://pypi.org/project/liburlparser/)
|
|
90
|
-
```sh
|
|
91
|
-
pip install liburlparser
|
|
92
|
-
```
|
|
93
|
-
if you want to use psl.update to update the public suffix list, you must install the `online` version
|
|
94
|
-
```sh
|
|
95
|
-
pip install "liburlparser[online]"
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
Or
|
|
100
|
-
###### pip by [git](https://github.com/mohammadraziei/liburlparser)
|
|
101
|
-
```sh
|
|
102
|
-
pip install git+https://github.com/mohammadraziei/liburlparser
|
|
103
|
-
```
|
|
104
|
-
Or
|
|
105
|
-
###### manually
|
|
106
|
-
```sh
|
|
107
|
-
git clone https://github.com/mohammadraziei/liburlparser
|
|
108
|
-
pip install ./liburlparser
|
|
109
|
-
```
|
|
111
|
+
-->
|
|
110
112
|
|
|
111
113
|
## Usage
|
|
112
114
|
|
|
@@ -173,7 +175,7 @@ Host.extract_from_url("https://ee.aut.ac.ir/about") # from url
|
|
|
173
175
|
there is some examples in [examples](https://github.com/MohammadRaziei/liburlparser/tree/master/examples) folder
|
|
174
176
|
|
|
175
177
|
```c++
|
|
176
|
-
#include "
|
|
178
|
+
#include "urlparser.h"
|
|
177
179
|
...
|
|
178
180
|
/// for parsing url
|
|
179
181
|
TLD::Url url("https://ee.aut.ac.ir/about");
|
|
@@ -188,6 +190,56 @@ TLD::Host host = TLD::Host::fromUrl("https://ee.aut.ac.ir/about");
|
|
|
188
190
|
you can see all methods in python we can use in c++ very easily
|
|
189
191
|
|
|
190
192
|
|
|
193
|
+
|
|
194
|
+
## Installation
|
|
195
|
+
### C++:
|
|
196
|
+
|
|
197
|
+
#### build steps:
|
|
198
|
+
```sh
|
|
199
|
+
git clone https://github.com/mohammadraziei/liburlparser
|
|
200
|
+
mkdir -p build; cd build
|
|
201
|
+
cmake ..
|
|
202
|
+
# Build the project:
|
|
203
|
+
make
|
|
204
|
+
# [Optional] run tests:
|
|
205
|
+
make test
|
|
206
|
+
# [Optional] make documents:
|
|
207
|
+
make docs
|
|
208
|
+
# [Optional] Run examples:
|
|
209
|
+
./example
|
|
210
|
+
# Make install
|
|
211
|
+
sudo make install
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
### Python and Command Line:
|
|
217
|
+
Be aware that it required `python>=3.8`
|
|
218
|
+
#### Installation
|
|
219
|
+
###### pip by [pypi](https://pypi.org/project/liburlparser/)
|
|
220
|
+
```sh
|
|
221
|
+
pip install liburlparser
|
|
222
|
+
```
|
|
223
|
+
if you want to use psl.update to update the public suffix list, you must install the `online` version
|
|
224
|
+
```sh
|
|
225
|
+
pip install "liburlparser[online]"
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
Or
|
|
230
|
+
###### pip by [git](https://github.com/mohammadraziei/liburlparser)
|
|
231
|
+
```sh
|
|
232
|
+
pip install git+https://github.com/mohammadraziei/liburlparser
|
|
233
|
+
```
|
|
234
|
+
Or
|
|
235
|
+
###### manually
|
|
236
|
+
```sh
|
|
237
|
+
git clone https://github.com/mohammadraziei/liburlparser
|
|
238
|
+
pip install ./liburlparser
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
|
|
191
243
|
### Performance
|
|
192
244
|
|
|
193
245
|
|
|
@@ -223,14 +275,17 @@ The test was conducted on a file containing 1 million random urls (Mar. 13rd 202
|
|
|
223
275
|
Distributed under the MIT License. See [LICENSE](LICENSE) for more information.
|
|
224
276
|
|
|
225
277
|
|
|
278
|
+
## Stats
|
|
279
|
+
[](https://starchart.cc/mohammadraziei/liburlparser)
|
|
280
|
+
|
|
226
281
|
## Contact
|
|
227
282
|
|
|
228
283
|
<!-- Gal Ben David - gal@intsights.com -->
|
|
229
284
|
|
|
230
|
-
Project Link:
|
|
285
|
+
Project Link:
|
|
231
286
|
- [https://github.com/mohammadraziei/liburlparser](https://github.com/mohammadraziei/liburlparser)
|
|
232
287
|
- [https://pypi.org/project/liburlparser](https://pypi.org/project/liburlparser)
|
|
233
288
|
|
|
234
289
|
|
|
235
290
|
|
|
236
|
-
[license-shield]: https://img.shields.io/github/license/othneildrew/Best-README-Template.svg?style=flat-square
|
|
291
|
+
[license-shield]: https://img.shields.io/github/license/othneildrew/Best-README-Template.svg?style=flat-square
|
|
File without changes
|
|
@@ -6,7 +6,7 @@ build-backend = "scikit_build_core.build"
|
|
|
6
6
|
|
|
7
7
|
[project]
|
|
8
8
|
name = "liburlparser"
|
|
9
|
-
version = "1.
|
|
9
|
+
version = "1.5.0"
|
|
10
10
|
description = "Fastest Url parser in the world"
|
|
11
11
|
readme = "README.md"
|
|
12
12
|
authors = [
|
|
@@ -30,7 +30,7 @@ dependencies = [
|
|
|
30
30
|
]
|
|
31
31
|
|
|
32
32
|
[project.optional-dependencies]
|
|
33
|
-
test = ["pytest", "requests"]
|
|
33
|
+
test = ["pytest-xdist", "requests"]
|
|
34
34
|
online = ["requests"]
|
|
35
35
|
|
|
36
36
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by mohammad on 10/17/24.
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
#include <nanobind/nanobind.h>
|
|
6
|
+
|
|
7
|
+
#include <string>
|
|
8
|
+
|
|
9
|
+
#define STRINGIFY(x) #x
|
|
10
|
+
#define MACRO_STRINGIFY(x) STRINGIFY(x)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
NB_MODULE(NB_MODULE_NAME, m) {
|
|
14
|
+
#ifdef VERSION_INFO
|
|
15
|
+
m.attr("__version__") = MACRO_STRINGIFY(VERSION_INFO);
|
|
16
|
+
#else
|
|
17
|
+
m.attr("__version__") = "dev";
|
|
18
|
+
#endif
|
|
19
|
+
}
|
|
@@ -76,7 +76,7 @@ inline nb::dict extract(const std::string& host){
|
|
|
76
76
|
return host_to_dict_minimal(TLD::Host(host));
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
NB_MODULE(
|
|
79
|
+
NB_MODULE(NB_MODULE_NAME, m) {
|
|
80
80
|
m.doc() = R"pbdoc(
|
|
81
81
|
nanobind example plugin
|
|
82
82
|
-----------------------
|
|
@@ -150,9 +150,5 @@ NB_MODULE(_core, m) {
|
|
|
150
150
|
return std::string("<PSL : ") + (p.isLoaded() ? "loaded" : "not loaded") + ">";
|
|
151
151
|
});
|
|
152
152
|
|
|
153
|
-
|
|
154
|
-
m.attr("__version__") = MACRO_STRINGIFY(VERSION_INFO);
|
|
155
|
-
#else
|
|
156
|
-
m.attr("__version__") = "dev";
|
|
157
|
-
#endif
|
|
153
|
+
|
|
158
154
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
*
|
|
Binary file
|
|
Binary file
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
cmake_minimum_required(VERSION 3.12)
|
|
2
|
-
|
|
3
|
-
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ version selection")
|
|
4
|
-
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
5
|
-
|
|
6
|
-
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/modules")
|
|
10
|
-
include(PyProject)
|
|
11
|
-
message(STATUS "Project: ${PyProject_NAME}@v${PyProject_VERSION}")
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if(NOT CMAKE_BUILD_TYPE)
|
|
15
|
-
set(CMAKE_BUILD_TYPE Release)
|
|
16
|
-
endif()
|
|
17
|
-
|
|
18
|
-
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
|
|
19
|
-
|
|
20
|
-
#set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if(MSVC)
|
|
24
|
-
# Microsoft Visual Studio compiler
|
|
25
|
-
set(MSVC_FLAGS "/O2")
|
|
26
|
-
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${MSVC_FLAGS}")
|
|
27
|
-
elseif(CMAKE_COMPILER_IS_GNUCXX)
|
|
28
|
-
# GCC or Clang compiler
|
|
29
|
-
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
|
|
30
|
-
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|
31
|
-
# Linux
|
|
32
|
-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
|
|
33
|
-
else()
|
|
34
|
-
# Other OS
|
|
35
|
-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=generic")
|
|
36
|
-
endif()
|
|
37
|
-
endif()
|
|
38
|
-
|
|
39
|
-
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}" CACHE STRING "" FORCE)
|
|
40
|
-
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING "" FORCE)
|
|
41
|
-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "" FORCE)
|
|
42
|
-
|
|
43
|
-
project(${PyProject_NAME} LANGUAGES CXX)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
# Download the public suffix list file from the internet
|
|
47
|
-
set(PUBLIC_SUFFIX_LIST_URL "https://publicsuffix.org/list/public_suffix_list.dat")
|
|
48
|
-
set(PUBLIC_SUFFIX_LIST_DAT "public_suffix_list.dat")
|
|
49
|
-
if(NOT DEFINED SKBUILD)
|
|
50
|
-
set(PUBLIC_SUFFIX_LIST_DAT "${CMAKE_CURRENT_BINARY_DIR}/${PUBLIC_SUFFIX_LIST_DAT}")
|
|
51
|
-
endif()
|
|
52
|
-
|
|
53
|
-
# Download the public suffix list file from the internet if not already exists
|
|
54
|
-
if(EXISTS "${PUBLIC_SUFFIX_LIST_DAT}")
|
|
55
|
-
message(STATUS "[DATA] ${PUBLIC_SUFFIX_LIST_DAT} is found.")
|
|
56
|
-
else()
|
|
57
|
-
message(WARNING "[DATA] ${PUBLIC_SUFFIX_LIST_DAT} is not found. Trying to download it.")
|
|
58
|
-
file(DOWNLOAD "${PUBLIC_SUFFIX_LIST_URL}" ${PUBLIC_SUFFIX_LIST_DAT})
|
|
59
|
-
if(EXISTS "${PUBLIC_SUFFIX_LIST_DAT}")
|
|
60
|
-
message(STATUS "[DATA] ${PUBLIC_SUFFIX_LIST_DAT} is downloaded.")
|
|
61
|
-
else()
|
|
62
|
-
message(FATAL_ERROR "[DATA] Failed to download ${PUBLIC_SUFFIX_LIST_DAT}.")
|
|
63
|
-
endif()
|
|
64
|
-
endif()
|
|
65
|
-
|
|
66
|
-
file(GLOB SOURCES ${PROJECT_SOURCE_DIR}/src/*.cpp)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if(DEFINED SKBUILD)
|
|
70
|
-
# Try to import all Python components potentially needed by nanobind
|
|
71
|
-
find_package(Python 3.8
|
|
72
|
-
REQUIRED COMPONENTS Interpreter Development.Module
|
|
73
|
-
OPTIONAL_COMPONENTS Development.SABIModule)
|
|
74
|
-
|
|
75
|
-
# Import nanobind through CMake's find_package mechanism
|
|
76
|
-
find_package(nanobind CONFIG REQUIRED)
|
|
77
|
-
|
|
78
|
-
# We are now ready to compile the actual extension module
|
|
79
|
-
nanobind_add_module(
|
|
80
|
-
# Name of the extension
|
|
81
|
-
_core
|
|
82
|
-
|
|
83
|
-
# Target the stable ABI for Python 3.12+, which reduces
|
|
84
|
-
# the number of binary wheels that must be built. This
|
|
85
|
-
# does nothing on older Python versions
|
|
86
|
-
STABLE_ABI
|
|
87
|
-
|
|
88
|
-
# Build libnanobind statically and merge it into the
|
|
89
|
-
# extension (which itself remains a shared library)
|
|
90
|
-
#
|
|
91
|
-
# If your project builds multiple extensions, you can
|
|
92
|
-
# replace this flag by NB_SHARED to conserve space by
|
|
93
|
-
# reusing a shared libnanobind across libraries
|
|
94
|
-
NB_STATIC
|
|
95
|
-
|
|
96
|
-
# Source code goes here
|
|
97
|
-
src/binding/main.cpp
|
|
98
|
-
)
|
|
99
|
-
|
|
100
|
-
target_sources(_core PRIVATE ${SOURCES})
|
|
101
|
-
target_include_directories(_core PRIVATE include src)
|
|
102
|
-
target_compile_definitions(_core PRIVATE VERSION_INFO=${SKBUILD_PROJECT_VERSION})
|
|
103
|
-
target_compile_definitions(_core PRIVATE
|
|
104
|
-
DONT_INIT_PSL
|
|
105
|
-
PUBLIC_SUFFIX_LIST_URL="${PUBLIC_SUFFIX_LIST_URL}"
|
|
106
|
-
PUBLIC_SUFFIX_LIST_DAT="${PUBLIC_SUFFIX_LIST_DAT}"
|
|
107
|
-
)
|
|
108
|
-
|
|
109
|
-
install(TARGETS _core
|
|
110
|
-
CONFIGURATIONS Release
|
|
111
|
-
LIBRARY DESTINATION
|
|
112
|
-
${SKBUILD_PROJECT_NAME})
|
|
113
|
-
install (FILES ${PUBLIC_SUFFIX_LIST_DAT}
|
|
114
|
-
DESTINATION ${SKBUILD_PROJECT_NAME})
|
|
115
|
-
|
|
116
|
-
RETURN()
|
|
117
|
-
endif()
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
add_library(urlparser SHARED ${SOURCES})
|
|
121
|
-
add_library(url::base ALIAS urlparser)
|
|
122
|
-
target_compile_definitions(urlparser PRIVATE
|
|
123
|
-
PUBLIC_SUFFIX_LIST_DAT="${PUBLIC_SUFFIX_LIST_DAT}"
|
|
124
|
-
)
|
|
125
|
-
|
|
126
|
-
target_include_directories(urlparser
|
|
127
|
-
PUBLIC
|
|
128
|
-
${PROJECT_SOURCE_DIR}/include
|
|
129
|
-
PRIVATE
|
|
130
|
-
${PROJECT_SOURCE_DIR}/src)
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
add_executable(example examples/main.cpp)
|
|
134
|
-
target_link_libraries(example PRIVATE url::base)
|
|
135
|
-
|
|
136
|
-
install(TARGETS urlparser
|
|
137
|
-
LIBRARY DESTINATION lib
|
|
138
|
-
ARCHIVE DESTINATION lib
|
|
139
|
-
INCLUDES DESTINATION include
|
|
140
|
-
)
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
enable_testing()
|
|
145
|
-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party/googletest)
|
|
146
|
-
file(GLOB TEST_SOURCES ${PROJECT_SOURCE_DIR}/tests/cpp/*.cpp)
|
|
147
|
-
|
|
148
|
-
add_executable(test_liburlparser ${TEST_SOURCES})
|
|
149
|
-
target_link_libraries(test_liburlparser PRIVATE url::base gtest gtest_main pthread)
|
|
150
|
-
target_include_directories(test_liburlparser PRIVATE ${PROJECT_SOURCE_DIR}/tests/cpp)
|
|
151
|
-
add_test(NAME unitTests COMMAND test_liburlparser)
|
|
152
|
-
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} -V DEPENDS test_liburlparser)
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
# Find Doxygen package
|
|
157
|
-
find_package(Doxygen)
|
|
158
|
-
message(STATUS "Doxygen_FOUND : ${Doxygen_FOUND}")
|
|
159
|
-
# Find Doxygen package
|
|
160
|
-
if (Doxygen_FOUND)
|
|
161
|
-
# Configure Doxyfile.in template
|
|
162
|
-
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
|
|
163
|
-
|
|
164
|
-
# Add target to generate documentation
|
|
165
|
-
add_custom_target(docs
|
|
166
|
-
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
|
|
167
|
-
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
|
168
|
-
COMMENT "Generating Doxygen documentation"
|
|
169
|
-
VERBATIM
|
|
170
|
-
)
|
|
171
|
-
endif ()
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|