Sync g3 to gh
This commit is contained in:
@@ -81,8 +81,8 @@ if __name__ == "__main__":
|
||||
format="[%(levelname)s] %(message)s", stream=sys.stdout, level=loglevel)
|
||||
|
||||
# Display Python Version and path
|
||||
logging.info(f"Python path : {sys.executable}")
|
||||
logging.info(f"Python version : {sys.version}")
|
||||
logging.info("Python path : %s", sys.executable)
|
||||
logging.info("Python version : %s", sys.version)
|
||||
|
||||
# Choose the pypi package
|
||||
ortools_name = "ortools"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,13 +2,12 @@
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import re
|
||||
import os
|
||||
import re
|
||||
|
||||
|
||||
def main(version_number):
|
||||
"""For each doc section, edit the doxy and header files, and generate the doc.
|
||||
"""
|
||||
def main(version):
|
||||
"""For each doc section, edit the doxy and header files, and generate the doc."""
|
||||
sections = create_section_data()
|
||||
doxy_tmp = 'tools/doc/tmp.doxy'
|
||||
header_tmp = 'tools/doc/header.tmp.html'
|
||||
@@ -22,11 +21,11 @@ def main(version_number):
|
||||
doxyfile = 'tools/doc/' + section['doxyfile']
|
||||
headerfile = 'tools/doc/' + section['headerfile']
|
||||
footerfile = 'tools/doc/' + section['footerfile']
|
||||
styleSheetfile = 'tools/doc/' + section['styleSheetfile']
|
||||
stylesheetfile = 'tools/doc/' + section['styleSheetfile']
|
||||
input_files = section['input_files']
|
||||
# Edit doxyfile.
|
||||
project_name_string = 'PROJECT_NAME = ' + project_name
|
||||
project_number_string = 'PROJECT_NUMBER = ' + version_number
|
||||
project_number_string = 'PROJECT_NUMBER = ' + version
|
||||
html_output_string = 'HTML_OUTPUT = ' + output_dir
|
||||
input_string = 'INPUT = ' + input_files
|
||||
f = open(doxyfile, 'r')
|
||||
@@ -46,7 +45,8 @@ def main(version_number):
|
||||
f = open(headerfile, 'r')
|
||||
g = open(header_tmp, 'w')
|
||||
filedata = f.read()
|
||||
filedata = re.sub('Banner Text', 'Google OR-Tools ' + version_number, filedata)
|
||||
filedata = re.sub('Banner Text', 'Google OR-Tools ' + version,
|
||||
filedata)
|
||||
filedata = re.sub('Page Title', title, filedata)
|
||||
# Write filedata.
|
||||
g.write(filedata)
|
||||
@@ -63,7 +63,7 @@ def main(version_number):
|
||||
g.close()
|
||||
|
||||
# Edit style sheet file.
|
||||
f = open(styleSheetfile, 'r')
|
||||
f = open(stylesheetfile, 'r')
|
||||
g = open(style_sheet_tmp, 'w')
|
||||
filedata = f.read()
|
||||
# Write filedata.
|
||||
@@ -81,115 +81,138 @@ def main(version_number):
|
||||
os.system(f'rm {footer_tmp}')
|
||||
os.system(f'rm {style_sheet_tmp}')
|
||||
|
||||
|
||||
def create_section_data():
|
||||
sections = [
|
||||
{
|
||||
'output_dir': 'cpp_algorithms',
|
||||
'project name': 'Algorithms',
|
||||
'title': 'C++ Reference: Algorithms',
|
||||
'doxyfile': 'cpp.doxy.in',
|
||||
'headerfile': 'cpp.header.html.in',
|
||||
'footerfile': 'all.footer.html.in',
|
||||
'styleSheetfile': 'all.styleSheet.css.in',
|
||||
"""Generate each section configuration."""
|
||||
sections = [{
|
||||
'output_dir':
|
||||
'cpp_algorithms',
|
||||
'project name':
|
||||
'Algorithms',
|
||||
'title':
|
||||
'C++ Reference: Algorithms',
|
||||
'doxyfile':
|
||||
'cpp.doxy.in',
|
||||
'headerfile':
|
||||
'cpp.header.html.in',
|
||||
'footerfile':
|
||||
'all.footer.html.in',
|
||||
'styleSheetfile':
|
||||
'all.styleSheet.css.in',
|
||||
'input_files':
|
||||
'ortools/algorithms/dense_doubly_linked_list.h ' +
|
||||
'ortools/algorithms/dynamic_partition.h ' +
|
||||
'ortools/algorithms/dynamic_permutation.h ' +
|
||||
'ortools/algorithms/find_graph_symmetries.h ' +
|
||||
'ortools/algorithms/hungarian.h ' +
|
||||
'ortools/algorithms/knapsack_solver.h ' +
|
||||
'ortools/algorithms/sparse_permutation.h'
|
||||
},
|
||||
{
|
||||
'output_dir': 'cpp_sat',
|
||||
'project name': 'CP-SAT',
|
||||
'title': 'C++ Reference: CP-SAT',
|
||||
'doxyfile': 'cpp.doxy.in',
|
||||
'headerfile': 'cpp.header.html.in',
|
||||
'footerfile': 'all.footer.html.in',
|
||||
'styleSheetfile': 'all.styleSheet.css.in',
|
||||
'ortools/algorithms/dense_doubly_linked_list.h ' +
|
||||
'ortools/algorithms/dynamic_partition.h ' +
|
||||
'ortools/algorithms/dynamic_permutation.h ' +
|
||||
'ortools/algorithms/find_graph_symmetries.h ' +
|
||||
'ortools/algorithms/hungarian.h ' +
|
||||
'ortools/algorithms/knapsack_solver.h ' +
|
||||
'ortools/algorithms/sparse_permutation.h'
|
||||
}, {
|
||||
'output_dir':
|
||||
'cpp_sat',
|
||||
'project name':
|
||||
'CP-SAT',
|
||||
'title':
|
||||
'C++ Reference: CP-SAT',
|
||||
'doxyfile':
|
||||
'cpp.doxy.in',
|
||||
'headerfile':
|
||||
'cpp.header.html.in',
|
||||
'footerfile':
|
||||
'all.footer.html.in',
|
||||
'styleSheetfile':
|
||||
'all.styleSheet.css.in',
|
||||
'input_files':
|
||||
'ortools/sat/cp_model.h ' +
|
||||
'ortools/sat/cp_model_solver.h ' +
|
||||
'ortools/sat/model.h ' +
|
||||
'ortools/util/sorted_interval_list.h ' +
|
||||
'ortools/util/time_limit.h ' +
|
||||
'ortools/gen/ortools/sat/boolean_problem.pb.h ' +
|
||||
'ortools/gen/ortools/sat/cp_model.pb.h ' +
|
||||
'ortools/gen/ortools/sat/sat_parameters.pb.h'
|
||||
},
|
||||
{
|
||||
'output_dir': 'cpp_graph',
|
||||
'project name': 'Graph',
|
||||
'title': 'C++ Reference: Graph',
|
||||
'doxyfile': 'cpp.doxy.in',
|
||||
'headerfile': 'cpp.header.html.in',
|
||||
'footerfile': 'all.footer.html.in',
|
||||
'styleSheetfile': 'all.styleSheet.css.in',
|
||||
'ortools/sat/cp_model.h ' + 'ortools/sat/cp_model_solver.h ' +
|
||||
'ortools/sat/model.h ' + 'ortools/util/sorted_interval_list.h ' +
|
||||
'ortools/util/time_limit.h ' +
|
||||
'ortools/gen/ortools/sat/boolean_problem.pb.h ' +
|
||||
'ortools/gen/ortools/sat/cp_model.pb.h ' +
|
||||
'ortools/gen/ortools/sat/sat_parameters.pb.h'
|
||||
}, {
|
||||
'output_dir':
|
||||
'cpp_graph',
|
||||
'project name':
|
||||
'Graph',
|
||||
'title':
|
||||
'C++ Reference: Graph',
|
||||
'doxyfile':
|
||||
'cpp.doxy.in',
|
||||
'headerfile':
|
||||
'cpp.header.html.in',
|
||||
'footerfile':
|
||||
'all.footer.html.in',
|
||||
'styleSheetfile':
|
||||
'all.styleSheet.css.in',
|
||||
'input_files':
|
||||
'ortools/graph/christofides.h ' +
|
||||
'ortools/graph/cliques.h ' +
|
||||
'ortools/graph/connected_components.h ' +
|
||||
'ortools/graph/connectivity.h ' +
|
||||
'ortools/graph/ebert_graph.h ' +
|
||||
'ortools/graph/eulerian_path.h ' +
|
||||
'ortools/graph/graph.h ' +
|
||||
'ortools/graph/graphs.h ' +
|
||||
'ortools/graph/hamiltonian_path.h ' +
|
||||
'ortools/graph/io.h ' +
|
||||
'ortools/graph/iterators.h ' +
|
||||
'ortools/graph/linear_assignment.h ' +
|
||||
'ortools/graph/max_flow.h ' +
|
||||
'ortools/graph/min_cost_flow.h ' +
|
||||
'ortools/graph/minimum_spanning_tree.h ' +
|
||||
'ortools/graph/one_tree_lower_bound.h ' +
|
||||
'ortools/graph/shortestpaths.h ' +
|
||||
'ortools/graph/strongly_connected_components.h ' +
|
||||
'ortools/graph/util.h ' +
|
||||
'ortools/gen/ortools/graph/flow_problem.pb.h '
|
||||
},
|
||||
{
|
||||
'output_dir': 'cpp_linear',
|
||||
'project name': 'Linear solver',
|
||||
'title': 'C++ Reference: Linear solver',
|
||||
'doxyfile': 'cpp.doxy.in',
|
||||
'headerfile': 'cpp.header.html.in',
|
||||
'footerfile': 'all.footer.html.in',
|
||||
'styleSheetfile': 'all.styleSheet.css.in',
|
||||
'ortools/graph/christofides.h ' + 'ortools/graph/cliques.h ' +
|
||||
'ortools/graph/connected_components.h ' +
|
||||
'ortools/graph/connectivity.h ' + 'ortools/graph/ebert_graph.h ' +
|
||||
'ortools/graph/eulerian_path.h ' + 'ortools/graph/graph.h ' +
|
||||
'ortools/graph/graphs.h ' + 'ortools/graph/hamiltonian_path.h ' +
|
||||
'ortools/graph/io.h ' + 'ortools/graph/iterators.h ' +
|
||||
'ortools/graph/linear_assignment.h ' + 'ortools/graph/max_flow.h ' +
|
||||
'ortools/graph/min_cost_flow.h ' +
|
||||
'ortools/graph/minimum_spanning_tree.h ' +
|
||||
'ortools/graph/one_tree_lower_bound.h ' +
|
||||
'ortools/graph/shortestpaths.h ' +
|
||||
'ortools/graph/strongly_connected_components.h ' +
|
||||
'ortools/graph/util.h ' +
|
||||
'ortools/gen/ortools/graph/flow_problem.pb.h '
|
||||
}, {
|
||||
'output_dir':
|
||||
'cpp_linear',
|
||||
'project name':
|
||||
'Linear solver',
|
||||
'title':
|
||||
'C++ Reference: Linear solver',
|
||||
'doxyfile':
|
||||
'cpp.doxy.in',
|
||||
'headerfile':
|
||||
'cpp.header.html.in',
|
||||
'footerfile':
|
||||
'all.footer.html.in',
|
||||
'styleSheetfile':
|
||||
'all.styleSheet.css.in',
|
||||
'input_files':
|
||||
'ortools/linear_solver/linear_expr.h ' +
|
||||
'ortools/linear_solver/linear_solver.h ' +
|
||||
'ortools/linear_solver/model_exporter.h ' +
|
||||
'ortools/linear_solver/model_exporter_swig_helper.h ' +
|
||||
'ortools/linear_solver/model_validator.h ' +
|
||||
'ortools/gen/ortools/linear_solver/linear_solver.pb.h '
|
||||
},
|
||||
{
|
||||
'output_dir': 'cpp_routing',
|
||||
'project name': 'Routing',
|
||||
'title': 'C++ Reference: Routing',
|
||||
'doxyfile': 'cpp.doxy.in',
|
||||
'headerfile': 'cpp.header.html.in',
|
||||
'footerfile': 'all.footer.html.in',
|
||||
'styleSheetfile': 'all.styleSheet.css.in',
|
||||
'ortools/linear_solver/linear_expr.h ' +
|
||||
'ortools/linear_solver/linear_solver.h ' +
|
||||
'ortools/linear_solver/model_exporter.h ' +
|
||||
'ortools/linear_solver/model_exporter_swig_helper.h ' +
|
||||
'ortools/linear_solver/model_validator.h ' +
|
||||
'ortools/gen/ortools/linear_solver/linear_solver.pb.h '
|
||||
}, {
|
||||
'output_dir':
|
||||
'cpp_routing',
|
||||
'project name':
|
||||
'Routing',
|
||||
'title':
|
||||
'C++ Reference: Routing',
|
||||
'doxyfile':
|
||||
'cpp.doxy.in',
|
||||
'headerfile':
|
||||
'cpp.header.html.in',
|
||||
'footerfile':
|
||||
'all.footer.html.in',
|
||||
'styleSheetfile':
|
||||
'all.styleSheet.css.in',
|
||||
'input_files':
|
||||
'ortools/constraint_solver/constraint_solver.h ' +
|
||||
'ortools/constraint_solver/constraint_solveri.h ' +
|
||||
'ortools/constraint_solver/routing.h ' +
|
||||
'ortools/constraint_solver/routing_flags.h ' +
|
||||
'ortools/constraint_solver/routing_index_manager.h ' +
|
||||
'ortools/constraint_solver/routing_lp_scheduling.h ' +
|
||||
'ortools/constraint_solver/routing_neighborhoods.h ' +
|
||||
'ortools/constraint_solver/routing_parameters.h ' +
|
||||
'ortools/constraint_solver/routing_types.h ' +
|
||||
'ortools/gen/ortools/constraint_solver/assignment.pb.h ' +
|
||||
'ortools/gen/ortools/constraint_solver/demon_profiler.pb.h ' +
|
||||
'ortools/gen/ortools/constraint_solver/routing_enums.pb.h ' +
|
||||
'ortools/gen/ortools/constraint_solver/routing_parameters.pb.h ' +
|
||||
'ortools/gen/ortools/constraint_solver/search_limit.pb.h ' +
|
||||
'ortools/gen/ortools/constraint_solver/solver_parameters.pb.h '
|
||||
},
|
||||
{
|
||||
'ortools/constraint_solver/constraint_solver.h ' +
|
||||
'ortools/constraint_solver/constraint_solveri.h ' +
|
||||
'ortools/constraint_solver/routing.h ' +
|
||||
'ortools/constraint_solver/routing_flags.h ' +
|
||||
'ortools/constraint_solver/routing_index_manager.h ' +
|
||||
'ortools/constraint_solver/routing_lp_scheduling.h ' +
|
||||
'ortools/constraint_solver/routing_neighborhoods.h ' +
|
||||
'ortools/constraint_solver/routing_parameters.h ' +
|
||||
'ortools/constraint_solver/routing_types.h ' +
|
||||
'ortools/gen/ortools/constraint_solver/assignment.pb.h ' +
|
||||
'ortools/gen/ortools/constraint_solver/demon_profiler.pb.h ' +
|
||||
'ortools/gen/ortools/constraint_solver/routing_enums.pb.h ' +
|
||||
'ortools/gen/ortools/constraint_solver/routing_parameters.pb.h ' +
|
||||
'ortools/gen/ortools/constraint_solver/search_limit.pb.h ' +
|
||||
'ortools/gen/ortools/constraint_solver/solver_parameters.pb.h '
|
||||
}, {
|
||||
'output_dir': 'cpp',
|
||||
'project name': 'OR-Tools',
|
||||
'title': 'C++ Reference',
|
||||
@@ -197,11 +220,8 @@ def create_section_data():
|
||||
'headerfile': 'default.header.html.in',
|
||||
'footerfile': 'default.footer.html.in',
|
||||
'styleSheetfile': 'default.styleSheet.css.in',
|
||||
'input_files':
|
||||
'ortools ' +
|
||||
'tools/doc'
|
||||
},
|
||||
{
|
||||
'input_files': 'ortools ' + 'tools/doc'
|
||||
}, {
|
||||
'output_dir': 'dotnet',
|
||||
'project name': 'OR-Tools',
|
||||
'title': '.Net Reference',
|
||||
@@ -209,11 +229,8 @@ def create_section_data():
|
||||
'headerfile': 'dotnet.header.html.in',
|
||||
'footerfile': 'all.footer.html.in',
|
||||
'styleSheetfile': 'all.styleSheet.css.in',
|
||||
'input_files':
|
||||
'ortools ' +
|
||||
'tools/doc'
|
||||
},
|
||||
{
|
||||
'input_files': 'ortools ' + 'tools/doc'
|
||||
}, {
|
||||
'output_dir': 'java',
|
||||
'project name': 'OR-Tools',
|
||||
'title': 'Java Reference',
|
||||
@@ -221,21 +238,19 @@ def create_section_data():
|
||||
'headerfile': 'java.header.html.in',
|
||||
'footerfile': 'all.footer.html.in',
|
||||
'styleSheetfile': 'all.styleSheet.css.in',
|
||||
'input_files':
|
||||
'ortools ' +
|
||||
'tools/doc'
|
||||
}
|
||||
]
|
||||
'input_files': 'ortools ' + 'tools/doc'
|
||||
}]
|
||||
return sections
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
f = open('Version.txt', 'r')
|
||||
ft = f.read()
|
||||
f.close()
|
||||
version_file = open('Version.txt', 'r')
|
||||
version_file_data = version_file.read()
|
||||
version_file.close()
|
||||
major_pattern = re.compile(r'OR_TOOLS_MAJOR=(\d)')
|
||||
minor_pattern = re.compile(r'OR_TOOLS_MINOR=(\d)')
|
||||
major = major_pattern.findall(ft)[0]
|
||||
minor = minor_pattern.findall(ft)[0]
|
||||
major = major_pattern.findall(version_file_data)[0]
|
||||
minor = minor_pattern.findall(version_file_data)[0]
|
||||
|
||||
version_number = f'{major}.{minor}'
|
||||
main(version_number)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
# Build all the wheel artifacts for the platforms supported by manylinux1 and
|
||||
# export them to the specified location.
|
||||
#
|
||||
@@ -15,8 +15,7 @@
|
||||
# destination path for the wheels export.
|
||||
# BUILD_ROOT if not specified at command line, this value is used as the
|
||||
# root path for the build process.
|
||||
set -x
|
||||
set -eo pipefail
|
||||
set -euxo pipefail
|
||||
|
||||
DEFAULT_BUILD_ROOT="$HOME"
|
||||
DEFAULT_EXPORT_ROOT="${HOME}/export"
|
||||
@@ -45,7 +44,7 @@ function export_manylinux_wheel {
|
||||
# Arguments:
|
||||
# $1 the or-tools sources root directory
|
||||
# $2 the artifacts export directory
|
||||
if [ "$#" -ne 2 ]; then
|
||||
if [[ "$#" -ne 2 ]]; then
|
||||
echo "build_pypi_archives called with an illegal number of parameters"
|
||||
exit 1 # TODO return error and check it outside
|
||||
fi
|
||||
@@ -90,26 +89,26 @@ function test_installed {
|
||||
###############################################################################
|
||||
# Setup
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
if [[ -z "$1" ]]; then
|
||||
(>&2 usage)
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SRC_ROOT="$1";
|
||||
if [ -n "$2" ]; then BUILD_ROOT="$2"; fi
|
||||
if [ -n "$3" ]; then EXPORT_ROOT="$3"; fi
|
||||
if [[ -n "$2" ]]; then BUILD_ROOT="$2"; fi
|
||||
if [[ -n "$3" ]]; then EXPORT_ROOT="$3"; fi
|
||||
|
||||
if [ ! -d "$SRC_ROOT" ]; then
|
||||
if [[ ! -d "$SRC_ROOT" ]]; then
|
||||
(>&2 echo "Can't find or-tools sources at the specified location: $SRC_ROOT")
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$BUILD_ROOT" ]; then
|
||||
if [[ -z "$BUILD_ROOT" ]]; then
|
||||
(>&2 echo "\$BUILD_ROOT is not set, using default location: $DEFAULT_BUILD_ROOT")
|
||||
BUILD_ROOT="$DEFAULT_BUILD_ROOT"
|
||||
fi
|
||||
|
||||
if [ -z "$EXPORT_ROOT" ]; then
|
||||
if [[ -z "$EXPORT_ROOT" ]]; then
|
||||
(>&2 echo "\$EXPORT_ROOT is not set, using default location: $DEFAULT_EXPORT_ROOT")
|
||||
EXPORT_ROOT="$DEFAULT_EXPORT_ROOT"
|
||||
fi
|
||||
@@ -145,7 +144,7 @@ mkdir -p "${BUILD_ROOT}"
|
||||
mkdir -p "${EXPORT_ROOT}"
|
||||
|
||||
# Make third_party if needed
|
||||
if [ ! -f "${SRC_ROOT}/Makefile.local" ]; then
|
||||
if [[ ! -f "${SRC_ROOT}/Makefile.local" ]]; then
|
||||
(>&2 echo "\${SRC_ROOT}/Makefile.local doesn't exist, building third_party")
|
||||
cd "$SRC_ROOT"
|
||||
make third_party
|
||||
@@ -159,7 +158,7 @@ do
|
||||
PYTAG=$(basename "$PYROOT")
|
||||
# Check for platforms to be skipped
|
||||
_skip=$(contains_element "$PYTAG" "${SKIP[@]}")
|
||||
if [ "$_skip" -eq '0' ]; then
|
||||
if [[ "$_skip" -eq '0' ]]; then
|
||||
(>&2 echo "skipping deprecated platform $PYTAG")
|
||||
continue
|
||||
fi
|
||||
@@ -184,14 +183,14 @@ do
|
||||
|
||||
# Hack wheel file to rename it manylinux1 since manylinux2010 is still not
|
||||
# supported by default pip on most distro.
|
||||
FILE=(${EXPORT_ROOT}/ortools-*-${PYTAG}-manylinux2010_x86_64.whl)
|
||||
FILE=${EXPORT_ROOT}/ortools-*-${PYTAG}-manylinux2010_x86_64.whl
|
||||
echo "Old wheel file to hack: ${WHEEL_FILE}"
|
||||
|
||||
# Unpack to hack it
|
||||
unzip "$FILE" -d /tmp
|
||||
rm -f $FILE
|
||||
WHEEL_FILE=(/tmp/ortools-*.dist-info/WHEEL)
|
||||
RECORD_FILE=(/tmp/ortools-*.dist-info/RECORD)
|
||||
rm -f "$FILE"
|
||||
WHEEL_FILE=/tmp/ortools-*.dist-info/WHEEL
|
||||
RECORD_FILE=/tmp/ortools-*.dist-info/RECORD
|
||||
|
||||
# Save old hash and size, in order to look them up in RECORD
|
||||
# see: https://github.com/pypa/pip/blob/c9df690f3b5bb285a855953272e6fe24f69aa08a/src/pip/_internal/wheel.py#L71-L84
|
||||
@@ -204,24 +203,24 @@ hashlib.sha256(open('${WHEEL_FILE}', 'rb').read())\
|
||||
.digest())\
|
||||
.decode('latin1')\
|
||||
.rstrip('='))\""
|
||||
OLD_HASH=$(eval ${WHEEL_HASH_CMD})
|
||||
OLD_SIZE=$(wc -c < ${WHEEL_FILE})
|
||||
OLD_HASH=$(eval "${WHEEL_HASH_CMD}")
|
||||
OLD_SIZE=$(wc -c < "${WHEEL_FILE}")
|
||||
|
||||
# Hack the WHEEL file and recompute the new hash
|
||||
sed -i 's/manylinux2010/manylinux1/' ${WHEEL_FILE}
|
||||
NEW_HASH=$(eval ${WHEEL_HASH_CMD})
|
||||
NEW_SIZE=$(wc -c < ${WHEEL_FILE})
|
||||
sed -i 's/manylinux2010/manylinux1/' "${WHEEL_FILE}"
|
||||
NEW_HASH=$(eval "${WHEEL_HASH_CMD}")
|
||||
NEW_SIZE=$(wc -c < "${WHEEL_FILE}")
|
||||
# Update RECORD file with the new hash and size
|
||||
sed -i "s/${OLD_HASH},${OLD_SIZE}/${NEW_HASH},${NEW_SIZE}/" ${RECORD_FILE}
|
||||
sed -i "s/${OLD_HASH},${OLD_SIZE}/${NEW_HASH},${NEW_SIZE}/" "${RECORD_FILE}"
|
||||
|
||||
# Repack it as a manylinux1 package
|
||||
WHEEL_FILE=${FILE//manylinux2010/manylinux1}
|
||||
(cd /tmp; zip -r ${WHEEL_FILE} ortools ortools-*; rm -r ortools*)
|
||||
(cd /tmp; zip -r "${WHEEL_FILE}" ortools ortools-*; rm -r ortools*)
|
||||
echo "New hacked wheel file: ${WHEEL_FILE}"
|
||||
|
||||
# verify manylinux1 package integrity using pex
|
||||
pip install pex
|
||||
python -m pex -o ort.pex ${WHEEL_FILE}
|
||||
python -m pex -o ort.pex "${WHEEL_FILE}"
|
||||
rm ort.pex
|
||||
|
||||
# Restore environment
|
||||
|
||||
@@ -9,7 +9,7 @@ from nbformat import v4
|
||||
input_file = sys.argv[1]
|
||||
print(f'reading {input_file}')
|
||||
with open(input_file) as fpin:
|
||||
text = fpin.read()
|
||||
text = fpin.read()
|
||||
|
||||
# Compute output file path.
|
||||
output_file = input_file
|
||||
@@ -27,12 +27,12 @@ output_file = output_file.replace('samples/', '')
|
||||
nbook = v3.reads_py('')
|
||||
nbook = v4.upgrade(nbook) # Upgrade v3 to v4
|
||||
|
||||
print(f'Adding copyright cell...')
|
||||
copyright = '##### Copyright 2020 The OR-Tools Authors.'
|
||||
nbook['cells'].append(v4.new_markdown_cell(copyright))
|
||||
print('Adding copyright cell...')
|
||||
google = '##### Copyright 2020 Google LLC.'
|
||||
nbook['cells'].append(v4.new_markdown_cell(google))
|
||||
|
||||
print(f'Adding license cell...')
|
||||
license = '''Licensed under the Apache License, Version 2.0 (the "License");
|
||||
print('Adding license cell...')
|
||||
apache = '''Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
@@ -44,13 +44,13 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
'''
|
||||
nbook['cells'].append(v4.new_markdown_cell(license))
|
||||
nbook['cells'].append(v4.new_markdown_cell(apache))
|
||||
|
||||
print(f'Adding Title cell...')
|
||||
print('Adding Title cell...')
|
||||
basename = '# ' + os.path.basename(input_file).replace('.py', '')
|
||||
nbook['cells'].append(v4.new_markdown_cell(basename))
|
||||
|
||||
print(f'Adding link cell...')
|
||||
print('Adding link cell...')
|
||||
github_logo = 'https://raw.githubusercontent.com/google/or-tools/master/tools/github_32px.png'
|
||||
github_path = 'https://github.com/google/or-tools/blob/master/' + input_file
|
||||
|
||||
@@ -66,13 +66,15 @@ link = f'''<table align=\"left\">
|
||||
</table>'''
|
||||
nbook['cells'].append(v4.new_markdown_cell(link))
|
||||
|
||||
print(f'Installing ortools cell...')
|
||||
install_doc = 'First, you must install [ortools](https://pypi.org/project/ortools/) package in this colab.'
|
||||
print('Installing ortools cell...')
|
||||
install_doc = ('First, you must install '
|
||||
'[ortools](https://pypi.org/project/ortools/) package in this '
|
||||
'colab.')
|
||||
nbook['cells'].append(v4.new_markdown_cell(install_doc))
|
||||
install_cmd = '!pip install ortools'
|
||||
nbook['cells'].append(v4.new_code_cell(install_cmd))
|
||||
|
||||
print(f'Adding code cell...')
|
||||
print('Adding code cell...')
|
||||
all_blocks = ast.parse(text).body
|
||||
print(f'number of bocks: {len(all_blocks)}')
|
||||
line_start = [c.lineno - 1 for c in all_blocks]
|
||||
@@ -81,26 +83,26 @@ lines = text.split('\n')
|
||||
|
||||
full_text = ''
|
||||
for c_block, s, e in zip(all_blocks, line_start, line_start[1:] + [len(lines)]):
|
||||
print(c_block)
|
||||
c_text = '\n'.join(lines[s:e])
|
||||
if isinstance(c_block,
|
||||
ast.If) and c_block.test.comparators[0].s == '__main__':
|
||||
print('Skip if main', lines[s:e])
|
||||
elif isinstance(c_block, ast.FunctionDef) and c_block.name == 'main':
|
||||
# remove start and de-indent lines
|
||||
c_lines = lines[s + 1:e]
|
||||
spaces_to_delete = c_block.body[0].col_offset
|
||||
fixed_lines = [
|
||||
n_line[spaces_to_delete:]
|
||||
if n_line.startswith(' ' * spaces_to_delete) else n_line
|
||||
for n_line in c_lines
|
||||
]
|
||||
fixed_text = '\n'.join(fixed_lines)
|
||||
print('Unwrapping main function')
|
||||
full_text += fixed_text
|
||||
else:
|
||||
print('appending', c_block)
|
||||
full_text += c_text + '\n'
|
||||
print(c_block)
|
||||
c_text = '\n'.join(lines[s:e])
|
||||
if isinstance(c_block,
|
||||
ast.If) and c_block.test.comparators[0].s == '__main__':
|
||||
print('Skip if main', lines[s:e])
|
||||
elif isinstance(c_block, ast.FunctionDef) and c_block.name == 'main':
|
||||
# remove start and de-indent lines
|
||||
c_lines = lines[s + 1:e]
|
||||
spaces_to_delete = c_block.body[0].col_offset
|
||||
fixed_lines = [
|
||||
n_line[spaces_to_delete:]
|
||||
if n_line.startswith(' ' * spaces_to_delete) else n_line
|
||||
for n_line in c_lines
|
||||
]
|
||||
fixed_text = '\n'.join(fixed_lines)
|
||||
print('Unwrapping main function')
|
||||
full_text += fixed_text
|
||||
else:
|
||||
print('appending', c_block)
|
||||
full_text += c_text + '\n'
|
||||
|
||||
nbook['cells'].append(v4.new_code_cell(full_text))
|
||||
|
||||
@@ -108,4 +110,4 @@ jsonform = v4.writes(nbook) + '\n'
|
||||
|
||||
print(f'writing {output_file}')
|
||||
with open(output_file, 'w') as fpout:
|
||||
fpout.write(jsonform)
|
||||
fpout.write(jsonform)
|
||||
|
||||
@@ -11,7 +11,7 @@ declare -r SRC=$(basename "$FILE")
|
||||
# shellcheck disable=SC2155
|
||||
declare -r PACKAGES_PATH=$(realpath --relative-to="${FILE%/*}" packages)
|
||||
if [[ $FILE == *.cs ]] ; then
|
||||
declare -r LANG_VERSION=" <LangVersion>7.3</LangVersion>"
|
||||
declare -r LANG_VERSION="<LangVersion>7.3</LangVersion>"
|
||||
declare -r OR_TOOLS_PKG="Google.OrTools"
|
||||
else
|
||||
declare -r LANG_VERSION=""
|
||||
@@ -51,7 +51,7 @@ cat >"$FILE_PROJ" <<EOL
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
${LANG_VERSION}
|
||||
${LANG_VERSION}
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<EnableDefaultItems>false</EnableDefaultItems>
|
||||
<!-- see https://github.com/dotnet/docs/issues/12237 -->
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euxo pipefail
|
||||
|
||||
if [ ! -f "$DOTNET_SNK" ]; then
|
||||
if [[ -z "${DOTNET_SNK}" ]]; then
|
||||
echo "DOTNET_SNK: not found !" | tee build.log
|
||||
exit 1
|
||||
fi
|
||||
@@ -35,16 +35,22 @@ for i in "${PY[@]}"; do
|
||||
done
|
||||
|
||||
# java
|
||||
echo "JAVA_HOME: ${JAVA_HOME}" | tee -a build.log
|
||||
command -v java
|
||||
command -v java | xargs echo "java: " | tee -a build.log
|
||||
command -v javac
|
||||
command -v javac | xargs echo "javac: " | tee -a build.log
|
||||
command -v jar
|
||||
command -v jar | xargs echo "jar: " | tee -a build.log
|
||||
command -v mvn
|
||||
command -v mvn | xargs echo "mvn: " | tee -a build.log
|
||||
java -version 2>&1 | head -n 1 | grep 1.8
|
||||
# maven require JAVA_HOME
|
||||
if [[ -z "${JAVA_HOME}" ]]; then
|
||||
echo "JAVA_HOME: not found !" | tee build.log
|
||||
exit 1
|
||||
else
|
||||
echo "JAVA_HOME: ${JAVA_HOME}" | tee -a build.log
|
||||
command -v java
|
||||
command -v java | xargs echo "java: " | tee -a build.log
|
||||
command -v javac
|
||||
command -v javac | xargs echo "javac: " | tee -a build.log
|
||||
command -v jar
|
||||
command -v jar | xargs echo "jar: " | tee -a build.log
|
||||
command -v mvn
|
||||
command -v mvn | xargs echo "mvn: " | tee -a build.log
|
||||
java -version 2>&1 | head -n 1 | grep 1.8
|
||||
fi
|
||||
|
||||
# C#
|
||||
command -v dotnet
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -x
|
||||
set -e
|
||||
set -euxo pipefail
|
||||
|
||||
if [ ! -f "$DOTNET_SNK" ]; then
|
||||
if [[ -z "${DOTNET_SNK}" ]]; then
|
||||
echo "DOTNET_SNK: not found !" | tee build.log
|
||||
exit 1
|
||||
fi
|
||||
@@ -20,14 +19,23 @@ command -v gcc | xargs echo "gcc: " | tee -a build.log
|
||||
command -v cmake | xargs echo "cmake: " | tee -a build.log
|
||||
command -v make | xargs echo "make: " | tee -a build.log
|
||||
command -v swig | xargs echo "swig: " | tee -a build.log
|
||||
|
||||
# python
|
||||
command -v python3 | xargs echo "python3: " | tee -a build.log
|
||||
|
||||
# java
|
||||
echo "JAVA_HOME: ${JAVA_HOME}" | tee -a build.log
|
||||
command -v java | xargs echo "java: " | tee -a build.log
|
||||
command -v javac | xargs echo "javac: " | tee -a build.log
|
||||
command -v jar | xargs echo "jar: " | tee -a build.log
|
||||
command -v mvn | xargs echo "mvn: " | tee -a build.log
|
||||
# maven require JAVA_HOME
|
||||
if [[ -z "${JAVA_HOME}" ]]; then
|
||||
echo "JAVA_HOME: not found !" | tee build.log
|
||||
exit 1
|
||||
else
|
||||
echo "JAVA_HOME: ${JAVA_HOME}" | tee -a build.log
|
||||
command -v java | xargs echo "java: " | tee -a build.log
|
||||
command -v javac | xargs echo "javac: " | tee -a build.log
|
||||
command -v jar | xargs echo "jar: " | tee -a build.log
|
||||
command -v mvn | xargs echo "mvn: " | tee -a build.log
|
||||
fi
|
||||
|
||||
# dotnet
|
||||
command -v dotnet | xargs echo "dotnet: " | tee -a build.log
|
||||
|
||||
|
||||
Reference in New Issue
Block a user