Compare commits

..

8 Commits

Author SHA1 Message Date
David Verdeguer
068ef74bd6 Test on all os 2020-10-01 11:26:53 +02:00
David Verdeguer
afde6a46b1 Test 2020-09-29 17:12:41 +02:00
David Verdeguer
5e2245cc23 Add x permission to the test scripts 2020-09-29 10:06:06 +02:00
David Verdeguer
67ddca1d9c Add workflow for testing python setup 2020-09-29 09:57:29 +02:00
Rasmus Wriedt Larsen
18312707fe Explain get_extractor_version for python setup scripts 2020-09-25 12:07:22 +02:00
David Verdeguer
5419fcd735 Improve warning message 2020-09-25 11:28:57 +02:00
Rasmus Wriedt Larsen
dffce9945c Minor fixes to python installation scripts based on code review 2020-09-24 15:43:34 +02:00
Rasmus Wriedt Larsen
6645c550ef Apply suggestions from code review
Co-authored-by: Marco Gario  <marcogario@github.com>
2020-09-24 15:36:00 +02:00
39 changed files with 495 additions and 14 deletions

64
.github/workflows/python-deps.yml vendored Normal file
View File

@@ -0,0 +1,64 @@
name: Test Python Package Installation
on:
push:
pull_request:
jobs:
test-setup-python-scripts:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest,windows-latest,macos-latest]
include:
- test_dir: python-setup/tests/pipenv/requests-2
test_script: $GITHUB_WORKSPACE/python-setup/tests/check_requests_123.sh 2
- test_dir: python-setup/tests/pipenv/requests-3
test_script: $GITHUB_WORKSPACE/python-setup/tests/check_requests_123.sh 3
- test_dir: python-setup/tests/poetry/requests-2
test_script: $GITHUB_WORKSPACE/python-setup/tests/check_requests_123.sh 2
- test_dir: python-setup/tests/poetry/requests-3
test_script: $GITHUB_WORKSPACE/python-setup/tests/check_requests_123.sh 3
- test_dir: python-setup/tests/requirements/requests-2
test_script: $GITHUB_WORKSPACE/python-setup/tests/check_requests_123.sh 2
- test_dir: python-setup/tests/requirements/requests-3
test_script: $GITHUB_WORKSPACE/python-setup/tests/check_requests_123.sh 3
- test_dir: python-setup/tests/setup_py/requests-2
test_script: $GITHUB_WORKSPACE/python-setup/tests/check_requests_123.sh 2
- test_dir: python-setup/tests/setup_py/requests-3
test_script: $GITHUB_WORKSPACE/python-setup/tests/check_requests_123.sh 3
# This one shouldn't fail, but also won't install packages
- test_dir: python-setup/tests/requirements/non-standard-location
test_script: test -z $LGTM_INDEX_IMPORT_PATH
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: python
- name: Test Auto Package Installation
run: |
set -x
$GITHUB_WORKSPACE/python-setup/install_tools.sh
echo -e '\n\n\n\n\n' && sleep 0.5
cd $GITHUB_WORKSPACE/${{ matrix.test_dir }}
$GITHUB_WORKSPACE/python-setup/auto_install_packages.py /opt/hostedtoolcache/CodeQL/0.0.0-20200826/x64/codeql/
/bin/true
- name: Setup for extractor
run: |
echo $CODEQL_PYTHON
# only run if $CODEQL_PYTHON is set
test ! -z $CODEQL_PYTHON && $GITHUB_WORKSPACE/python-setup/tests/from_python_exe.py $CODEQL_PYTHON || /bin/true
- name: Verify packages installed
run: |
${{ matrix.test_script }}

4
lib/init.js generated
View File

@@ -138,7 +138,7 @@ async function installPythonDeps(codeql, logger) {
// This script tries to install some needed tools in the runner. It should not fail, but if it does
// we just abort the process without failing the action
logger.endGroup();
logger.warning("Unable to download and extract the tools needed for installing the python dependecies");
logger.warning("Unable to download and extract the tools needed for installing the python dependecies. You can call this action with 'setup-python-dependencies: false' to disable this process.");
}
}
// Install dependencies
@@ -147,7 +147,7 @@ async function installPythonDeps(codeql, logger) {
}
catch (e) {
logger.endGroup();
logger.warning("We were unable to install your python dependencies.");
logger.warning("We were unable to install your python dependencies. You can call this action with 'setup-python-dependencies: false' to disable this process.");
}
logger.endGroup();
}

View File

@@ -1 +1 @@
{"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":";;;;;;;;;AAAA,0EAA4D;AAC5D,uCAAyB;AACzB,2CAA6B;AAE7B,gEAAkD;AAClD,qCAA+C;AAC/C,4DAA8C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,CAAC,OAAO,EAAE,CAAC,CAAC,CACjC,CAAC,IAAI,EAAE,CAAC;KACV;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,CAAC,QAAQ,EAAE,CAAC;QAClB,MAAM,CAAC,OAAO,CACZ,+IAA+I,CAChJ,CAAC;KACH;IACD,MAAM,CAAC,QAAQ,EAAE,CAAC;AACpB,CAAC;AA1CD,8CA0CC"}

View File

@@ -4,6 +4,7 @@ import sys
import os
import subprocess
from tempfile import mkdtemp
from typing import Optional
import extractor_version
@@ -101,7 +102,7 @@ def install_with_setup_py(version: int):
return venv_python
def install_packages() -> str:
def install_packages(codeql_base_dir) -> Optional[str]:
if os.path.exists('poetry.lock'):
print('Found poetry.lock, will install packages with poetry', flush=True)
return install_packages_with_poetry()
@@ -113,7 +114,8 @@ def install_packages() -> str:
print('Found Pipfile, will install packages with Pipenv', flush=True)
return install_packages_with_pipenv()
version = extractor_version.get_extractor_version(sys.argv[1], quiet=False)
# get_extractor_version returns the Python version the extractor thinks this repo is using
version = extractor_version.get_extractor_version(codeql_base_dir, quiet=False)
if os.path.exists('requirements.txt'):
print('Found requirements.txt, will install packages with pip', flush=True)
@@ -124,17 +126,20 @@ def install_packages() -> str:
return install_with_setup_py(version)
print("was not able to install packages automatically", flush=True)
return None
if __name__ == "__main__":
if len(sys.argv) != 2:
sys.exit('Must provide base directory for codeql tool as only argument')
codeql_base_dir = sys.argv[1]
# The binaries for packages installed with `pip install --user` are not available on
# PATH by default, so we need to manually add them.
os.environ['PATH'] = os.path.expanduser('~/.local/bin') + os.pathsep + os.environ['PATH']
python_executable_path = install_packages()
python_executable_path = install_packages(codeql_base_dir)
if python_executable_path is not None:
print("Setting CODEQL_PYTHON={}".format(python_executable_path))

View File

@@ -30,7 +30,6 @@ def suppress_stdout_stderr():
def get_extractor_version(codeql_base_dir: str, quiet: bool = True) -> int:
extractor_dir = os.path.join(codeql_base_dir, 'python', 'tools')
sys.path = [extractor_dir] + sys.path
@@ -50,4 +49,4 @@ def get_extractor_version(codeql_base_dir: str, quiet: bool = True) -> int:
if __name__ == "__main__":
codeql_base_dir = sys.argv[1]
version = get_extractor_version(codeql_base_dir)
print('{!r}'.format(version))
print('{!r}'.format(version))

View File

@@ -18,10 +18,7 @@ python3 -m pip install --user --upgrade pip setuptools wheel
python2 -m pip install --user virtualenv
python3 -m pip install --user virtualenv
# venv is required for installation of poetry or pipenv (I forgot which)
sudo apt-get install -y python3-venv
# We're install poetry with pip instead of the recommended way, since the recommended way
# We install poetry with pip instead of the recommended way, since the recommended way
# caused some problem since `poetry run` gives output like:
#
# /root/.poetry/lib/poetry/_vendor/py2.7/subprocess32.py:149: RuntimeWarning: The _posixsubprocess module is not being used. Child process reliability may suffer if your program uses threads.

View File

@@ -0,0 +1,32 @@
#!/bin/bash
set -e
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
EXPECTED_VERSION=$1
FOUND_VERSION="$LGTM_PYTHON_SETUP_VERSION"
FOUND_PYTHONPATH="$LGTM_INDEX_IMPORT_PATH"
echo "FOUND_VERSION=${FOUND_VERSION} FOUND_PYTHONPATH=${FOUND_PYTHONPATH} "
if [[ $FOUND_VERSION != $EXPECTED_VERSION ]]; then
echo "Script told us to use Python ${FOUND_VERSION}, but expected ${EXPECTED_VERSION}"
exit 1
else
echo "Script told us to use Python ${FOUND_VERSION}, which was expected"
fi
PYTHON_EXE="python${EXPECTED_VERSION}"
INSTALLED_REQUESTS_VERSION=$(PYTHONPATH="${FOUND_PYTHONPATH}" "${PYTHON_EXE}" -c 'import requests; print(requests.__version__)')
EXPECTED_REQUESTS="1.2.3"
if [[ "$INSTALLED_REQUESTS_VERSION" != "$EXPECTED_REQUESTS" ]]; then
echo "Using ${FOUND_PYTHONPATH} as PYTHONPATH, we found version $INSTALLED_REQUESTS_VERSION of requests, but expected $EXPECTED_REQUESTS"
exit 1
else
echo "Using ${FOUND_PYTHONPATH} as PYTHONPATH, we found version $INSTALLED_REQUESTS_VERSION of requests, which was expected"
fi

View File

@@ -0,0 +1,31 @@
#!/usr/bin/env python3
import sys
import subprocess
from typing import Tuple
def get_details(path_to_python_exe: str) -> Tuple[str, str]:
import_path = subprocess.check_output(
[
path_to_python_exe,
"-c",
"import os; import pip; print(os.path.dirname(os.path.dirname(pip.__file__)))",
],
stdin=subprocess.DEVNULL,
)
version = subprocess.check_output(
[path_to_python_exe, "-c", "import sys; print(sys.version_info[0])"],
stdin=subprocess.DEVNULL,
)
return version.decode("utf-8").strip(), import_path.decode("utf-8").strip()
if __name__ == "__main__":
version, import_path = get_details(sys.argv[1])
print("Setting LGTM_PYTHON_SETUP_VERSION={}".format(version))
print("::set-env name=LGTM_PYTHON_SETUP_VERSION::{}".format(version))
print("Setting LGTM_INDEX_IMPORT_PATH={}".format(import_path))
print("::set-env name=LGTM_INDEX_IMPORT_PATH::{}".format(import_path))

View File

@@ -0,0 +1,12 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
[packages]
requests = "*"
[requires]
python_version = "3.8"

View File

@@ -0,0 +1,28 @@
{
"_meta": {
"hash": {
"sha256": "2296b1fab66570fa3660c5e6a4e923332dcd7785814624c584be6623bc62c0e7"
},
"pipfile-spec": 6,
"requires": {
"python_version": "3.8"
},
"sources": [
{
"name": "pypi",
"url": "https://pypi.org/simple",
"verify_ssl": true
}
]
},
"default": {
"requests": {
"hashes": [
"sha256:156bf3ec27ba9ec7e0cf8fbe02808718099d218de403eb64a714d73ba1a29ab1"
],
"index": "pypi",
"version": "==1.2.3"
}
},
"develop": {}
}

View File

@@ -0,0 +1,12 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
[packages]
requests = "*"
[requires]
python_version = "3.100"

View File

@@ -0,0 +1,28 @@
{
"_meta": {
"hash": {
"sha256": "2296b1fab66570fa3660c5e6a4e923332dcd7785814624c584be6623bc62c0e7"
},
"pipfile-spec": 6,
"requires": {
"python_version": "3.8"
},
"sources": [
{
"name": "pypi",
"url": "https://pypi.org/simple",
"verify_ssl": true
}
]
},
"default": {
"requests": {
"hashes": [
"sha256:156bf3ec27ba9ec7e0cf8fbe02808718099d218de403eb64a714d73ba1a29ab1"
],
"index": "pypi",
"version": "==1.2.3"
}
},
"develop": {}
}

View File

@@ -0,0 +1,12 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
[packages]
requests = "*"
[requires]
python_version = "2.7"

View File

@@ -0,0 +1,28 @@
{
"_meta": {
"hash": {
"sha256": "fba50410545d38a2f88b8d6964eb292055389e363b5c75a56b01ec80e7de14c1"
},
"pipfile-spec": 6,
"requires": {
"python_version": "2.7"
},
"sources": [
{
"name": "pypi",
"url": "https://pypi.org/simple",
"verify_ssl": true
}
]
},
"default": {
"requests": {
"hashes": [
"sha256:156bf3ec27ba9ec7e0cf8fbe02808718099d218de403eb64a714d73ba1a29ab1"
],
"index": "pypi",
"version": "==1.2.3"
}
},
"develop": {}
}

View File

@@ -0,0 +1,11 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
[packages]
requests = "*"
[requires]

View File

@@ -0,0 +1,28 @@
{
"_meta": {
"hash": {
"sha256": "2296b1fab66570fa3660c5e6a4e923332dcd7785814624c584be6623bc62c0e7"
},
"pipfile-spec": 6,
"requires": {
"python_version": "3.8"
},
"sources": [
{
"name": "pypi",
"url": "https://pypi.org/simple",
"verify_ssl": true
}
]
},
"default": {
"requests": {
"hashes": [
"sha256:156bf3ec27ba9ec7e0cf8fbe02808718099d218de403eb64a714d73ba1a29ab1"
],
"index": "pypi",
"version": "==1.2.3"
}
},
"develop": {}
}

View File

@@ -0,0 +1,16 @@
[[package]]
category = "main"
description = "Python HTTP for Humans."
name = "requests"
optional = false
python-versions = "^3.8"
version = "1.2.3"
[metadata]
content-hash = "b1abdce30bbdad3ac786dafe6840129df522cae3c5988f9ba8061320e3c1a34e"
python-versions = "^3.8"
[metadata.files]
requests = [
{file = "requests-1.2.3.tar.gz", hash = "sha256:156bf3ec27ba9ec7e0cf8fbe02808718099d218de403eb64a714d73ba1a29ab1"},
]

View File

@@ -0,0 +1,15 @@
[tool.poetry]
name = "autoinstall-test"
version = "0.1.0"
description = ""
authors = ["Your Name <you@example.com>"]
[tool.poetry.dependencies]
python = "^3.8"
requests = "*"
[tool.poetry.dev-dependencies]
[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

View File

@@ -0,0 +1,16 @@
[[package]]
category = "main"
description = "Python HTTP for Humans."
name = "requests"
optional = false
python-versions = "^3.100"
version = "1.2.3"
[metadata]
content-hash = "b1abdce30bbdad3ac786dafe6840129df522cae3c5988f9ba8061320e3c1a34e"
python-versions = "^3.100"
[metadata.files]
requests = [
{file = "requests-1.2.3.tar.gz", hash = "sha256:156bf3ec27ba9ec7e0cf8fbe02808718099d218de403eb64a714d73ba1a29ab1"},
]

View File

@@ -0,0 +1,15 @@
[tool.poetry]
name = "autoinstall-test"
version = "0.1.0"
description = ""
authors = ["Your Name <you@example.com>"]
[tool.poetry.dependencies]
python = "^3.100"
requests = "*"
[tool.poetry.dev-dependencies]
[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

View File

@@ -0,0 +1,16 @@
[[package]]
category = "main"
description = "Python HTTP for Humans."
name = "requests"
optional = false
python-versions = "*"
version = "1.2.3"
[metadata]
content-hash = "b8c27a00aece20cb2ff6b3dcd394b1b5ef5e4acc3d7a059cfeb9f9cc11c9eff4"
python-versions = "^2.7"
[metadata.files]
requests = [
{file = "requests-1.2.3.tar.gz", hash = "sha256:156bf3ec27ba9ec7e0cf8fbe02808718099d218de403eb64a714d73ba1a29ab1"},
]

View File

@@ -0,0 +1,15 @@
[tool.poetry]
name = "autoinstall-test"
version = "0.1.0"
description = ""
authors = ["Your Name <you@example.com>"]
[tool.poetry.dependencies]
python = "^2.7"
requests = "*"
[tool.poetry.dev-dependencies]
[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

View File

@@ -0,0 +1,16 @@
[[package]]
category = "main"
description = "Python HTTP for Humans."
name = "requests"
optional = false
python-versions = "^3.5"
version = "1.2.3"
[metadata]
content-hash = "b1abdce30bbdad3ac786dafe6840129df522cae3c5988f9ba8061320e3c1a34e"
python-versions = "^3.5"
[metadata.files]
requests = [
{file = "requests-1.2.3.tar.gz", hash = "sha256:156bf3ec27ba9ec7e0cf8fbe02808718099d218de403eb64a714d73ba1a29ab1"},
]

View File

@@ -0,0 +1,15 @@
[tool.poetry]
name = "autoinstall-test"
version = "0.1.0"
description = ""
authors = ["Your Name <you@example.com>"]
[tool.poetry.dependencies]
python = "^3.5"
requests = "*"
[tool.poetry.dev-dependencies]
[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

View File

@@ -0,0 +1,2 @@
# non-existing package
ajsdiofjasodinfkajsndfoiuqwhefoanisdfojnasdofas

View File

@@ -0,0 +1,2 @@
# valid package with invalid version
requests==10000

View File

@@ -0,0 +1 @@
requests==1.2.3

View File

@@ -0,0 +1 @@
print('hello')

View File

@@ -0,0 +1 @@
requests==1.2.3

View File

@@ -0,0 +1,3 @@
# fake setup.py with Trove classifier to fool Python extractor to believe this is Python 2 for sure
# Programming Language :: Python :: 2.7

View File

@@ -0,0 +1 @@
requests==1.2.3

View File

@@ -0,0 +1,3 @@
# fake setup.py with Trove classifier to fool Python extractor to believe this is Python 3 for sure
# Programming Language :: Python :: 3.7

View File

@@ -0,0 +1,11 @@
from setuptools import setup
# has fake Trove classifier to fool Python extractor to believe this is Python 3 for sure
# Programming Language :: Python :: 3.7
setup(
name="example-setup.py",
install_requires=[],
extras_require={"all": ["requests==1.2.3"]}
)

View File

@@ -0,0 +1 @@
raise Exception("some kind of error")

View File

@@ -0,0 +1,6 @@
from setuptools import setup
setup(
name="example-setup.py",
install_requires=["requests==10000"],
)

View File

@@ -0,0 +1,12 @@
from setuptools import setup
# has fake Trove classifier to fool Python extractor to believe this is Python 2 for sure
# Programming Language :: Python :: 2.7
setup(
name="example-setup.py",
install_requires=["requests==1.2.3"],
python_requires=">=2.7, <3",
)

View File

@@ -0,0 +1,12 @@
from setuptools import setup
# has fake Trove classifier to fool Python extractor to believe this is Python 3 for sure
# Programming Language :: Python :: 3.7
setup(
name="example-setup.py",
install_requires=["requests==1.2.3"],
python_requires='>=3.5',
)

View File

@@ -0,0 +1,12 @@
from setuptools import setup
# has fake Trove classifier to fool Python extractor to believe this is Python 3 for sure
# Programming Language :: Python :: 3.7
setup(
name="example-setup.py",
install_requires=["requests==1.2.3"],
python_requires=">=2.7, <3",
)

View File

@@ -206,7 +206,7 @@ export async function installPythonDeps(codeql: CodeQL, logger: Logger) {
// we just abort the process without failing the action
logger.endGroup();
logger.warning(
"Unable to download and extract the tools needed for installing the python dependecies"
"Unable to download and extract the tools needed for installing the python dependecies. You can call this action with 'setup-python-dependencies: false' to disable this process."
);
}
}
@@ -219,7 +219,9 @@ export async function installPythonDeps(codeql: CodeQL, logger: Logger) {
).exec();
} catch (e) {
logger.endGroup();
logger.warning("We were unable to install your python dependencies.");
logger.warning(
"We were unable to install your python dependencies. You can call this action with 'setup-python-dependencies: false' to disable this process."
);
}
logger.endGroup();
}