Skip to content

Commit

Permalink
Merge branch 'dev-venv'. Close #243.
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanperez-keera committed Dec 14, 2023
2 parents 21cd2b5 + 0a8d946 commit 5cc2353
Show file tree
Hide file tree
Showing 19 changed files with 47 additions and 200 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ jobs:
runs-on: ubuntu-latest

env:
PYTHONPATH: /opt/ikos/lib/python3.10/site-packages/
MAKEFLAGS: -j4

steps:
Expand All @@ -20,7 +19,7 @@ jobs:
gcc g++ cmake libgmp-dev libboost-dev libboost-filesystem-dev \
libboost-thread-dev libboost-test-dev \
libsqlite3-dev libtbb-dev libz-dev libedit-dev \
python3 python3-pygments python3-distutils python3-pip \
python3 python3-pip \
llvm-14 llvm-14-dev llvm-14-tools clang-14
- name: Compile IKOS
run: |
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/build-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install dependencies
run: |
pip3 install setuptools
- name: Install dependencies
run: |
brew tap nasa-sw-vnv/core
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,11 @@ To build and run the analyzer, you will need the following dependencies:
* CMake >= 3.4.3
* GMP >= 4.3.1
* Boost >= 1.55
* Python 2 >= 2.7.3 or Python 3 >= 3.3
* Python >= 3.3
* SQLite >= 3.6.20
* TBB >= 2
* LLVM and Clang 14.0.x
* (Optional) APRON >= 0.9.10
* (Optional) Pygments
Most of them can be installed using your package manager.
Expand Down
61 changes: 25 additions & 36 deletions analyzer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -333,48 +333,37 @@ else()
"${CMAKE_CURRENT_SOURCE_DIR}/python/ikos/settings.py.in"
VERBATIM)
endif()
add_custom_target(ikos-python-settings ALL
DEPENDS "python/ikos/settings/__init__.py"
)

# setup.py
configure_file(python/setup.py.in python/setup.py @ONLY)

file(GLOB PYTHON_FILES python/ikos/*.py)

# python module
add_custom_command(
OUTPUT
"python/build/lib/ikos/__init__.py"
COMMAND
${PYTHON_EXECUTABLE} setup.py -q build
--build-base=build
--build-purelib=build/lib
COMMAND
${CMAKE_COMMAND} -E touch "build/lib/ikos/__init__.py" # udpate timestamp
WORKING_DIRECTORY
"${CMAKE_CURRENT_BINARY_DIR}/python"
DEPENDS
"${CMAKE_CURRENT_BINARY_DIR}/python/setup.py"
"${CMAKE_CURRENT_BINARY_DIR}/python/ikos/settings/__init__.py"
${PYTHON_FILES}
)
add_custom_target(ikos-python ALL
DEPENDS "python/build/lib/ikos/__init__.py"
)
option(INSTALL_PYTHON_VIRTUALENV "Install a python virtual environment for ikos" ON)
option(PYTHON_VENV_EXECUTABLE "Path to the python executable of an existing virtual environment")
if (INSTALL_PYTHON_VIRTUALENV)
install(CODE "
message(STATUS \"Running python -m venv ${CMAKE_INSTALL_PREFIX}/libexec\")
execute_process(COMMAND \"${PYTHON_EXECUTABLE}\" -m venv \"${CMAKE_INSTALL_PREFIX}/libexec\")
install(CODE "
set(PIP_INSTALL
\"${PYTHON_EXECUTABLE}\"
\"-m\"
\"pip\"
\"install\"
)
if (DEFINED ENV{DESTDIR})
list(APPEND PIP_INSTALL \"--target=\$ENV{DESTDIR}\")
endif()
list(APPEND PIP_INSTALL \".\")
message(STATUS \"Running ${CMAKE_INSTALL_PREFIX}/libexec/bin/python -m pip install -U pip\")
execute_process(COMMAND \"${CMAKE_INSTALL_PREFIX}/libexec/bin/python\" -m pip install -U pip)
execute_process(COMMAND \${PIP_INSTALL}
WORKING_DIRECTORY \"${CMAKE_CURRENT_BINARY_DIR}/python\")
")
message(STATUS \"Running ${CMAKE_INSTALL_PREFIX}/libexec/bin/python -m pip install -U pygments setuptools\")
execute_process(COMMAND \"${CMAKE_INSTALL_PREFIX}/libexec/bin/python\" -m pip install pygments setuptools)
message(STATUS \"Running ${CMAKE_INSTALL_PREFIX}/libexec/bin/python -m pip install .\")
execute_process(COMMAND \"${CMAKE_INSTALL_PREFIX}/libexec/bin/python\" -m pip install .
WORKING_DIRECTORY \"${CMAKE_CURRENT_BINARY_DIR}/python\")
")
set(PYTHON_VENV_EXECUTABLE "${CMAKE_INSTALL_PREFIX}/libexec/bin/python")
else()
# This can be used by the Homebrew formula or by package maintainers.
if (NOT PYTHON_VENV_EXECUTABLE)
message(FATAL_ERROR "Please specify -DPYTHON_VENV_EXECUTABLE=<path> when using -DINSTALL_PYTHON_VIRTUALENV=OFF")
endif()
endif()

# python web resources
install(DIRECTORY python/ikos/view DESTINATION share/ikos)
Expand Down
3 changes: 1 addition & 2 deletions analyzer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,11 @@ To build and run the analyzer, you will need the following dependencies:
* CMake >= 3.4.3
* GMP >= 4.3.1
* Boost >= 1.55
* Python 2 >= 2.7.3 or Python 3 >= 3.3
* Python >= 3.3
* SQLite >= 3.6.20
* TBB >= 2
* LLVM and Clang 14.0.x
* (Optional) APRON >= 0.9.10
* (Optional) Pygments
* IKOS Core
* IKOS AR
* IKOS LLVM Frontend
Expand Down
3 changes: 2 additions & 1 deletion analyzer/python/ikos/highlight.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
# UNILATERAL TERMINATION OF THIS AGREEMENT.
#
###############################################################################
from ikos import html
import html

from ikos import log


Expand Down
47 changes: 0 additions & 47 deletions analyzer/python/ikos/html.py

This file was deleted.

16 changes: 4 additions & 12 deletions analyzer/python/ikos/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,13 @@
# UNILATERAL TERMINATION OF THIS AGREEMENT.
#
###############################################################################
try:
# Python 3
from http.server import HTTPServer, BaseHTTPRequestHandler
from urllib.parse import parse_qs, urlencode
from urllib.request import urlopen
except ImportError:
# Python 2
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
from urlparse import parse_qs
from urllib import urlencode
from urllib2 import urlopen

import os
from errno import EAFNOSUPPORT
from http.server import HTTPServer, BaseHTTPRequestHandler
from socket import AF_INET, AF_INET6
import os
from urllib.parse import parse_qs, urlencode
from urllib.request import urlopen

class HTTPServerIPv6(HTTPServer):
'''
Expand Down
2 changes: 1 addition & 1 deletion analyzer/python/ikos/output_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def __init__(self, path):
self.con = sqlite3.connect(path)

# Use 'str' as text factory since it's the type of string literals
# This is bytes in python 2 and unicode in python 3
# This is unicode
self.con.text_factory = str

def close(self):
Expand Down
2 changes: 1 addition & 1 deletion analyzer/python/ikos/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
###############################################################################
import argparse
import collections
import html
import io
import json
import operator
Expand All @@ -56,7 +57,6 @@

from ikos import args
from ikos import colors
from ikos import html
from ikos import log
from ikos import report
from ikos import settings
Expand Down
12 changes: 1 addition & 11 deletions analyzer/script/ikos-config.py.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!@PYTHON_EXECUTABLE@
#!@PYTHON_VENV_EXECUTABLE@
###############################################################################
#
# ikos-config: get configuration information
Expand Down Expand Up @@ -44,16 +44,6 @@ import os.path
import sys

if __name__ == '__main__':
# Add ../lib/pythonX.Y/site-packages at the beginning of the python path
root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
site_pkg_dir = os.path.join(
root_dir,
'lib',
'python%d.%d' % (sys.version_info.major, sys.version_info.minor),
'site-packages',
)
sys.path.insert(1, site_pkg_dir)

try:
import ikos.settings
except ImportError:
Expand Down
12 changes: 1 addition & 11 deletions analyzer/script/ikos-report.py.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!@PYTHON_EXECUTABLE@
#!@PYTHON_VENV_EXECUTABLE@
###############################################################################
#
# ikos-report: generate an analysis report from a result database
Expand Down Expand Up @@ -44,16 +44,6 @@ import os.path
import sys

if __name__ == '__main__':
# Add ../lib/pythonX.Y/site-packages at the beginning of the python path
root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
site_pkg_dir = os.path.join(
root_dir,
'lib',
'python%d.%d' % (sys.version_info.major, sys.version_info.minor),
'site-packages',
)
sys.path.insert(1, site_pkg_dir)

try:
import ikos.report
except ImportError:
Expand Down
12 changes: 1 addition & 11 deletions analyzer/script/ikos-scan-c++.py.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!@PYTHON_EXECUTABLE@
#!@PYTHON_VENV_EXECUTABLE@
###############################################################################
#
# ikos-scan-c++: wrapper around clang++ for ikos-scan
Expand Down Expand Up @@ -44,16 +44,6 @@ import os.path
import sys

if __name__ == '__main__':
# Add ../lib/pythonX.Y/site-packages at the beginning of the python path
root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
site_pkg_dir = os.path.join(
root_dir,
'lib',
'python%d.%d' % (sys.version_info.major, sys.version_info.minor),
'site-packages',
)
sys.path.insert(1, site_pkg_dir)

try:
import ikos.scan
except ImportError:
Expand Down
12 changes: 1 addition & 11 deletions analyzer/script/ikos-scan-cc.py.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!@PYTHON_EXECUTABLE@
#!@PYTHON_VENV_EXECUTABLE@
###############################################################################
#
# ikos-scan-cc: wrapper around clang for ikos-scan
Expand Down Expand Up @@ -44,16 +44,6 @@ import os.path
import sys

if __name__ == '__main__':
# Add ../lib/pythonX.Y/site-packages at the beginning of the python path
root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
site_pkg_dir = os.path.join(
root_dir,
'lib',
'python%d.%d' % (sys.version_info.major, sys.version_info.minor),
'site-packages',
)
sys.path.insert(1, site_pkg_dir)

try:
import ikos.scan
except ImportError:
Expand Down
12 changes: 1 addition & 11 deletions analyzer/script/ikos-scan-extract.py.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!@PYTHON_EXECUTABLE@
#!@PYTHON_VENV_EXECUTABLE@
###############################################################################
#
# ikos-scan-extract: extract the llvm bitcode generated for a given file
Expand Down Expand Up @@ -44,16 +44,6 @@ import os.path
import sys

if __name__ == '__main__':
# Add ../lib/pythonX.Y/site-packages at the beginning of the python path
root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
site_pkg_dir = os.path.join(
root_dir,
'lib',
'python%d.%d' % (sys.version_info.major, sys.version_info.minor),
'site-packages',
)
sys.path.insert(1, site_pkg_dir)

try:
import ikos.scan
except ImportError:
Expand Down
12 changes: 1 addition & 11 deletions analyzer/script/ikos-scan.py.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!@PYTHON_EXECUTABLE@
#!@PYTHON_VENV_EXECUTABLE@
###############################################################################
#
# ikos-scan: tool to analyze a whole project
Expand Down Expand Up @@ -44,16 +44,6 @@ import os.path
import sys

if __name__ == '__main__':
# Add ../lib/pythonX.Y/site-packages at the beginning of the python path
root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
site_pkg_dir = os.path.join(
root_dir,
'lib',
'python%d.%d' % (sys.version_info.major, sys.version_info.minor),
'site-packages',
)
sys.path.insert(1, site_pkg_dir)

try:
import ikos.scan
except ImportError:
Expand Down
12 changes: 1 addition & 11 deletions analyzer/script/ikos-view.py.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!@PYTHON_EXECUTABLE@
#!@PYTHON_VENV_EXECUTABLE@
###############################################################################
#
# ikos-view: web server to display an analysis report
Expand Down Expand Up @@ -44,16 +44,6 @@ import os.path
import sys

if __name__ == '__main__':
# Add ../lib/pythonX.Y/site-packages at the beginning of the python path
root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
site_pkg_dir = os.path.join(
root_dir,
'lib',
'python%d.%d' % (sys.version_info.major, sys.version_info.minor),
'site-packages',
)
sys.path.insert(1, site_pkg_dir)

try:
import ikos.view
except ImportError:
Expand Down
Loading

0 comments on commit 5cc2353

Please sign in to comment.