Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions .github/workflows/clojure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,33 @@ jobs:
- run: dotnet tool install --global Clojure.Main --version ${{ matrix.version }}
- run: dotnet restore
- run: bb -m tasks.test/cljr
test-py:
needs: [ setup, build ]
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: browser-actions/setup-chrome@v1
with:
chrome-version: 135
- uses: actions/checkout@v3
- uses: ./.github/setup
- run: rm package.json
- run: npm install "react@^17.0.2"
- uses: actions/download-artifact@v4
with:
name: portal-client
path: resources/portal
- uses: actions/setup-python@v5
with:
python-version: '3.13'
cache: 'pip'
- run: pip install virtualenv
- run: bb -m tasks.test/lpy
app:
runs-on: ubuntu-latest
needs: [ test-ui, test-clj, test-cljs, test-cljr, check ]
needs: [ test-ui, test-clj, test-cljs, test-cljr, test-py, check ]
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v3
Expand All @@ -117,7 +141,7 @@ jobs:
force_orphan: true
package:
runs-on: ubuntu-latest
needs: [ test-ui, test-clj, test-cljs, test-cljr, check ]
needs: [ test-ui, test-clj, test-cljs, test-cljr, test-py, check ]
if: startsWith(github.event.head_commit.message, 'Release ')
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ clojure.data.json*
*.iml

obj/

**__pycache__**
17 changes: 17 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,23 @@
":nrepl"
]
}
},
{
"name": "basilisp",
"projectType": "deps.edn",
"projectRootPath": [
"."
],
"customJackInCommandLine": "bb py",
"nReplPortFile": [
".nrepl-port"
],
"menuSelections": {
"cljAliases": [
":dev",
":cider"
]
}
}
]
}
1 change: 1 addition & 0 deletions bb.edn
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
ide tasks.ide/open
pkg tasks.package/all
deploy tasks.deploy/all
py tasks.py/-main
bench tasks.bench/-main}}
1 change: 1 addition & 0 deletions dev/notebook/ci.clj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
(with-out-data (test/cljs-runtime "1.10.844"))
(with-out-data (test/cljs-nbb))
(with-out-data (test/cljs-ui))
(with-out-data (test/lpy))
(build)
(with-out-data (tool/clj "-M:test" "-m" :portal.test-runner))
(with-out-data (tool/bb "-m" :portal.test-runner))
Expand Down
12 changes: 7 additions & 5 deletions dev/tasks/bench.clj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(ns tasks.bench
(:require
[portal.api :as p]
[portal.runtime.bench-cson :as bc]
[portal.bench-cson :as bc]
[tasks.parallel :refer [with-out-data]]
[tasks.tools :as t]))

Expand All @@ -12,10 +12,12 @@
#(let [{:keys [tag val]} %]
(when (= :tap tag) val))
@f))
(for [f [#(t/clj "-M:test" "-m" :portal.runtime.bench-cson)
#(t/bb "-m" :portal.runtime.bench-cson)
#(t/cljr "-m" :portal.runtime.bench-cson)
#(t/nbb "-m" :portal.runtime.bench-cson)]]
(for [f [#(t/clj "-M:test" "-m" :portal.bench-cson)
#(t/bb "-m" :portal.bench-cson)
#(t/cljs "1.10.773" :portal.bench-cson)
#(t/cljr "-m" :portal.bench-cson)
#(t/nbb "-m" :portal.bench-cson)
#(t/lpy :run "-n" :portal.bench-cson)]]
(future (with-out-data (f))))))

(def windows
Expand Down
18 changes: 18 additions & 0 deletions dev/tasks/py.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
(ns tasks.py
(:require [babashka.fs :as fs]
[tasks.build :refer [build]]
[tasks.tools :refer [py pip lpy]]))

(defn install []
(when-not (fs/exists? "target/py")
(py "-m" :venv "target/py")
(pip :install "-r" "requirements.txt")))

(defn nrepl [] (lpy :nrepl-server "--include-path" "src"))

(defn -main
"Start basilisp dev env / nrepl"
[]
(build)
(install)
(nrepl))
5 changes: 5 additions & 0 deletions dev/tasks/test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
(:refer-clojure :exclude [test])
(:require [babashka.fs :as fs]
[tasks.build :refer [build install]]
[tasks.py :as py]
[tasks.tools :as t]))

(defn cljs* [deps main]
Expand Down Expand Up @@ -60,6 +61,10 @@
(build)
(t/cljr "-m" :portal.test-clr))

(defn lpy []
(py/install)
(t/lpy :run "--include-path" "test" "--include-path" "src" "-n" :portal.test-runner))

(defn test* []
(future (cljs-runtime "1.10.773"))
(future (cljs-runtime "1.10.844"))
Expand Down
38 changes: 37 additions & 1 deletion dev/tasks/tools.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(ns tasks.tools
(:require [babashka.process :as p]
(:require [babashka.fs :as fs]
[babashka.process :as p]
[clojure.java.io :as io]
[clojure.string :as str]
[io.aviso.ansi :as a])
Expand Down Expand Up @@ -89,3 +90,38 @@
(str/join (System/getProperty "path.separator")
["src" "resources" "dev" "test"]))]
(apply sh :Clojure.Main args)))

(defn- py-script [bin]
(str (if windows?
"./target/py/Scripts/"
"./target/py/bin/")
(name bin)))

(def py (partial #'sh :python3))
(def pip (partial #'sh (py-script :pip)))

(defn lpy [& args]
(binding [*opts*
(assoc *opts*
:inherit true
:extra-env
{"PYTHONPATH" "src:test"})]
(apply sh (py-script :basilisp) args)))

(defn cljs [version main]
(let [deps {'org.clojure/clojurescript {:mvn/version version}}
out (str "target/" (name main) "." version)]
(when (seq
(fs/modified-since
out
(concat
(fs/glob "src" "**")
(fs/glob "test" "**"))))
(clj "-Sdeps" (pr-str {:deps deps})
"-M:test"
"-m" :cljs.main
"--output-dir" out
"--target" :node
"--output-to" (str out ".js")
"--compile" main))
(node out)))
1 change: 1 addition & 0 deletions dev/user.clj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

(p/clear)
(p/close)
(p/stop)
(p/docs {:mode :dev})

(def portal (p/open {:launcher :auto}))
Expand Down
1 change: 1 addition & 0 deletions examples/clr/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.classpath
.clj-kondo/
.cpcache/
16 changes: 16 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
aiohappyeyeballs==2.4.4
aiohttp==3.11.11
aiosignal==1.3.2
asyncio==3.4.3
attrs==24.3.0
basilisp==0.4.0
frozenlist==1.5.0
idna==3.10
immutables==0.21
multidict==6.1.0
prompt_toolkit==3.0.48
propcache==0.2.1
pyrsistent==0.20.0
typing_extensions==4.12.2
wcwidth==0.2.13
yarl==1.18.3
69 changes: 69 additions & 0 deletions resources/runtime/python.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 20 additions & 6 deletions src/examples/data.cljc
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
(ns examples.data
(:require #?(:clj [clojure.java.io :as io])
#?(:org.babashka/nbb [clojure.core]
:default [examples.hacker-news :as hn])
:clj [examples.hacker-news :as hn]
:cljr [examples.hacker-news :as hn]
:cljs [examples.hacker-news :as hn])
[clojure.pprint :as pp]
[examples.macros :refer [read-file]]
[portal.colors :as c]
Expand All @@ -13,7 +15,8 @@
:org.babashka/nbb (:import)
:cljs (:import [goog.math Long])
:cljr (:import [System DateTime Guid Uri]
[System.IO File])))
[System.IO File])
:lpy (:import [math :as Math])))

#?(:clj
(defn slurp-bytes [x]
Expand Down Expand Up @@ -66,7 +69,14 @@
::date (js/Date.)
::bigint (js/BigInt "42")
::js-array #js [0 1 2 3 4]
::js-object #js {:hello "world"}}))
::js-object #js {:hello "world"}}
:lpy
{::class (type {})
::ratio 22/7
::uuid #uuid "844d415a-5288-4c2c-a163-0d104e899fa8"
::date #inst "2021-04-07T22:43:59.393-00:00"
::array #py [0 1 2 3 4]
::hash #py {:hello "world"}}))

(def platform-collections
#?(:bb nil
Expand Down Expand Up @@ -107,8 +117,10 @@

(def clojure-data
{::regex #"hello-world"
::sorted-map (sorted-map-by gt 3 "c" 2 "b" 1 "a")
::sorted-set (sorted-set-by gt 3 2 1)
::sorted-map #?(:lpy :not-implemented
:default (sorted-map-by gt 3 "c" 2 "b" 1 "a"))
::sorted-set #?(:lpy :not-implemented
:default (sorted-set-by gt 3 2 1))
::var #'portal.colors/themes
::with-meta (with-meta 'with-meta {:hello :world})
::tagged (tagged-literal 'my/tag ["hello, world"])
Expand Down Expand Up @@ -870,6 +882,8 @@
{:columns [:a :b :c :d :e]})
::multi-map map-reflection-data})

(declare test-report)

(def test-report
(v/test-report
[{:type :begin-test-ns
Expand Down Expand Up @@ -1123,7 +1137,7 @@
(def data
(merge
{::platform-data platform-data
::hacker-news #?(:org.babashka/nbb nil :default hn/stories)
::hacker-news #?(:org.babashka/nbb nil :lpy :not-implemented :default hn/stories)
::spec-data spec-data
::table-data table-data
::diff diff-data
Expand Down
7 changes: 5 additions & 2 deletions src/examples/macros.cljc
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
(ns ^:no-doc examples.macros
#?(:portal (:import) :cljs (:require-macros examples.macros)))
#?(:portal (:import)
:cljs (:require-macros examples.macros)
:lpy (:require [portal.runtime.fs :as fs])))

#?(:clj (defmacro read-file [file-name] (slurp file-name))
:cljs (defn read-file [_file-name] ::missing)
:cljr (defmacro read-file [file-name] (slurp file-name :enc "utf8")))
:cljr (defmacro read-file [file-name] (slurp file-name :enc "utf8"))
:lpy (defn read-file [file-name] (fs/slurp file-name)))
Loading