From bda5fc772e3db91c7660c7bb2296440a347fe402 Mon Sep 17 00:00:00 2001 From: OshriAsulin <114335827+OshriAsulin@users.noreply.github.com> Date: Sun, 30 Jul 2023 10:21:13 +0200 Subject: [PATCH] fix: ignore pip install .whl file (#142) Continue of #140 Close #119 I added a change for ignore commands that end with `.whl`, and I also added an example to real-examples.yaml --------- Co-authored-by: Baruch Odem Co-authored-by: Baruch Odem (Rothkoff) --- src/content/registry/python.js | 5 + src/content/registry/python.test.js | 1 + .../real-examples/real-examples-results.yaml | 117 +++++++++++++++--- tests/real-examples/real-examples.yaml | 4 + 4 files changed, 110 insertions(+), 17 deletions(-) diff --git a/src/content/registry/python.js b/src/content/registry/python.js index f0b7b1e..2224642 100644 --- a/src/content/registry/python.js +++ b/src/content/registry/python.js @@ -90,6 +90,11 @@ const handleArgument = (argument, restCommandWords) => { const baseCommandMatch = (line) => line.match(/pip3? +install/); const packageWordParse = (word) => { + if (word.endsWith('.whl')) { + console.debug('Ignoring package with ".whl":', word); + return null; + } + const match = word.match(packageArea); if (!match) return null; diff --git a/src/content/registry/python.test.js b/src/content/registry/python.test.js index 2aa9168..1481130 100644 --- a/src/content/registry/python.test.js +++ b/src/content/registry/python.test.js @@ -17,6 +17,7 @@ describe(parseCommand.name, () => { 'install numpy‑1.9.2+mkl‑cp34‑none‑win_amd64.whl', 'install MySQL_python==', // Although this is a valid package name, it's not a valid command 'install -r requirements.txt', + 'install scipy-0.16.1-cp27-none-win_amd64.whl', ]; const createCommand = (packageManager) => commands.map((command) => `${packageManager} ${command}`); diff --git a/tests/real-examples/real-examples-results.yaml b/tests/real-examples/real-examples-results.yaml index 6b7b11f..fb9c7d6 100644 --- a/tests/real-examples/real-examples-results.yaml +++ b/tests/real-examples/real-examples-results.yaml @@ -1983,11 +1983,6 @@ https://stackoverflow.com/questions/26575587: type: pypi name: pip - - range: |- - pip install scipy-0.16.1-cp27-none-win_amd64.whl - - type: pypi - name: scipy-0.16.1-cp27-none-win_amd64.whl - range: |- $ sudo apt-get install libatlas-base-dev gfortran $ sudo pip3 install scipy @@ -2009,28 +2004,116 @@ https://stackoverflow.com/questions/26575587: type: pypi name: scipy - range: |- - pip install FileName.whl + $ sudo pip install scipy + + type: pypi + name: scipy + - range: >- + python -m pip install --user numpy scipy matplotlib ipython + jupyter pandas sympy nose + + + type: pypi + name: numpy + - range: >- + python -m pip install --user numpy scipy matplotlib ipython + jupyter pandas sympy nose + + + type: pypi + name: scipy + - range: >- + python -m pip install --user numpy scipy matplotlib ipython + jupyter pandas sympy nose + + + type: pypi + name: matplotlib + - range: >- + python -m pip install --user numpy scipy matplotlib ipython + jupyter pandas sympy nose + + + type: pypi + name: ipython + - range: >- + python -m pip install --user numpy scipy matplotlib ipython + jupyter pandas sympy nose + type: pypi - name: FileName.whl - - range: pip install scipy-0.15.1-cp33-none-win_amd64.whl.whl + name: jupyter + - range: >- + python -m pip install --user numpy scipy matplotlib ipython + jupyter pandas sympy nose + + + type: pypi + name: pandas + - range: >- + python -m pip install --user numpy scipy matplotlib ipython + jupyter pandas sympy nose + + type: pypi - name: scipy-0.15.1-cp33-none-win_amd64.whl.whl + name: sympy + - range: >- + python -m pip install --user numpy scipy matplotlib ipython + jupyter pandas sympy nose + + + type: pypi + name: nose +https://stackoverflow.com/a/33984261: + comment: should Ignore this .whl as a package + post: answer + registry: pypi + results: + - range: >- + https://pypi.python.org/pypi/scipy + type: pypi + name: scipy - range: |- - $ sudo pip install scipy + pip install scipy type: pypi name: scipy - range: |- - - @echo off - C:\Python36\python.exe -m pip -V - C:\Python36\python.exe -m pip install scipy-0.19.1-cp36-cp36m-win32.whl - C:\Python36\python.exe -m pip list - pause + pip install --upgrade pip type: pypi - name: scipy-0.19.1-cp36-cp36m-win32.whl + name: pip + - range: |- + python3 -m pip install --upgrade pip + + type: pypi + name: pip + - range: |- + $ sudo apt-get install libatlas-base-dev gfortran + $ sudo pip3 install scipy + + type: pypi + name: scipy + - range: pip install scipy + type: pypi + name: scipy + - range: |- + brew install gcc + pip install scipy + + type: pypi + name: scipy + - range: |- + pip install scipy + + type: pypi + name: scipy + - range: |- + $ sudo pip install scipy + + type: pypi + name: scipy - range: >- python -m pip install --user numpy scipy matplotlib ipython jupyter pandas sympy nose diff --git a/tests/real-examples/real-examples.yaml b/tests/real-examples/real-examples.yaml index 37dcd8d..583af67 100644 --- a/tests/real-examples/real-examples.yaml +++ b/tests/real-examples/real-examples.yaml @@ -97,6 +97,10 @@ links: comment: pip3 install command post: answer registry: pypi + https://stackoverflow.com/a/33984261: + comment: should Ignore this .whl as a package + post: answer + registry: pypi https://stackoverflow.com/a/27709931: comment: go get standard library