-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
[draft/RFC] Make tool ports first class citizens #31748
Conversation
Drive by fix inverted sourceforge_args test. Drive by fix missing scripts in ports.cmake.
…e it to avoid needing to do the 'temporarily editable hack'.
…ore we didn't have a version lock.
Yes (have to check the rest of the PR) |
@@ -41,7 +41,8 @@ if(CMAKE_HOST_WIN32) | |||
set(PYTHON3 "${MSYS_ROOT}/mingw64/bin/python3.exe") | |||
vcpkg_execute_required_process(COMMAND ${PYTHON3} -c "import site; print(site.getsitepackages()[0])" WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR} LOGNAME prerequisites-pypath-${TARGET_TRIPLET} OUTPUT_VARIABLE PYTHON_LIB_PATH) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this also generating python bindings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. The tensorflow ports are broken for windows. #30582 (comment)
@@ -17,7 +17,7 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS | |||
|
|||
set(ADDITIONAL_OPTIONS "") | |||
if(PYTHON_BINDINGS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did i miss that in the python bindings list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The python bindings list was not exhaustive. Will investigate them as separate changes before this one lands.
# This function is called through find_path or find_program to validate that the program works | ||
function(z_vcpkg_try_find_acquire_tool_validator result candidate) | ||
vcpkg_execute_in_download_mode( | ||
COMMAND ${candidate} $CACHE{z_vcpkg_try_find_acquire_tool_validator_VERSION_COMMAND} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you use $CACHE
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because find_program
passes no context information to the validator, we have to route things through "globals". Since these need to come from the cache, I said $CACHE
to make that excruciatingly clear.
Would you prefer I just remove $CACHE
or do you have better suggestions on how to smuggle this information into the validator?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you prefer I just remove $CACHE
Just remove CACHE. I don't see a reason to actually use that.
passes no context information to the validator, we have to route things through "globals"
The context is scoped through the call site. (as all function calls are in cmake)
Example:
cmake_minimum_required(VERSION 3.25)
function(git_validator result item)
message(STATUS "Scoped variable:${var}")
set(${result} TRUE PARENT_SCOPE)
endfunction()
set(var "Hello from the validator!" )
find_program(GIT NAMES git VALIDATOR git_validator)
Output:
E:\vcpkg_folders>cmake -P find_git.cmake
-- Scoped variable:Hello from the validator!
so no need to smuggle anything.
# Given VERSION_PREFIX is "my fancy program" and program_version_output is | ||
# "my fancy program 1.2.0", extract the dots-numeric part | ||
if(DEFINED CACHE{z_vcpkg_try_find_acquire_tool_validator_VERSION_PREFIX}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we pass a VERSION_REGEX
instead? (or even a VERSION_VALIDATOR
?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't necessarily object to VERSION_REGEX
; I just looked at what the existing tools we care about do, and for them prefix was sufficient. I'm not sure how to document what the resulting regex interface would look like; how does the regex tell us where the version part is located?
CMake regex' inability to assert positions at line boundaries does not help :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then version VERSION_VALIDATOR
it is ;). Yeah i did not think about CMAKE_MATCH_X
being needed for the implementation
@@ -20,7 +20,8 @@ set(supported_on_unix ON) | |||
set(version_command --version) | |||
set(extra_search_args EXACT_VERSION_MATCH) | |||
|
|||
vcpkg_find_acquire_program(PYTHON3) | |||
include("${CMAKE_CURRENT_LIST_DIR}/../vcpkg-tool-python3-interpreter/vcpkg-port-config.cmake") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
another include. Still necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one was not necessary, good point.
@@ -0,0 +1,10 @@ | |||
{ | |||
"name": "vcpkg-tool-python3-interpreter", | |||
"version": "3.0.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"version": "3.0.0", | |
"version": "3", |
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed.
"dependencies": [ | ||
"vcpkg-find-acquire-tool" | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add a feature which will force the usage of the python3 port ? Or would you consider that a antipattern?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I consider that an antipattern. This tool port is only for "I need a python to run a python script and I do not otherwise care about the python ecosystem"; if you otherwise care about that you need to depend on python.
Yes, find_package(PYTHON3
does not make this clear :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tool port is only for "I need a python to run a python script and I do not otherwise care about the python ecosystem"; if you otherwise care about that you need to depend on python.
But there should be a rule how the python port exposes its binary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But there should be a rule how the python port exposes its binary.
I don't think the existing tool ports are consistent enough for that; not every tool refers to a single individual binary. Guidelines are just guidelines, if a tool port needs something different, that's going to be reasonable to do.
@@ -67,7 +67,7 @@ vcpkg_download_distfile(GNI_TO_CMAKE_PY | |||
) | |||
|
|||
# Generate CMake files from GN / GNI files | |||
vcpkg_find_acquire_program(PYTHON3) | |||
vcpkg_find_acquire_python3_interpreter(PYTHON3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vcpkg_find_acquire_python3_interpreter(PYTHON3)
Is kind of annoying and long. can we get something like:
vcpkg_get(<X>)
and make that call vcpkg_find_acquire_<X>(X)
Having:
vcpkg_find_acquire_python3_interpreter(PYTHON3) # may need to be added to path
vcpkg_find_acquire_meson(MESON)
vcpkg_find_acquire_flex(FLEX) # may need to be added to path
is kind of verbose compared to something like
vcpkg_get(INTERPRETER python3 ADD_TO_PATH)
vcpkg_get(PYSCRIPT meson)
vcpkg_get(TOOL flex ADD_TO_PATH)
(the explicit dep in the manifest will still be verbose.)
|
Main points for discussion in my eyes:
How is
I am ok with that but explicitly calling out to
maybe add a
it is cmake_parse_arguments(PARSE_ARGV 1 arg "" "" ""). Also 0 is OUTPUT var ?
I am for the chaining/former approach since otherwise another helper port has implementation details of the upstream port. Depending on
Not using CACHE entries means disallowing overwrites from the triplet. |
string(FIND | ||
"${program_version_output}" | ||
"$CACHE{z_vcpkg_try_find_acquire_tool_validator_VERSION_PREFIX}" prefix_offset) | ||
# If there's no matching prefix, this isn't even the program we're looking for, so bail |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# If there's no matching prefix, this isn't even the program we're looking for, so bail | |
# If there's no matching prefix, this isn't even the program we're looking for, so fail |
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did mean bail but I agree fail is probably more universally understandable; changed.
Definitely yes! IMO we should not build things like LLVM, Nodejs or Python from source when used as a tool. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has it been considered to just outright drop Windows x86 32Bit support for (developer) tools? AFAICT there isn't any Windows 32Bit version with (extended) support left.
if(is64_bit) | ||
vcpkg_find_acquire_tool( | ||
OUT_TOOL_PATH out_var_value | ||
OUT_TOOL_ACQUIRED tool_acquired | ||
OUT_EXTRACTED_ROOT out_extract_root | ||
TOOL_NAME python | ||
VERSION ${program_version} | ||
DOWNLOAD_FILENAME "python-${program_version}-embed-win32.zip" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logic error: if (is64_bit)
=> embed-win32.zip
The branches need to be inverted.
That goes into the direction of
That will work independent of the approach.
With python2 there is already precedence. But i think it will rather be the exception than the rule and stuff will be handled like CMake. |
Q: How are tool ports different than e.g. atlmfc ? A: atlmfc is always a system provided thing that the toolchain makes available by default; there is no information that needs to be conveyed into a build system to turn on its use. |
@dg0yt I don't think we're opposed to the concept of asking for a version here; we're just changing enough things with this proposal and that opens a whole can of worms with negotiation etc. that I don't want to hold the rest for. That's why I'm saying "not right now, but not necessarily opposed to the idea". |
Hm, I thought about the atlmfc pattern when I proposed the VSCLANG tool.
We depend on a significant set of such tools which are not yet sufficiently reflected: autoconf, automake, libtool, ... This is an issue because it leads to poor error reporting. (I know that ports should print there requirements, but this leads to a lot of redundant and inconsistent information.) |
So where do we stand here? I would like to see this move forward somehow to unblock a few PRs of mine ;) |
PING |
set(download_sha512 2a1e539ed628c0cca5935d24d22cf3a7165f5c80e12a4003ac184deae6a6d0aa31f582f3e8257b0730adfc09aeec3a0e62f4732e658c312d5382170bcd8c94d8) | ||
if(CMAKE_HOST_WIN32) | ||
set(download_urls "https://dl.google.com/go/go${tool_subdirectory}.zip") | ||
set(download_filename "go${tool_subdirectory}.zip") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: tool_subdirectory
and paths_to_search
should also be under if(CMAKE_HOST_WIN32)
. The latter must also be quoted.
@@ -2,8 +2,10 @@ set(program_name nuget) | |||
set(tool_subdirectory "5.11.0") | |||
set(paths_to_search "${DOWNLOADS}/tools/nuget-${tool_subdirectory}-windows") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this should also be under if(CMAKE_HOST_WIN32)
vcpkg_list(APPEND installed_pythons ${more_maybe_pythons}) | ||
endforeach() | ||
|
||
if(is64_bit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to have arm64 check, too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree but for purposes of this PR I don't want to expand the feature set beyond what vcpkg_find_acquire_program
does today.
endif() | ||
|
||
if(tool_acquired) | ||
file(REMOVE "${out_extract_root}/python310._pth") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there should be a comment about why this is needed in vcpkg (probably not in this PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree but I don't know. This is copy pasta from vcpkg_find_acquire_program I think.
"dependencies": [ | ||
{ | ||
"name": "vcpkg-tool-python3-interpreter", | ||
"host": true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency, we should either remove host
from dependencies from tool ports, or add them everywhere else (vcpkg-tool-python3-interpreter
etc).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vcpkg-tool-python3-interpreter
should probably be marked with "supports": "native"
then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It it already marked
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll ask maintainers. I have a mild preference for removing it when "supports":"native"
just by virtue of being shorter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FTR supports
can be overridden at the command line, or restrictions can be removed in future revisions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, this is a reason to keep it as it is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ras0219-msft argues that 'not host:true' is more correct in the --allow-unsupported
universe, because in, for example:
include("${CMAKE_CURRENT_LIST_DIR}/../vcpkg-find-acquire-tool/vcpkg-port-config.cmake")
this means the selected triplet for the dependency needs to match the selected triplet of the port.
Poll: We want host:true
even when supports:native
?
@JavierMatosD No.
@ras0219-msft No. (Strongly opposed to host:true.)
@BillyONeal @vicroms I'm convinced by @ras0219-msft
@data-queue No.
@@ -18,7 +18,7 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS | |||
"crypto" LIBXSLT_WITH_CRYPTO | |||
) | |||
if("python" IN_LIST FEATURES) | |||
vcpkg_find_acquire_program(PYTHON3) | |||
vcpkg_find_acquire_python3_interpreter(PYTHON3) | |||
list(APPEND FEATURE_OPTIONS "-DPYTHON_EXECUTABLE=${PYTHON3}") | |||
list(APPEND FEATURE_OPTIONS_RELEASE "-DLIBXSLT_PYTHON_INSTALL_DIR=${CURRENT_PACKAGES_DIR}/lib/site-packages") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks wrong. Should probably be lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages
.
And the port should depend on python3
package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should move everything to lib/site-packages
or tools/python3/lib/site-packages
. There is no need to hardcode the python version. But that is another PR in my eyes.
Soo, since the Perl update in #33854 got green-lit, can we maybe agree to update some other rarely used / unlikely to break things like Go while waiting for this? |
If the change is extremely unlikely to be breaking I think updates to Notably, #33854 required no edits to |
…unctions. This updates the list of helper port scripts in ports.cmake to ensure it has every file in scripts/cmake, and changes the caller to conditionally call the function rather than conditionally include. This was extracted from microsoft#31748 but I'm not sure we want to do it.
This is a continuation of the work started in microsoft#31748 . There I tried to boil the ocean of all tools at the same time which turned into something unreviewable. Instead, this adds only python and meson, and a first caller of each.
I think vcpkg should provide a mechanism to globally set the tool version to be used, and each port can individually specify the tool version it needs, so that when a port needs a higher version of tool which not exists in vcpkg, it only needs to add this version of tool as a port and specify the port to use it, which won't affect any of the older ports. |
Is there any update on this? |
Closing this as there has been no action in more than 4 months. Doesn't mean we are giving up on tool ports, but I don't think the comments here are going to be useful in a subsequent review |
There are several outstanding efforts trying to introduce dependencies from vcpkg to various host support tools, or that wish to provide tools.
vcpkg
has no less than 5 different ways to get these dependencies:vcpkg fetch
vcpkgTools.xml
vcpkg_find_acquire_program
None of these do everything we want, see the following support matrix:
This introduces a new helper port,
vcpkg-find-acquire-tool
, which exposes the guts ofvcpkg_find_acquire_program
for tool port consumption. Moreover, it uses the newVALIDATOR
feature offind_program
to close the gap between whatvcpkg_find_acquire_program
was able to do andvcpkg fetch
is able to do.Remaining work necessary to complete this:
INTERPRETER
and teachvcpkg-tool-meson
to use this infrastructure.vcpkg-tool-swig
andvcpkg-tool-doxygen
.Work currently blocked by this:
vcpkg_find_acquire_program(VSCLANG)
)Outstanding guidelines notes (to be added to based on other maintainers' comments):
VCPKG_FORCE_SYSTEM_BINARIES
; we believe that setting is poorly designed and will deprecate use of that setting going forward. IntroducingVCPKG_FORCE_SYSTEM_<ToolName>
might make sense.vcpkg-tool-meson
andvcpkg-tool-ninja
break this rule by trying to influence whatvcpkg_find_acquire_program
does.vcpkg-port-config.cmake
, they must instead declare a function that does the actual work.vcpkg-port-config.cmake
files in their ownvcpkg-port.config.cmake
files to ensure their functions are available.Ctrl+P
et al.cmake_parse_arguments(PARSE_ARGV arg 1 "" "" "")
include_guard(GLOBAL)
portfile.cmake
to make things fail early.vcpkg-port-config.cmake
files in their ownvcpkg-port-config.cmake
file.Reviewing individual commits highly recommended.