127 lines
3.9 KiB
Plaintext
127 lines
3.9 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "google",
|
|
"metadata": {},
|
|
"source": [
|
|
"##### Copyright 2021 Google LLC."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "apache",
|
|
"metadata": {},
|
|
"source": [
|
|
"Licensed under the Apache License, Version 2.0 (the \"License\");\n",
|
|
"you may not use this file except in compliance with the License.\n",
|
|
"You may obtain a copy of the License at\n",
|
|
"\n",
|
|
" http://www.apache.org/licenses/LICENSE-2.0\n",
|
|
"\n",
|
|
"Unless required by applicable law or agreed to in writing, software\n",
|
|
"distributed under the License is distributed on an \"AS IS\" BASIS,\n",
|
|
"WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
|
|
"See the License for the specific language governing permissions and\n",
|
|
"limitations under the License.\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "basename",
|
|
"metadata": {},
|
|
"source": [
|
|
"# check_dependencies"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "link",
|
|
"metadata": {},
|
|
"source": [
|
|
"<table align=\"left\">\n",
|
|
"<td>\n",
|
|
"<a href=\"https://colab.research.google.com/github/google/or-tools/blob/master/examples/notebook/contrib/check_dependencies.ipynb\"><img src=\"https://raw.githubusercontent.com/google/or-tools/master/tools/colab_32px.png\"/>Run in Google Colab</a>\n",
|
|
"</td>\n",
|
|
"<td>\n",
|
|
"<a href=\"https://github.com/google/or-tools/blob/master/examples/contrib/check_dependencies.py\"><img src=\"https://raw.githubusercontent.com/google/or-tools/master/tools/github_32px.png\"/>View source on GitHub</a>\n",
|
|
"</td>\n",
|
|
"</table>"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "doc",
|
|
"metadata": {},
|
|
"source": [
|
|
"First, you must install [ortools](https://pypi.org/project/ortools/) package in this colab."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "install",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"!pip install ortools"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "code",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import logging, sys, inspect\n",
|
|
"from os.path import dirname, abspath\n",
|
|
"from optparse import OptionParser\n",
|
|
"\n",
|
|
"\n",
|
|
"def log_error_and_exit(error_message):\n",
|
|
" logging.error(error_message)\n",
|
|
" raise SystemExit\n",
|
|
"\n",
|
|
"\n",
|
|
"#try to import setuptools\n",
|
|
"try:\n",
|
|
" from setuptools import setup, Extension\n",
|
|
" from setuptools.command import easy_install\n",
|
|
"except ImportError:\n",
|
|
" log_error_and_exit(\"\"\"setuptools is not installed for \\\"\"\"\" + sys.executable +\n",
|
|
" \"\"\"\\\"\n",
|
|
"Follow this link for installing instructions :\n",
|
|
"https://pypi.python.org/pypi/setuptools\n",
|
|
"make sure you use \\\"\"\"\" + sys.executable + \"\"\"\\\" during the installation\"\"\")\n",
|
|
"\n",
|
|
"from pkg_resources import parse_version\n",
|
|
"\n",
|
|
"\n",
|
|
"def notinstalled(modulename):\n",
|
|
" return modulename + \"\"\" could not be imported for \\\"\"\"\" + sys.executable + \"\"\"\\\"\n",
|
|
"Set PYTHONPATH to the output of this command \\\"make print-OR_TOOLS_PYTHONPATH\\\" before running the examples\"\"\"\n",
|
|
"\n",
|
|
"\n",
|
|
"def wrong_module(module_file, modulename):\n",
|
|
" return \"\"\"\n",
|
|
"The python examples are not importing the \"\"\" + modulename + \"\"\" module from the sources.\n",
|
|
"Remove the site-package that contains \\\"\"\"\" + module_file + \"\"\"\\\", either manually or by using pip, and rerun this script again.\"\"\"\n",
|
|
"\n",
|
|
"\n",
|
|
"# Returns the n_th parent of file\n",
|
|
"def n_dirname(n, file):\n",
|
|
" directory = file\n",
|
|
" for x in range(0, n):\n",
|
|
" directory = dirname(directory)\n",
|
|
" return directory\n",
|
|
"\n",
|
|
"\n"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|