Skip to content

Commit

Permalink
Prepare release v0.2
Browse files Browse the repository at this point in the history
* cpptcl.eval is now a C++ implementation
* cpptcl.interpreter.get returns non owning pointer
* native to python and python to native dispatching
* Create directory per example

 Bugfixes
* import from tcl did not work on nested packages
* Python GIL is acquired and released appropriately

Library updates
* Add winappdbg library wrappers
* Update pybind11 to 2.6.2
* Update asmjit to 5bc166efdb419f8
* Update PolyHook 2 to 84d6be2a20
* Update cpptcl to 9384cf9551520
  • Loading branch information
ktksgit committed May 30, 2021
1 parent bf85f88 commit e69c456
Show file tree
Hide file tree
Showing 286 changed files with 54,116 additions and 19,848 deletions.
18 changes: 9 additions & 9 deletions SConstruct
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os

AddOption('--mingw',
AddOption('--nomingw',
dest='mingw',
action='store_true',
action='store_false',
default=True,
help='mingw build (defaults to gcc)')

Expand Down Expand Up @@ -51,11 +51,13 @@ if is_mingw == True:
variables=vars,
tools = ['mingw']
)
env["is_mingw"] = True
else:
env = Environment(
variables=vars,
TARGET_ARCH='x86'
)
env["is_mingw"] = False
print ('Visual Studio build')
env.AppendUnique(CXXFLAGS =['/EHsc'])

Expand Down Expand Up @@ -98,6 +100,8 @@ if is_mingw:
env.AppendUnique(CXXFLAGS=['-g'])
env.AppendUnique(CFLAGS=['-g'])
else:
env.AppendUnique(CXXFLAGS=['/std:c++17']
)
if nodebug or releasedebug:
env.AppendUnique(CPPFLAGS =['/W3', '/MD', '/Od'],#, '/Gs'],
LINKFLAGS=['/RELEASE']
Expand Down Expand Up @@ -131,8 +135,6 @@ tclStubLib_obj)= env.SConscript('libs/tcl8.3.2/SConscript_main.py',
exports='nodebug is_mingw windows'
)

tcl_dll_full_path = os.path.join(tcl_bin_install_dir, tcl_lib_name + '.dll')

env.AppendUnique(CPPPATH = [capstone_include_path,
tcl_includes],
# CPPDEFINES = {'__thiscall' : ''},
Expand All @@ -149,23 +151,21 @@ Export('pyenv')
(tclpython_dll,
static_cpptcl,
static_cpptcl_no_stubs,
py3_obj,
cpptcl_includes,
pybind11_includes) = pyenv.SConscript(f'{variant_dir}/libs/libs.SConscript',
py3_static) = pyenv.SConscript(f'{variant_dir}/libs/libs.SConscript',
exports='tclStubLib_obj',
)

all_targets = [
tclpython_dll,
static_cpptcl,
static_cpptcl_no_stubs,
py3_obj
py3_static
]

env.CompileCommands('object', all_targets)

if is_mingw and env["windows"]:
install_dir = Dir('#/bin').abspath
env.Install(install_dir, tcl_dll_full_path)

path = os.environ['PATH']
path = [x for x in path.split(';') if 'mingw32' in x][0]
Expand Down
47 changes: 33 additions & 14 deletions examples/bootstrap.tcl
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# This file will bootstrap the current directory
# It adds python path to the environment variable PATH
# It adds this SDKs bin path, namely ../bin, to the environment variable PATH
#
# A python interpreter is created
# It adds this path to Python's sys.path
# It adds this SDKs scripts path, namely ../scripts, to Python's sys.path
#
# How to use
# ----------
# Add line
# source <sdk_path>/examples/bootstrap.tcl
# to the very beginning of <diggles_path>/data/systeminit.tcl
# where
# <sdk_path> is to be replaced with the path where you unpacked the SDK
# <diggles_path> is to be replaced with the path where you're Diggles installation (Diggles.exe) is located

set info_script [ info script ]
if { $info_script == "" } {
error "Use \"source bootstrap.tcl\""
Expand All @@ -11,32 +28,34 @@ if { [catch {puts "Writing stdout to console"} fid] } {

set bootstrap_path [ file dirname $info_script ]
set package_bin_path $bootstrap_path/../bin
set python_path $package_bin_path/python36
set jupyter_qtconsole $python_path/scripts/jupyter-qtconsole.exe
set package_scripts_path $bootstrap_path/../scripts


if { [ info exists python_path] } {
# Switch to user supplied python path
} else {
# Use self-contained python 3.6 32-bit installation
set python_path $package_bin_path/python36
}

puts $stdout "bootstrap_path $bootstrap_path"
puts $stdout "package_bin_path $package_bin_path"
puts $stdout "package_scripts_path $package_scripts_path"
puts $stdout "python_path $python_path"

set env(PATH) "$package_bin_path;$python_path;$env(PATH);"
set env(PATH) "$package_bin_path;$python_path;"
set env(PYTHONHOME) $python_path
set env(PYTHONPATH) "$python_path/lib;$python_path/dlls;"

load tclandpython.dll

set py [PythonInterpreter]
$py exec "
import sys
import site
# This makes import from the example directory possible
sys.path.append('$bootstrap_path')
sys.path.append('$package_scripts_path')
site.addsitedir('$python_path/lib/site-packages')
"

# $py import pytcl
# $py import cpptcl

# Use exclusively first:
# $py import gui.console
# $py gui.console.main()

# or second:
# $py import ipy_kernel
# $py eval ipy_kernel.main('$jupyter_qtconsole')
File renamed without changes.
93 changes: 93 additions & 0 deletions examples/ex01/ipy_kernel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#print("Waiting for Visual Python debugger to attach")
# import ptvsd; ptvsd.enable_attach(); ptvsd.wait_for_attach()

# import pydevd
# pydevd.settrace()

import os
import sys
import subprocess
import tempfile
import threading
import time

from pathlib import Path

import IPython

connection_file = Path(tempfile.gettempdir()) / 'connection-{:d}.json'.format(os.getpid())
jupyter_qtconsole_exe = Path(__file__).parent / 'jupyter' / 'qt_console.py'


def clean_up_environment_path():
os_path = []
for p in os.environ['PATH'].split(';'):
if Path(p).exists() and len(p):
os_path.append(str(p))
else:
print("Removed from PATH:", str(p))
os.environ['PATH'] = ';'.join(os_path) + ';'


def runner(python_exe, timeout=10):
print(f"Waiting {timeout} sec for {connection_file} to be created")
count_down = timeout
while count_down >= 1 and not connection_file.exists():
time.sleep(1)
count_down -= 1

if not connection_file.exists():
print(f"{connection_file} does not exist after {timeout} seconds")
return

count_down = timeout
while count_down >= 1 and len(connection_file.read_text()) < 2:
time.sleep(1)
count_down -= 1

if len(connection_file.read_text()) < 2:
print(f"{connection_file} is empty after {timeout} seconds")
return

# print(os.system(f"cmd.exe /c {jupyter_qtconsole_exe} --existing {connection_file}"))
command = [python_exe, str(jupyter_qtconsole_exe), "--existing", str(connection_file)]
print('Starting:', ' '.join(command))
proc = subprocess.Popen(
args=command,
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
universal_newlines=True)

# we need to read. read is a blocking call
print("Process stderr\n", proc.stderr.read())
print("Process stdout\n", proc.stdout.read())

print(f"Closed {jupyter_qtconsole_exe}")


def main(python_exe, throw_on_error = False):
clean_up_environment_path()

t = threading.Thread(
target=runner,
args=[python_exe])
t.start()

print("Running IPython embeded kernel")
try:
IPython.embed_kernel(
local_ns=sys._getframe(1).f_locals,
connection_file=str(connection_file),
)
except Exception as exp:
print("Unable to embed IPython. Exception occured:")
print(exp)
if throw_on_error:
raise exp
finally:
if sys.stdout:
sys.stdout.flush()
t.join()


if __name__ == "__main__":
main(sys.executable)
Empty file.
7 changes: 7 additions & 0 deletions examples/ex01/jupyter/qt_console.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import sys
from qtconsole.qtconsoleapp import main

if __name__ == '__main__':
import re
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(main())
Empty file added examples/ex02/__init__.py
Empty file.
File renamed without changes.
77 changes: 0 additions & 77 deletions examples/gui/console.py

This file was deleted.

0 comments on commit e69c456

Please sign in to comment.