release: check mypy files are generated
This commit is contained in:
@@ -95,7 +95,10 @@ function build_wheel() {
|
||||
>&2 echo "Can't find project's CMakeLists.txt or cmake"
|
||||
exit 2
|
||||
fi
|
||||
cmake -S. -B"${BUILD_DIR}" -DCMAKE_BUILD_TYPE=Release -DBUILD_DEPS=ON -DBUILD_PYTHON=ON -DPython3_ROOT_DIR="$1" -DBUILD_TESTING=OFF #--debug-find
|
||||
cmake -S. -B"${BUILD_DIR}" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DBUILD_DEPS=ON -DBUILD_PYTHON=ON -DPython3_ROOT_DIR="$1" \
|
||||
-DBUILD_TESTING=OFF -DBUILD_SAMPLES=OFF -DBUILD_EXAMPLES=OFF #--debug-find
|
||||
cmake --build "${BUILD_DIR}" -v -j4
|
||||
|
||||
# Restore environment
|
||||
@@ -112,6 +115,28 @@ function check_wheel() {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check mypy files
|
||||
declare -a MYPY_FILES=(
|
||||
"ortools/algorithms/python/knapsack_solver.pyi"
|
||||
"ortools/constraint_solver/pywrapcp.pyi"
|
||||
"ortools/graph/python/linear_sum_assignment.pyi"
|
||||
"ortools/graph/python/max_flow.pyi"
|
||||
"ortools/graph/python/min_cost_flow.pyi"
|
||||
"ortools/init/python/init.pyi"
|
||||
"ortools/linear_solver/python/model_builder_helper.pyi"
|
||||
"ortools/linear_solver/pywraplp.pyi"
|
||||
"ortools/pdlp/python/pdlp.pyi"
|
||||
"ortools/sat/python/swig_helper.pyi"
|
||||
"ortools/scheduling/python/rcpsp.pyi"
|
||||
"ortools/util/python/sorted_interval_list.pyi"
|
||||
)
|
||||
for FILE in "${MYPY_FILES[@]}"; do
|
||||
if [[ ! -f "${BUILD_DIR}/python/${FILE}" ]]; then
|
||||
echo "error: ${FILE} missing in the python project"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
# Check all generated wheel packages
|
||||
pushd "${BUILD_DIR}/python/dist"
|
||||
for FILE in *.whl; do
|
||||
@@ -152,6 +177,20 @@ function test_wheel() {
|
||||
pip install --no-cache-dir "$WHEEL_FILE"
|
||||
pip show ortools
|
||||
|
||||
# Python scripts to be used as tests for the installed wheel. This list of files
|
||||
# has been taken from the 'test_python' make target.
|
||||
declare -a TESTS=(
|
||||
"ortools/algorithms/samples/simple_knapsack_program.py"
|
||||
"ortools/graph/samples/simple_max_flow_program.py"
|
||||
"ortools/graph/samples/simple_min_cost_flow_program.py"
|
||||
"ortools/linear_solver/samples/simple_lp_program.py"
|
||||
"ortools/linear_solver/samples/simple_mip_program.py"
|
||||
"ortools/sat/samples/simple_sat_program.py"
|
||||
"ortools/constraint_solver/samples/tsp.py"
|
||||
"ortools/constraint_solver/samples/vrp.py"
|
||||
"ortools/constraint_solver/samples/cvrptw_break.py"
|
||||
)
|
||||
|
||||
# Run all the specified test scripts using the current environment.
|
||||
local -r ROOT_DIR=$(pwd)
|
||||
pushd "$(mktemp -d)" # ensure we are not importing something from $PWD
|
||||
@@ -215,19 +254,6 @@ function main() {
|
||||
assert_defined PYTHON_VERSION
|
||||
|
||||
# Setup
|
||||
# Python scripts to be used as tests for the installed wheel. This list of files
|
||||
# has been taken from the 'test_python' make target.
|
||||
declare -a TESTS=(
|
||||
"ortools/algorithms/samples/simple_knapsack_program.py"
|
||||
"ortools/graph/samples/simple_max_flow_program.py"
|
||||
"ortools/graph/samples/simple_min_cost_flow_program.py"
|
||||
"ortools/linear_solver/samples/simple_lp_program.py"
|
||||
"ortools/linear_solver/samples/simple_mip_program.py"
|
||||
"ortools/sat/samples/simple_sat_program.py"
|
||||
"ortools/constraint_solver/samples/tsp.py"
|
||||
"ortools/constraint_solver/samples/vrp.py"
|
||||
"ortools/constraint_solver/samples/cvrptw_break.py"
|
||||
)
|
||||
declare -a SKIPS=( "pp37-pypy37_pp73" )
|
||||
|
||||
case ${1} in
|
||||
|
||||
@@ -218,7 +218,10 @@ function build_python() {
|
||||
local -r PY=(3.8 3.9 3.10 3.11 3.12)
|
||||
fi
|
||||
|
||||
# Check Python env
|
||||
for PY_VERSION in "${PY[@]}"; do
|
||||
# Check python interpreter
|
||||
# Need the one form python.org not from homebrew to be compatible with older macOS
|
||||
PY_PATH="/Library/Frameworks/Python.framework/Versions/${PY_VERSION}"
|
||||
if [[ ! -d "$PY_PATH" ]]; then
|
||||
echo "Error: Python ${PY_VERSION} is not found (${PY_PATH})." | tee -a build.log
|
||||
@@ -226,9 +229,9 @@ function build_python() {
|
||||
fi
|
||||
export PATH="${HOME}/Library/Python/${PY_VERSION}/bin:${PY_PATH}/bin:${PATH_BCKP}"
|
||||
|
||||
# Check Python env
|
||||
echo "check python3..."
|
||||
command -v python3 | xargs echo "python3: " | tee -a build.log
|
||||
# Check Python packages mandatory are available and up to date
|
||||
echo "check python${PY_VERSION}..."
|
||||
command -v python3 | xargs echo "python${PY_VERSION}: " | tee -a build.log
|
||||
command -v "python${PY_VERSION}" | xargs echo "python${PY_VERSION}: " | tee -a build.log
|
||||
"python${PY_VERSION}" -c "import platform as p; print(p.platform())" | tee -a build.log
|
||||
"python${PY_VERSION}" -m pip install --upgrade --user pip
|
||||
@@ -239,6 +242,22 @@ function build_python() {
|
||||
protoc-gen-mypy --version | grep "3\.5\.0"
|
||||
done
|
||||
|
||||
declare -a MYPY_FILES=(
|
||||
"ortools/algorithms/python/knapsack_solver.pyi"
|
||||
"ortools/constraint_solver/pywrapcp.pyi"
|
||||
"ortools/graph/python/linear_sum_assignment.pyi"
|
||||
"ortools/graph/python/max_flow.pyi"
|
||||
"ortools/graph/python/min_cost_flow.pyi"
|
||||
"ortools/init/python/init.pyi"
|
||||
"ortools/linear_solver/python/model_builder_helper.pyi"
|
||||
"ortools/linear_solver/pywraplp.pyi"
|
||||
"ortools/pdlp/python/pdlp.pyi"
|
||||
"ortools/sat/python/swig_helper.pyi"
|
||||
"ortools/scheduling/python/rcpsp.pyi"
|
||||
"ortools/util/python/sorted_interval_list.pyi"
|
||||
"ortools/test/test.pyi"
|
||||
)
|
||||
|
||||
for PY_VERSION in "${PY[@]}"; do
|
||||
PY_PATH="/Library/Frameworks/Python.framework/Versions/${PY_VERSION}"
|
||||
if [[ ! -d "$PY_PATH" ]]; then
|
||||
@@ -247,7 +266,7 @@ function build_python() {
|
||||
fi
|
||||
export PATH="${HOME}/Library/Python/${PY_VERSION}/bin:${PY_PATH}/bin:${PATH_BCKP}"
|
||||
|
||||
# Clean and build
|
||||
# Clean and build
|
||||
echo -n "Cleaning Python ${PY_VERSION}..." | tee -a build.log
|
||||
rm -rf "temp_python${PY_VERSION}"
|
||||
echo "DONE" | tee -a build.log
|
||||
@@ -258,6 +277,14 @@ function build_python() {
|
||||
#cmake --build temp_python${PY_VERSION} --target test
|
||||
#echo "cmake test_python${PY_VERSION}: DONE" | tee -a build.log
|
||||
|
||||
# Check mypy files
|
||||
for FILE in "${MYPY_FILES[@]}"; do
|
||||
if [[ ! -f "temp_python${PY_VERSION}/build/python/${FILE}" ]]; then
|
||||
echo "error: ${FILE} missing in the python project" | tee -a build.log
|
||||
exit 2
|
||||
fi
|
||||
done
|
||||
|
||||
cp "temp_python${PY_VERSION}"/python/dist/*.whl export/
|
||||
pushd export
|
||||
for WHEEL_FILE in *_universal2.whl; do
|
||||
|
||||
@@ -291,6 +291,29 @@ for %%v in (8 9 10 11 12) do (
|
||||
cmake --build temp_python3%%v --config Release -j8 -v
|
||||
echo DONE | tee.exe -a build.log
|
||||
|
||||
echo Check MYPY files... | tee.exe -a build.log
|
||||
FOR %%m IN (
|
||||
ortools\algorithms\python\knapsack_solver.pyi
|
||||
ortools\constraint_solver\pywrapcp.pyi
|
||||
ortools\graph\python\linear_sum_assignment.pyi
|
||||
ortools\graph\python\max_flow.pyi
|
||||
ortools\graph\python\min_cost_flow.pyi
|
||||
ortools\init\python\init.pyi
|
||||
ortools\linear_solver\python\model_builder_helper.pyi
|
||||
ortools\linear_solver\pywraplp.pyi
|
||||
ortools\pdlp\python\pdlp.pyi
|
||||
ortools\sat\python\swig_helper.pyi
|
||||
ortools\scheduling\python\rcpsp.pyi
|
||||
ortools\util\python\sorted_interval_list.pyi
|
||||
) DO (
|
||||
IF NOT EXIST temp_python3%%v\python\%%m (
|
||||
echo File %%m missing in python project | tee.exe -a build.log
|
||||
exit /B 1
|
||||
)
|
||||
)
|
||||
echo Check MYPY files...DONE | tee.exe -a build.log
|
||||
|
||||
|
||||
REM echo Test Python 3.%%v pypi archive... | tee.exe -a build.log
|
||||
REM cmake --build temp_python3%%v --config Release --target RUN_TEST || exit 1
|
||||
REM echo DONE | tee.exe -a build.log
|
||||
|
||||
Reference in New Issue
Block a user