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

[python2] no absolute paths #22329

Merged
merged 2 commits into from
Mar 2, 2022
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
52 changes: 52 additions & 0 deletions ports/python2/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,62 @@ else()
)

vcpkg_install_make()
vcpkg_fixup_pkgconfig()

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include" "${CURRENT_PACKAGES_DIR}/debug/share")
endif()

if (NOT VCPKG_TARGET_IS_WINDOWS)
foreach(lib_suffix IN ITEMS "" "/debug")
set(python_config_file "${CURRENT_PACKAGES_DIR}${lib_suffix}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/_sysconfigdata.py")
if(NOT EXISTS "${python_config_file}")
continue()
endif()

file(READ "${python_config_file}" contents)

string(PREPEND contents "import os\n_base = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))\n")
# make contents a list of lines
string(REPLACE ";" "\\;" old_contents "${contents}")
strega-nil-ms marked this conversation as resolved.
Show resolved Hide resolved
string(REGEX REPLACE "\r?\n" ";" old_contents "${contents}")

set(new_contents "")
foreach(line IN LISTS old_contents)
if(line MATCHES "\"")
string(REGEX REPLACE
"${CURRENT_PACKAGES_DIR}|${CURRENT_INSTALLED_DIR}"
"\" + _base + \""
line
"${line}"
)
string(REGEX REPLACE
"\"[^\"]*${CURRENT_BUILDTREES_DIR}[^\"]*\""
"''"
line
"${line}"
)
else()
string(REGEX REPLACE
"${CURRENT_PACKAGES_DIR}|${CURRENT_INSTALLED_DIR}"
"' + _base + '"
line
"${line}"
)
string(REGEX REPLACE
"'[^']*${CURRENT_BUILDTREES_DIR}[^']*'"
"''"
line
"${line}"
)
endif()
list(APPEND new_contents "${line}")
endforeach()

list(JOIN new_contents "\n" contents)
file(WRITE "${python_config_file}" "${contents}")
endforeach()
endif()

# Handle copyright
file(COPY ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/python${PYTHON_VERSION_MAJOR})
file(RENAME ${CURRENT_PACKAGES_DIR}/share/python${PYTHON_VERSION_MAJOR}/LICENSE ${CURRENT_PACKAGES_DIR}/share/python${PYTHON_VERSION_MAJOR}/copyright)
2 changes: 1 addition & 1 deletion ports/python2/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "python2",
"version": "2.7.18",
"port-version": 2,
"port-version": 3,
"description": "The Python programming language as an embeddable library",
"homepage": "https://www.python.org",
"license": "Python-2.0"
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -5546,7 +5546,7 @@
},
"python2": {
"baseline": "2.7.18",
"port-version": 2
"port-version": 3
},
"python3": {
"baseline": "3.10.1",
Expand Down
5 changes: 5 additions & 0 deletions versions/p-/python2.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "2a9fb7f96d762e213e9901452492aee00f6fe049",
"version": "2.7.18",
"port-version": 3
},
{
"git-tree": "fc1f7aaa8a2312a56ce7dc1324c2eaf608a7a331",
"version": "2.7.18",
Expand Down