runcode 0.2__py3-none-any.whl → 0.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
runcode/__init__.py CHANGED
@@ -1 +1,83 @@
1
- from .runner import Runner
1
+ """runcode is now onlinecompiler. This release keeps runcode.Runner working through the onlinecompiler client.
2
+
3
+ New code should use the client directly:
4
+
5
+ from onlinecompiler import OnlineCompiler
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import warnings
11
+ from typing import Any
12
+
13
+ from onlinecompiler import OnlineCompiler, Queued
14
+
15
+ __version__ = "0.3.0"
16
+ __all__ = ["Runner", "OnlineCompiler"]
17
+
18
+ # The compiler ids runcode 0.2.1 offered, mapped to the current version of each language.
19
+ # None means the language is no longer offered.
20
+ _CURRENT_IDS: dict[str, str | None] = {
21
+ "python-3.9.7": "python-3.14",
22
+ "gcc-4.9": "gcc-15",
23
+ "g++-4.9": "g++-15",
24
+ "openjdk-11": "openjdk-25",
25
+ "dotnet-5": "dotnet-csharp-10",
26
+ "python-2.7.18": None,
27
+ "php-8.1": "php-8.5",
28
+ "fsharp-5": "dotnet-fsharp-10",
29
+ "ruby-3.0.2": "ruby-4.0",
30
+ }
31
+
32
+
33
+ class Runner:
34
+ """The runcode 0.2.1 API, sent through onlinecompiler's queued run (POST /api/run-code/)."""
35
+
36
+ python39 = "python-3.9.7"
37
+ gcc49 = "gcc-4.9"
38
+ cpp49 = "g++-4.9"
39
+ openjdk11 = "openjdk-11"
40
+ dotnet5 = "dotnet-5"
41
+ python27 = "python-2.7.18"
42
+ php81 = "php-8.1"
43
+ fsharp5 = "fsharp-5"
44
+ ruby30 = "ruby-3.0.2"
45
+
46
+ def __init__(self, api_key: str = "", callback_url: str = ""):
47
+ """api_key defaults to Django's settings.RUNCODE_API_KEY, as before, then to the
48
+ ONLINECOMPILER_API_KEY environment variable. Get a key at https://onlinecompiler.io."""
49
+ warnings.warn(
50
+ "runcode is now onlinecompiler: use `from onlinecompiler import OnlineCompiler`. "
51
+ "runcode.Runner keeps working through it.",
52
+ DeprecationWarning,
53
+ stacklevel=2,
54
+ )
55
+ if not api_key:
56
+ try:
57
+ from django.conf import settings
58
+
59
+ api_key = getattr(settings, "RUNCODE_API_KEY", "") or ""
60
+ callback_url = callback_url or getattr(settings, "RUNCODE_CALLBACK_URL", "") or ""
61
+ except Exception:
62
+ pass
63
+ self.api_key = api_key
64
+ self.callback_url = callback_url
65
+ if callback_url:
66
+ warnings.warn(
67
+ "callback_url is not sent: results go to the callback URL set on your API key in the "
68
+ "onlinecompiler.io dashboard.",
69
+ UserWarning,
70
+ stacklevel=2,
71
+ )
72
+ self.client = OnlineCompiler(api_key or None)
73
+
74
+ def execute(self, code: str, input: str, compiler: str, extra_params: dict[str, Any] | None = None) -> Queued:
75
+ """Queue a run and return at once with its id ({"status": ..., "id": ...}). The result is
76
+ POSTed to the callback URL set on your API key in the onlinecompiler.io dashboard, with
77
+ extra_params echoed back. Raises onlinecompiler.OnlineCompilerError if the run is refused."""
78
+ if compiler in _CURRENT_IDS:
79
+ current = _CURRENT_IDS[compiler]
80
+ if current is None:
81
+ raise ValueError(f"{compiler} is no longer offered. Runner.python39 runs Python 3.14.")
82
+ compiler = current
83
+ return self.client.submit(compiler, code, input, extra_params=extra_params or None)
@@ -0,0 +1,74 @@
1
+ Metadata-Version: 2.5
2
+ Name: runcode
3
+ Version: 0.3.0
4
+ Summary: runcode is now onlinecompiler: this release keeps runcode.Runner working through the OnlineCompiler.io client
5
+ Project-URL: Homepage, https://onlinecompiler.io
6
+ Project-URL: Documentation, https://pypi.org/project/onlinecompiler/
7
+ Author: RunCode Inc.
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Keywords: code execution,compiler api,online compiler,onlinecompiler,runcode
11
+ Classifier: Development Status :: 7 - Inactive
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Requires-Python: >=3.10
16
+ Requires-Dist: onlinecompiler>=0.1.0
17
+ Description-Content-Type: text/markdown
18
+
19
+ # runcode is now onlinecompiler
20
+
21
+ RunCode's code execution API is now [OnlineCompiler.io](https://onlinecompiler.io/?utm_source=pypi-runcode),
22
+ and its Python client is [`onlinecompiler`](https://pypi.org/project/onlinecompiler/). New code should
23
+ use it:
24
+
25
+ ```bash
26
+ pip install onlinecompiler
27
+ ```
28
+
29
+ ```python
30
+ from onlinecompiler import OnlineCompiler
31
+
32
+ client = OnlineCompiler() # reads ONLINECOMPILER_API_KEY
33
+
34
+ result = client.run("python-3.14", "name = input()\nprint(f'Hello, {name}!')", input="Ada")
35
+ print(result["output"]) # Hello, Ada!
36
+ ```
37
+
38
+ It runs code in 46 languages and judges it against test cases, and it is free up to 100,000 runs a
39
+ month. Get an API key at https://api.onlinecompiler.io/compilers/api-keys/.
40
+
41
+ ## Code written for runcode 0.2.1
42
+
43
+ runcode 0.2.1 sent runs to app.runcode.io, which no longer answers. This release keeps the same
44
+ `Runner` working through `onlinecompiler`, so old code runs again after `pip install -U runcode`:
45
+
46
+ ```python
47
+ from runcode import Runner
48
+
49
+ runner = Runner(api_key="YOUR_ONLINECOMPILER_API_KEY")
50
+ queued = runner.execute(code="print(input())", input="hi", compiler=Runner.python39)
51
+ print(queued["id"])
52
+ ```
53
+
54
+ What changed:
55
+
56
+ - The API key is an OnlineCompiler.io key. Without one, `Runner()` reads Django's
57
+ `settings.RUNCODE_API_KEY` as before, then the `ONLINECOMPILER_API_KEY` environment variable.
58
+ - Results are POSTed to the callback URL set on your API key in the
59
+ [dashboard](https://api.onlinecompiler.io/compilers/api-keys/), with `extra_params` echoed back.
60
+ Set one there first: a key without a callback URL is refused. A `callback_url` passed to `Runner`
61
+ (or `RUNCODE_CALLBACK_URL`) is not sent, and `Runner` warns.
62
+ - `execute` returns `{"status": ..., "id": ...}` for the queued run, and raises
63
+ `onlinecompiler.OnlineCompilerError` when the run is refused (a bad key, a limit), where 0.2.1
64
+ returned nothing.
65
+ - The old compiler ids run on current versions: `python39` on Python 3.14, `gcc49` on GCC 15,
66
+ `cpp49` on G++ 15, `openjdk11` on OpenJDK 25, `dotnet5` on C# (.NET 10), `php81` on PHP 8.5,
67
+ `fsharp5` on F# (.NET 10) and `ruby30` on Ruby 4.0. Python 2.7 (`python27`) is no longer offered
68
+ and raises `ValueError`. Any current compiler id works too, such as `"rust-1.93"`; the full list is
69
+ at https://onlinecompiler.io/languages.
70
+ - Python 3.10 or newer, and no `requests` dependency. The Django sample project is gone.
71
+
72
+ `Runner` shows a `DeprecationWarning`. To get results in the response, judge against test cases,
73
+ verify webhooks and more, move to `OnlineCompiler`: see the
74
+ [onlinecompiler README](https://pypi.org/project/onlinecompiler/).
@@ -0,0 +1,5 @@
1
+ runcode/__init__.py,sha256=I6optAMzkCrRmd1ILFyxeOeQjovCva5L0dsac33Giv4,3156
2
+ runcode-0.3.0.dist-info/METADATA,sha256=eti3SMJkmBpfLSYJQDyTmoSJLibIsc_zBsg94-1KUAw,3346
3
+ runcode-0.3.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
4
+ runcode-0.3.0.dist-info/licenses/LICENSE,sha256=ewJ8Ho-t36T048PVcYWDREgjhelKO_i5q2cH8pafvU0,1069
5
+ runcode-0.3.0.dist-info/RECORD,,
@@ -1,5 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.37.0)
2
+ Generator: hatchling 1.33.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
-
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2020 RunCode
3
+ Copyright (c) 2026 RunCode Inc.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
runcode/runner.py DELETED
@@ -1,74 +0,0 @@
1
- import requests
2
-
3
-
4
- class Runner:
5
-
6
- python39 = "python-3.9.7"
7
- gcc49 = "gcc-4.9"
8
- cpp49 = "g++-4.9"
9
- openjdk11 = "openjdk-11"
10
- dotnet5 = "dotnet-5"
11
- python27 = "python-2.7.18"
12
- php81 = "php-8.1"
13
- fsharp5 = "fsharp-5"
14
- ruby30 = "ruby-3.0.2"
15
-
16
- def __init__(self, api_key="", callback_url=""):
17
- """
18
- Constructs and sends a :class:`Runner <Runner>`.
19
- :param api_key: API Key to autheticate and process your request. You can get it in runcode.io dashboard.
20
- :param callback_url: URL to receive executon results.
21
- :return: :class:`Runner <Runner>` object
22
- :rtype: runcode.Runner
23
- Usage::
24
- >>> from runcode import Runner
25
- >>> runner = Runner(
26
- api_key="{API_KEY}",
27
- callback_url="{URL_TO_PROCESS_RESULT}",
28
- )
29
- """
30
-
31
- if api_key == "":
32
- try:
33
- from django.conf import settings
34
-
35
- self.api_key = settings.RUNCODE_API_KEY
36
- self.callback_url = settings.RUNCODE_CALLBACK_URL
37
- except:
38
- pass
39
- else:
40
- self.api_key = api_key
41
- self.callback_url = callback_url
42
-
43
- def execute(self, code, input, compiler, extra_params={}):
44
- """
45
- Sends code and input to be executed by runcode platform.
46
- :param code: Code to get executed.
47
- :param input: input values for the code.
48
- :compiler: Compiler to use to execute the code.
49
- :extra_params: json dict to post extra parameters to identify the response or any other purpose
50
- Usage::
51
- >>> runner.execute(
52
- code='''
53
- print("Hello world")
54
- start = input()
55
- end = input()
56
- for i in range(int(start), int(end)):
57
- print(i)
58
- ''',
59
- input="1\n10",
60
- compiler=Runner.python39,
61
- )
62
- """
63
-
64
- out = {
65
- "api_key": self.api_key,
66
- "code": code,
67
- "input": input,
68
- "compiler": compiler,
69
- "callback_url": self.callback_url,
70
- "extra_params": extra_params,
71
- }
72
-
73
- r = requests.post("https://app.runcode.io/api/run-code/", json=out)
74
- # r = requests.post("http://localhost:8000/api/run-code/", json=out)
@@ -1,107 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: runcode
3
- Version: 0.2
4
- Summary: RunCode Python API
5
- Home-page: https://github.com/runcode-io/runcode-python
6
- Author: RunCode
7
- Author-email: hello@runcode.io
8
- License: UNKNOWN
9
- Platform: UNKNOWN
10
- Classifier: Intended Audience :: Developers
11
- Classifier: Operating System :: OS Independent
12
- Classifier: License :: OSI Approved :: MIT License
13
- Classifier: Programming Language :: Python
14
- Classifier: Programming Language :: Python :: 3
15
- Classifier: Programming Language :: Python :: 3.3
16
- Classifier: Programming Language :: Python :: 3.4
17
- Classifier: Programming Language :: Python :: 3.5
18
- Classifier: Programming Language :: Python :: 3.6
19
- Classifier: Programming Language :: Python :: 3.7
20
- Classifier: Programming Language :: Python :: 3.8
21
- Classifier: Programming Language :: Python :: 3.9
22
- Classifier: Topic :: Software Development :: Internationalization
23
- Description-Content-Type: text/markdown
24
- License-File: LICENSE
25
- Requires-Dist: requests
26
-
27
- # RunCode Python API
28
-
29
- This API is as simaple as send your code and getting execution result.
30
-
31
- Install
32
-
33
- ```
34
- pip install runcode
35
- ```
36
-
37
-
38
-
39
- ## Python Example
40
- ```
41
- from runcode import Runner
42
-
43
- runner = Runner(
44
- api_key="",
45
- callback_url="",
46
- )
47
-
48
- runner.execute(
49
- code="""
50
- print("Hello world")
51
- start = input()
52
- end = input()
53
- for i in range(int(start), int(end)):
54
- print(i)
55
- """,
56
- input="1\n10",
57
- compiler=Runner.python39,
58
- )
59
-
60
- ```
61
- You need to provide two parameters here.
62
- api_key - you will get it from runcode.io dashboard after loging.
63
- callback_url - Your application URL to process execution result.
64
- compiler - You can choose any of the available compilers from RunCode docs.
65
- ## Django Example
66
- ```
67
- from runcode import Runner
68
-
69
- runner = Runner()
70
-
71
- runner.execute(
72
- code="""
73
- print("Hello world")
74
- start = input()
75
- end = input()
76
- for i in range(int(start), int(end)):
77
- print(i)
78
- """,
79
- input="1\n10",
80
- compiler=Runner.python39,
81
- )
82
- ```
83
- You need to specify compiler here.
84
- compiler - You can choose any of the available compilers from RunCode docs.
85
-
86
- You need to add two parameters to settings.py file.
87
-
88
- RUNCODE_API_KEY - you will get it from runcode.io dashboard after loging.
89
- RUNCODE_CALLBACK_URL - Your application URL to process execution result.
90
-
91
- ### Available compilers
92
- ```
93
- python39 = "python-3.9.7"
94
- gcc49 = "gcc-4.9"
95
- cpp49 = "g++-4.9"
96
- openjdk11 = "openjdk-11"
97
- dotnet5 = "dotnet-5"
98
- python27 = "python-2.7.18"
99
- php81 = "php-8.1"
100
- fsharp5 = "fsharp-5"
101
- ruby30 = "ruby-3.0.2"
102
- ```
103
-
104
-
105
- For further support, contact hello@runcode.io
106
-
107
-
@@ -1,13 +0,0 @@
1
- runcode/__init__.py,sha256=xh1VuKyxkfiHGWMvcornpA6bEAHfyASZ8d_OdIscccI,27
2
- runcode/runner.py,sha256=Hdkd4r3Q5iAN5vaW7W0PT72pWVuXM7D4fMOZDM9lb5Q,2372
3
- runcode_sample/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- runcode_sample/asgi.py,sha256=FNDZzHMw6CI90pXGh2nOhJxQNGeqYVTmBkNQEQY37VY,391
5
- runcode_sample/settings.py,sha256=OmxDYqUx00bHNXuzVJb2DIOWVja3_bkNvl8SvhSA1sM,3112
6
- runcode_sample/urls.py,sha256=R29rxCIFcfcAxE8Ywd9I-VpPLpoKnnKunN0cXSg8ZS4,211
7
- runcode_sample/views.py,sha256=kn8ShRWg9Ds7zpzyVIf11q5WCS-ZY6IZHHOWog0YzJQ,789
8
- runcode_sample/wsgi.py,sha256=yRTVA45vcvgAjF8AzGafzfQnDyBiT4wlJZBB4TcAD9U,391
9
- runcode-0.2.dist-info/LICENSE,sha256=-P34USQli1FfJzTwF154T4ZktMRyIMOuQbMW59mMNK0,1064
10
- runcode-0.2.dist-info/METADATA,sha256=cPyhMDhA3XzwXStjIvCh1pFHZjgld-a1p7wtzMoMTjE,2531
11
- runcode-0.2.dist-info/WHEEL,sha256=ewwEueio1C2XeHTvT17n8dZUJgOvyCWCt0WVNLClP9o,92
12
- runcode-0.2.dist-info/top_level.txt,sha256=WInQ7CXL9NEXoG0QE17ZTe0IN_TxEgVgsWaIMwogVW8,23
13
- runcode-0.2.dist-info/RECORD,,
@@ -1,2 +0,0 @@
1
- runcode
2
- runcode_sample
File without changes
runcode_sample/asgi.py DELETED
@@ -1,16 +0,0 @@
1
- """
2
- ASGI config for runcode project.
3
-
4
- It exposes the ASGI callable as a module-level variable named ``application``.
5
-
6
- For more information on this file, see
7
- https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/
8
- """
9
-
10
- import os
11
-
12
- from django.core.asgi import get_asgi_application
13
-
14
- os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'runcode.settings')
15
-
16
- application = get_asgi_application()
@@ -1,120 +0,0 @@
1
- import os
2
- from dotenv import load_dotenv
3
- from pathlib import Path
4
-
5
- load_dotenv()
6
-
7
- # Build paths inside the project like this: BASE_DIR / 'subdir'.
8
- BASE_DIR = Path(__file__).resolve().parent.parent
9
-
10
-
11
- # Quick-start development settings - unsuitable for production
12
- # See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
13
-
14
- # SECURITY WARNING: keep the secret key used in production secret!
15
- SECRET_KEY = "django-insecure-k7#@^xuh868*a_md7yll@9(h+((za&gs8t!ybln6*qxb!2s$fo"
16
-
17
- # SECURITY WARNING: don't run with debug turned on in production!
18
- DEBUG = True
19
-
20
- ALLOWED_HOSTS = ["*"]
21
-
22
-
23
- # Application definition
24
-
25
- INSTALLED_APPS = [
26
- "django.contrib.admin",
27
- "django.contrib.auth",
28
- "django.contrib.contenttypes",
29
- "django.contrib.sessions",
30
- "django.contrib.messages",
31
- "django.contrib.staticfiles",
32
- ]
33
-
34
- MIDDLEWARE = [
35
- "django.middleware.security.SecurityMiddleware",
36
- "django.contrib.sessions.middleware.SessionMiddleware",
37
- "django.middleware.common.CommonMiddleware",
38
- "django.middleware.csrf.CsrfViewMiddleware",
39
- "django.contrib.auth.middleware.AuthenticationMiddleware",
40
- "django.contrib.messages.middleware.MessageMiddleware",
41
- "django.middleware.clickjacking.XFrameOptionsMiddleware",
42
- ]
43
-
44
- ROOT_URLCONF = "runcode_sample.urls"
45
-
46
- TEMPLATES = [
47
- {
48
- "BACKEND": "django.template.backends.django.DjangoTemplates",
49
- "DIRS": [],
50
- "APP_DIRS": True,
51
- "OPTIONS": {
52
- "context_processors": [
53
- "django.template.context_processors.debug",
54
- "django.template.context_processors.request",
55
- "django.contrib.auth.context_processors.auth",
56
- "django.contrib.messages.context_processors.messages",
57
- ],
58
- },
59
- },
60
- ]
61
-
62
- WSGI_APPLICATION = "runcode_sample.wsgi.application"
63
-
64
-
65
- # Database
66
- # https://docs.djangoproject.com/en/3.2/ref/settings/#databases
67
-
68
- DATABASES = {
69
- "default": {
70
- "ENGINE": "django.db.backends.sqlite3",
71
- "NAME": BASE_DIR / "db.sqlite3",
72
- }
73
- }
74
-
75
-
76
- # Password validation
77
- # https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
78
-
79
- AUTH_PASSWORD_VALIDATORS = [
80
- {
81
- "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
82
- },
83
- {
84
- "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
85
- },
86
- {
87
- "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
88
- },
89
- {
90
- "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
91
- },
92
- ]
93
-
94
-
95
- # Internationalization
96
- # https://docs.djangoproject.com/en/3.2/topics/i18n/
97
-
98
- LANGUAGE_CODE = "en-us"
99
-
100
- TIME_ZONE = "UTC"
101
-
102
- USE_I18N = True
103
-
104
- USE_L10N = True
105
-
106
- USE_TZ = True
107
-
108
-
109
- # Static files (CSS, JavaScript, Images)
110
- # https://docs.djangoproject.com/en/3.2/howto/static-files/
111
-
112
- STATIC_URL = "/static/"
113
-
114
- # Default primary key field type
115
- # https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
116
-
117
- DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
118
-
119
- RUNCODE_API_KEY = os.getenv("RUNCODE_API_KEY")
120
- RUNCODE_CALLBACK_URL = os.getenv("RUNCODE_CALLBACK_URL")
runcode_sample/urls.py DELETED
@@ -1,9 +0,0 @@
1
- from django.contrib import admin
2
- from django.urls import path
3
- from .views import test_index, run_code
4
-
5
- urlpatterns = [
6
- path("admin/", admin.site.urls),
7
- path("", test_index),
8
- path("rc/", run_code),
9
- ]
runcode_sample/views.py DELETED
@@ -1,33 +0,0 @@
1
- import json
2
- from django.http.response import HttpResponse
3
- from django.views.decorators.csrf import csrf_exempt
4
- from runcode import Runner
5
-
6
-
7
- def run_code(request):
8
- # runner = Runner(
9
- # api_key="KMXQosOYD1Bmrg1OJg4PzaQyprVVXaYkCsv3HgTh",
10
- # callback_url="http://7a91-2405-201-c00a-e012-4abc-50aa-3eb3-71d5.ngrok.io",
11
- # )
12
- runner = Runner()
13
- runner.execute(
14
- code="""
15
- print("Hello world")
16
- start = input()
17
- end = input()
18
- for i in range(int(start), int(end)):
19
- print(i)
20
- """,
21
- input="1\n10",
22
- compiler=Runner.python39,
23
- extra_params={"ukey": "16"},
24
- )
25
-
26
- return HttpResponse("hi")
27
-
28
-
29
- @csrf_exempt
30
- def test_index(request):
31
- received_json_data = json.loads(request.body)
32
- print(received_json_data)
33
- return HttpResponse("ok")
runcode_sample/wsgi.py DELETED
@@ -1,16 +0,0 @@
1
- """
2
- WSGI config for runcode project.
3
-
4
- It exposes the WSGI callable as a module-level variable named ``application``.
5
-
6
- For more information on this file, see
7
- https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/
8
- """
9
-
10
- import os
11
-
12
- from django.core.wsgi import get_wsgi_application
13
-
14
- os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'runcode.settings')
15
-
16
- application = get_wsgi_application()