Skip to content

Commit 20b5bd9

Browse files
DerThorstenIsabelParedesKlaim
authored
async-kernel (#697)
* Fix context errors * Working build * Working without debugger The debugger causes zmq errors somewhere * Not working * Partially working * Working * Rename xhook * Move hook * Add uvw dependency * Ignore pybind11 visibility warning * Clean hook * Clean main * Fix hook implementaion * updates * remove mac-13 * movin find uv related code to non-emscripten branch * working * libuv * libuv * path * path * path * widgets * build xeus-uv * add uvloop * debugger * debugger * remove xeus-uv after building * special win env * use winloop * debug * move * debug * native runner * native runner * native runner * native runner * remove uv * fix debugger bug * fix raw kernel * fix raw kernel * use one global dict * fixes * time based win * time based win * time based win * first c++ tests * remove activation * remove activation * remove activation * remove activation * remove activation * dont build extension * use dummy in stop * activate * build extension again * build extension again * use reader * use reader * use reader * use reader * fix * fix * fix * fix * fix * fixes * fixes * fixes * fixes * fixes * fixes * fixes * fixes * fixes * more * more * more * more * more * more * more * more * more * more * more * more * more * more info * more info * even more * even more * even more * no more specta * no more specta * no more specta * no more specta * no more specta * no more specta * win experiment * win experiment * win experiment * use selector event loop * win experiment * win experiment * adding default runner to xeus python st. we can add cout stuff * missing break * cleanup * applied #685 to async pr * added missing boost dependency * ignore root build dirs * added missing boost packages dependencies * non-buisy * retrigger-ci * try buisy * socket * socket * merged * hidden * add missing method * hidden macro * win fix * debug duct tape and more info * removed msvc-specific instruction * tests wait for xpython's ready message instead of sleep * debug duct tape and more info * fi * fix * x6 * one minute * added eval * run tests 20 times for win * powershell syntax * use default runner * publich error * clean internal request impl * remoev unused file in cmake * fix info request * fix typo like errors * trigger run * cleanup * cleaner fix: lock python's GIL when destroying the debugger * cleanup python path deduction unicode-friendly (on windows) and absolute paths * removed buisy loop * cleanup path * cleanup pass 2 * toplevel await test * cleanup * cleanup * cleanup * cleanup * trigger ci * using released xeus-python-shell * using released xeus-python-shell --------- Co-authored-by: Isabel Paredes <isabel.paredes@quantstack.net> Co-authored-by: Klaim (Joël Lamotte) <142265+Klaim@users.noreply.github.com>
1 parent 5dc3707 commit 20b5bd9

28 files changed

Lines changed: 538 additions & 135 deletions

.github/workflows/deploy-github-page.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ jobs:
4747
4848
set -eux
4949
50+
51+
URL=https://github.com/DerThorsten/xeus-python-shell/archive/refs/heads/akernel.zip
52+
curl -L $URL -o xeus-python-shell-akernel.zip
53+
unzip xeus-python-shell-akernel.zip
54+
5055
export PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-python-wasm-host
5156
echo "PREFIX=$PREFIX" >> $GITHUB_ENV
5257
@@ -63,10 +68,12 @@ jobs:
6368
- name: Jupyter Lite integration
6469
shell: bash -l {0}
6570
run: |
71+
THIS_DIR=$(pwd)
6672
jupyter lite build \
6773
--XeusAddon.prefix=${{ env.PREFIX }} \
6874
--contents notebooks/ \
69-
--output-dir dist
75+
--output-dir dist
76+
7077
7178
- name: Upload artifact
7279
uses: actions/upload-pages-artifact@v4

.github/workflows/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ jobs:
3232
uses: mamba-org/setup-micromamba@v2
3333
with:
3434
environment-file: environment-dev.yml
35+
3536

3637
- name: Make build directory
3738
run: mkdir build

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ set(XEUS_PYTHON_SRC
180180
src/xstream.hpp
181181
src/xtraceback.cpp
182182
src/xutils.cpp
183+
src/xasync_runner.cpp
184+
src/xaserver.cpp
183185
)
184186

185187
set(XEUS_PYTHON_HEADERS
@@ -190,6 +192,7 @@ set(XEUS_PYTHON_HEADERS
190192
include/xeus-python/xinterpreter_raw.hpp
191193
include/xeus-python/xtraceback.hpp
192194
include/xeus-python/xutils.hpp
195+
include/xeus-python/xaserver.hpp
193196
)
194197

195198
set(XPYTHON_SRC

environment-dev.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ dependencies:
1515
# The debugger is not available with python 3.13 because
1616
# of a spurious bug in debugpy
1717
- python <3.13
18-
- xeus-python-shell>=0.6.3,<0.7
18+
- pip
19+
- xeus-python-shell>=0.7.0,<0.8
1920
- debugpy>=1.6.5
2021
- ipython
2122
# Test dependencies

environment-wasm-build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ dependencies:
1313
- jupyterlite-core >0.6
1414
- jupyter_server
1515
- jupyterlite-xeus
16+
- # widgets
17+
- ipywidgets

environment-wasm-host.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ dependencies:
1212
- numpy
1313
- xeus-lite
1414
- xeus
15-
- xeus-python-shell>=0.6.3
1615
- pyjs >=4,<5
1716
- libpython
1817
- zstd
1918
- openssl
2019
- xz
20+
- ipywidgets
21+
- xeus-python-shell>=0.7.0,<0.8
22+

include/xeus-python/xaserver.hpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/***************************************************************************
2+
* Copyright (c) 2024, Isabel Paredes *
3+
* Copyright (c) 2024, QuantStack *
4+
* *
5+
* Distributed under the terms of the BSD 3-Clause License. *
6+
* *
7+
* The full license is in the file LICENSE, distributed with this software. *
8+
****************************************************************************/
9+
10+
#include "xeus_python_config.hpp"
11+
#include "xeus/xkernel.hpp"
12+
#include "pybind11/pybind11.h"
13+
14+
namespace py = pybind11;
15+
namespace nl = nlohmann;
16+
17+
namespace xpyt
18+
{
19+
20+
XEUS_PYTHON_API XPYT_FORCE_PYBIND11_EXPORT xeus::xkernel::server_builder make_async_server_factory(py::dict globals);
21+
22+
} // namespace xeus

include/xeus-python/xdebugger.hpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ namespace xpyt
3838

3939
using base_type = xeus::xdebugger_base;
4040

41-
debugger(xeus::xcontext& context,
41+
debugger(
42+
py::dict globals,
43+
xeus::xcontext& context,
4244
const xeus::xkernel_configuration& config,
4345
const std::string& user_name,
4446
const std::string& session_id,
@@ -63,6 +65,9 @@ namespace xpyt
6365
xeus::xdebugger_info get_debugger_info() const override;
6466
std::string get_cell_temporary_file(const std::string& code) const override;
6567

68+
69+
py::dict m_global_dict;
70+
6671
std::unique_ptr<xdebugpy_client> p_debugpy_client;
6772
std::string m_debugpy_host;
6873
std::string m_debugpy_port;
@@ -72,8 +77,10 @@ namespace xpyt
7277
bool m_copy_to_globals_available;
7378
};
7479

75-
XEUS_PYTHON_API
76-
std::unique_ptr<xeus::xdebugger> make_python_debugger(xeus::xcontext& context,
80+
81+
XEUS_PYTHON_API XPYT_FORCE_PYBIND11_EXPORT
82+
std::unique_ptr<xeus::xdebugger> make_python_debugger(py::dict globals,
83+
xeus::xcontext& context,
7784
const xeus::xkernel_configuration& config,
7885
const std::string& user_name,
7986
const std::string& session_id,

include/xeus-python/xeus_python_config.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,9 @@
4646
#define XPYT_FORCE_PYBIND11_EXPORT __attribute__ ((visibility ("default")))
4747
#endif
4848
#endif
49+
50+
#ifdef _MSC_VER
51+
#define XEUS_PYTHON_HIDDEN
52+
#else
53+
#define XEUS_PYTHON_HIDDEN __attribute__ ((visibility ("hidden")))
54+
#endif

include/xeus-python/xinterpreter.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace nl = nlohmann;
3232

3333
namespace xpyt
3434
{
35-
class XEUS_PYTHON_API interpreter : public xeus::xinterpreter
35+
class XEUS_PYTHON_API XPYT_FORCE_PYBIND11_EXPORT interpreter : public xeus::xinterpreter
3636
{
3737
public:
3838

@@ -44,7 +44,9 @@ namespace xpyt
4444
// If redirect_display_enabled is true (default) then this interpreter will
4545
// overwrite sys.displayhook and send execution results using publish_execution_result.
4646
// Disable this if your interpreter uses custom display hook.
47-
interpreter(bool redirect_output_enabled=true, bool redirect_display_enabled = true);
47+
interpreter(
48+
py::dict globals,
49+
bool redirect_output_enabled=true, bool redirect_display_enabled = true);
4850
virtual ~interpreter();
4951

5052
protected:
@@ -78,6 +80,7 @@ namespace xpyt
7880

7981
void redirect_output();
8082

83+
py::dict m_global_dict;
8184
py::object m_ipython_shell_app;
8285
py::object m_ipython_shell;
8386
py::object m_displayhook;
@@ -94,8 +97,7 @@ namespace xpyt
9497
// If an application has already released the GIL by the time the interpreter
9598
// is started, m_release_gil_at_startup has to be set to false to prevent
9699
// releasing it again in configure_impl().
97-
//
98-
bool m_release_gil_at_startup = true;
100+
bool m_release_gil_at_startup = false;
99101
gil_scoped_release_ptr m_release_gil = nullptr;
100102

101103
bool m_redirect_output_enabled;

0 commit comments

Comments
 (0)