diff --git a/.gitignore b/.gitignore index ff8d3cdb..dc9b73bb 100644 --- a/.gitignore +++ b/.gitignore @@ -10,5 +10,5 @@ cover.out /dist # tests -builtin/testfile -examples/embedding/embedding \ No newline at end of file +stdlib/builtin/testfile +examples/embedding/embedding diff --git a/examples/embedding/main.go b/examples/embedding/main.go index 37f34a7f..e4aadfef 100644 --- a/examples/embedding/main.go +++ b/examples/embedding/main.go @@ -10,7 +10,7 @@ import ( // This initializes gpython for runtime execution and is essential. // It defines forward-declared symbols and registers native built-in modules, such as sys and time. - _ "github.com/go-python/gpython/modules" + _ "github.com/go-python/gpython/stdlib" // Commonly consumed gpython "github.com/go-python/gpython/py" @@ -27,8 +27,8 @@ func runWithFile(pyFile string) error { // See type Context interface and related docs ctx := py.NewContext(py.DefaultContextOpts()) - - // This drives modules being able to perform cleanup and release resources + + // This drives modules being able to perform cleanup and release resources defer ctx.Close() var err error diff --git a/examples/multi-context/main.go b/examples/multi-context/main.go index 4bbeda8b..f645e766 100644 --- a/examples/multi-context/main.go +++ b/examples/multi-context/main.go @@ -14,7 +14,7 @@ import ( // This initializes gpython for runtime execution and is critical. // It defines forward-declared symbols and registers native built-in modules, such as sys and time. - _ "github.com/go-python/gpython/modules" + _ "github.com/go-python/gpython/stdlib" // This is the primary import for gpython. // It contains all symbols needed to fully compile and run python. @@ -129,7 +129,7 @@ func RunMultiPi(numWorkers, numTimes int) time.Duration { } workersRunning.Done() - // This drives modules being able to perform cleanup and release resources + // This drives modules being able to perform cleanup and release resources w.ctx.Close() }() } diff --git a/main.go b/main.go index d529646a..bc906aac 100644 --- a/main.go +++ b/main.go @@ -14,10 +14,11 @@ import ( "runtime" "runtime/pprof" - _ "github.com/go-python/gpython/modules" "github.com/go-python/gpython/py" "github.com/go-python/gpython/repl" "github.com/go-python/gpython/repl/cli" + + _ "github.com/go-python/gpython/stdlib" ) // Globals diff --git a/pytest/pytest.go b/pytest/pytest.go index db556f6e..7cadadb1 100644 --- a/pytest/pytest.go +++ b/pytest/pytest.go @@ -11,10 +11,10 @@ import ( "strings" "testing" - _ "github.com/go-python/gpython/modules" - "github.com/go-python/gpython/compile" "github.com/go-python/gpython/py" + + _ "github.com/go-python/gpython/stdlib" ) var gContext = py.NewContext(py.DefaultContextOpts()) diff --git a/repl/repl_test.go b/repl/repl_test.go index 9c64879e..3c13c7c6 100644 --- a/repl/repl_test.go +++ b/repl/repl_test.go @@ -6,7 +6,7 @@ import ( "testing" // import required modules - _ "github.com/go-python/gpython/modules" + _ "github.com/go-python/gpython/stdlib" ) type replTest struct { diff --git a/repl/web/main.go b/repl/web/main.go index 0be6f3cd..f0cebfd8 100644 --- a/repl/web/main.go +++ b/repl/web/main.go @@ -13,12 +13,11 @@ import ( "log" "runtime" + "github.com/go-python/gpython/repl" "github.com/gopherjs/gopherwasm/js" // gopherjs to wasm converter shim // import required modules - _ "github.com/go-python/gpython/modules" - - "github.com/go-python/gpython/repl" + _ "github.com/go-python/gpython/stdlib" ) // Implement the replUI interface diff --git a/builtin/builtin.go b/stdlib/builtin/builtin.go similarity index 100% rename from builtin/builtin.go rename to stdlib/builtin/builtin.go diff --git a/builtin/builtin_test.go b/stdlib/builtin/builtin_test.go similarity index 100% rename from builtin/builtin_test.go rename to stdlib/builtin/builtin_test.go diff --git a/builtin/tests/builtin.py b/stdlib/builtin/tests/builtin.py similarity index 100% rename from builtin/tests/builtin.py rename to stdlib/builtin/tests/builtin.py diff --git a/builtin/tests/lib.py b/stdlib/builtin/tests/lib.py similarity index 100% rename from builtin/tests/lib.py rename to stdlib/builtin/tests/lib.py diff --git a/builtin/tests/libtest.py b/stdlib/builtin/tests/libtest.py similarity index 100% rename from builtin/tests/libtest.py rename to stdlib/builtin/tests/libtest.py diff --git a/math/math.go b/stdlib/math/math.go similarity index 100% rename from math/math.go rename to stdlib/math/math.go diff --git a/math/math_test.go b/stdlib/math/math_test.go similarity index 100% rename from math/math_test.go rename to stdlib/math/math_test.go diff --git a/math/tests/libtest.py b/stdlib/math/tests/libtest.py similarity index 100% rename from math/tests/libtest.py rename to stdlib/math/tests/libtest.py diff --git a/math/tests/libulp.py b/stdlib/math/tests/libulp.py similarity index 100% rename from math/tests/libulp.py rename to stdlib/math/tests/libulp.py diff --git a/math/tests/mathtests.py b/stdlib/math/tests/mathtests.py similarity index 100% rename from math/tests/mathtests.py rename to stdlib/math/tests/mathtests.py diff --git a/math/tests/testcases.py b/stdlib/math/tests/testcases.py similarity index 100% rename from math/tests/testcases.py rename to stdlib/math/tests/testcases.py diff --git a/modules/runtime.go b/stdlib/stdlib.go similarity index 95% rename from modules/runtime.go rename to stdlib/stdlib.go index 0b003022..7b46d391 100644 --- a/modules/runtime.go +++ b/stdlib/stdlib.go @@ -2,7 +2,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package modules +// Package stdlib provides the bootstrap code to wire in all the stdlib +// (python) modules into a gpython context and VM. +package stdlib import ( "bytes" @@ -16,10 +18,10 @@ import ( "github.com/go-python/gpython/py" "github.com/go-python/gpython/vm" - _ "github.com/go-python/gpython/builtin" - _ "github.com/go-python/gpython/math" - _ "github.com/go-python/gpython/sys" - _ "github.com/go-python/gpython/time" + _ "github.com/go-python/gpython/stdlib/builtin" + _ "github.com/go-python/gpython/stdlib/math" + _ "github.com/go-python/gpython/stdlib/sys" + _ "github.com/go-python/gpython/stdlib/time" ) func init() { diff --git a/sys/sys.go b/stdlib/sys/sys.go similarity index 100% rename from sys/sys.go rename to stdlib/sys/sys.go diff --git a/time/time.go b/stdlib/time/time.go similarity index 100% rename from time/time.go rename to stdlib/time/time.go