Repository navigation
fix(nodeenv): escape glob characters in prebuilt paths - #447
Conversation
ekalinin
left a comment
There was a problem hiding this comment.
Thanks for the patch! Two things before merge.
-
glob.escapefixesproj[1]/env, but the escaped path still goes through glob matching:proj[1]becomesproj[[]1], so glob still lists the directory that contains it and matches the entries itself. That leaves cases that fail with the sameValueError:- on a case-insensitive filesystem (macOS, Cygwin),
nodeenv --prebuilt PROJ[1]/envwhen the directory on disk isproj[1]: the match is case-sensitive, so it finds nothing, while the same path without brackets works; - when the directory that contains
proj[1]can be entered but not listed (mode 0311 or 0711), glob swallows thePermissionErrorand returns[]; node_versionis still not escaped, and a version such as18.0.0+build[1]with a custom mirror passes the version check.
The env path doesn't need to be in the pattern at all. Python 3.10 is the minimum now, so
root_dircan take it:src_folder_tpl = glob.escape('node-v%s-' % node_version) + '*' src_folder, = glob.glob(src_folder_tpl, root_dir=src_dir) copytree(join(src_dir, src_folder), dest, True)
The
-after the version also stops the glob from matchingnode-v18.1.10-linux-x64when installing 18.1.1, or a source treenode-v18.1.1left insrc/(the second case in #443). Both fail now withtoo many values to unpack. I checked all of these cases on macOS: the current pattern finds no folder or several, this one finds exactly one. If you take the-too, please mention it in theCHANGESentry. - on a case-insensitive filesystem (macOS, Cygwin),
-
The test repeats the
is_WIN/is_CYGWINbranching fromcopy_node_from_prebuilt. The bug doesn't depend on the platform, so patching both toFalse, astest_download_node_src_tar_keeps_data_filterdoes, keeps the test short and doesn't tie it to that logic. Of the nine cases,plain,path with spaces,café,proj[andproj]pass on master as well (a[without a closing]is a literal for fnmatch), so onlyproj[1],proj*andproj?cover #441 and the rest can go. With the-change, a case withnode-v18.1.10-...ornode-v18.1.1next to the archive folder would cover it. I tried such tests: they fail on master and pass with the change above.
|
Please rebase on master. |
7c7d74a to
06f9071
Compare
|
Addressed the requested changes and rebased onto master. Could you take another look? |
Prebuilt installs treated destination paths and versions as glob patterns. Match archive names under a literal source directory and preserve the version boundary.
Fixes #441
tox -e py314passes: tests and flake8CHANGEShas an unreleased entryREADME.rst: no documentation change neededtype(scope): subject