basilisp
Advanced tools
+1
-1
| Metadata-Version: 2.3 | ||
| Name: basilisp | ||
| Version: 0.3.6 | ||
| Version: 0.3.7 | ||
| Summary: A Clojure-like lisp written for Python | ||
@@ -5,0 +5,0 @@ License: Eclipse Public License 1.0 (EPL-1.0) |
+1
-1
| [tool.poetry] | ||
| name = "basilisp" | ||
| version = "0.3.6" | ||
| version = "0.3.7" | ||
| description = "A Clojure-like lisp written for Python" | ||
@@ -5,0 +5,0 @@ authors = ["Christopher Rink <chrisrink10@gmail.com>"] |
@@ -401,3 +401,3 @@ import argparse | ||
| def _wrap_add_subcommand( | ||
| f: Callable[[argparse.ArgumentParser], None] | ||
| f: Callable[[argparse.ArgumentParser], None], | ||
| ) -> Callable[["argparse._SubParsersAction"], None]: | ||
@@ -429,7 +429,8 @@ def _wrapped_subcommand(subparsers: "argparse._SubParsersAction"): | ||
| else: | ||
| for file in removed: | ||
| print_(f"Removed '{file}'") | ||
| if removed is not None: | ||
| print_(f"Removed '{removed}'") | ||
| else: | ||
| basilisp.bootstrap_python(site_packages=args.site_packages) | ||
| path = basilisp.bootstrap_python(site_packages=args.site_packages) | ||
| print_( | ||
| f"(Added {path})\n\n" | ||
| "Your Python installation has been bootstrapped! You can undo this at any " | ||
@@ -478,3 +479,2 @@ "time with with `basilisp bootstrap --uninstall`." | ||
| "--site-packages", | ||
| action="append", | ||
| help=argparse.SUPPRESS, | ||
@@ -751,3 +751,3 @@ ) | ||
| else: | ||
| pytest.main(args=list(extra)) | ||
| sys.exit(pytest.main(args=list(extra))) | ||
@@ -775,3 +775,5 @@ | ||
| `basilisp test -k vector -p other_dir`""" | ||
| `basilisp test -k vector -p other_dir` | ||
| Returns the PyTest exit code as the exit code.""" | ||
| ), | ||
@@ -778,0 +780,0 @@ handler=test, |
@@ -20,2 +20,3 @@ import importlib.util | ||
| from basilisp.lang.obj import lrepr | ||
| from basilisp.lang.util import munge | ||
| from basilisp.util import Maybe | ||
@@ -187,5 +188,6 @@ | ||
| for pth in sys.path: | ||
| root = Path(pth) | ||
| root = Path(pth).resolve() | ||
| if file.is_relative_to(root): | ||
| elems = list(file.with_suffix("").relative_to(pth).parts) | ||
| elems = list(file.with_suffix("").relative_to(root).parts) | ||
| if elems[-1] == "__init__": | ||
@@ -274,2 +276,8 @@ elems.pop() | ||
| ns = module.__basilisp_namespace__ | ||
| # Ensure the test module was loaded because it was directly | ||
| # relative to an entry in `sys.path`. | ||
| if module.__name__ != munge(str(ns)): | ||
| raise ModuleNotFoundError(f"Module named '{ns}' is not in sys.path") | ||
| once_fixtures, each_fixtures = self._collected_fixtures(ns) | ||
@@ -276,0 +284,0 @@ self._fixture_manager = FixtureManager(once_fixtures) |
@@ -36,3 +36,6 @@ import ast | ||
| from basilisp.lang.compiler.generator import expressionize as _expressionize # noqa | ||
| from basilisp.lang.compiler.generator import gen_py_ast, py_module_preamble | ||
| from basilisp.lang.compiler.generator import ( | ||
| gen_py_ast, | ||
| py_module_preamble, | ||
| ) | ||
| from basilisp.lang.compiler.generator import statementize as _statementize | ||
@@ -39,0 +42,0 @@ from basilisp.lang.compiler.optimizer import PythonASTOptimizer |
+28
-28
| import importlib | ||
| import site | ||
| import os | ||
| import sysconfig | ||
| from pathlib import Path | ||
@@ -59,6 +60,7 @@ from typing import Optional | ||
| def bootstrap_python(site_packages: Optional[list[str]] = None) -> None: | ||
| """Bootstrap a Python installation by installing a ``.pth`` file in the first | ||
| available ``site-packages`` directory (as by | ||
| :external:py:func:`site.getsitepackages`). | ||
| def bootstrap_python(site_packages: Optional[str] = None) -> str: | ||
| """Bootstrap a Python installation by installing a ``.pth`` file | ||
| in ``site-packages`` directory (corresponding to "purelib" in | ||
| :external:py:func:`sysconfig.get_paths`). Returns the path to the | ||
| ``.pth`` file. | ||
@@ -68,32 +70,30 @@ Subsequent startups of the Python interpreter will have Basilisp already | ||
| if site_packages is None: # pragma: no cover | ||
| site_packages = site.getsitepackages() | ||
| site_packages = sysconfig.get_paths()["purelib"] | ||
| assert site_packages, "Expected at least one site-package directory" | ||
| assert site_packages, "Expected a site-package directory" | ||
| for d in site_packages: | ||
| p = Path(d) | ||
| with open(p / "basilispbootstrap.pth", mode="w") as f: | ||
| f.write("import basilisp.sitecustomize") | ||
| break | ||
| pth = Path(site_packages) / "basilispbootstrap.pth" | ||
| with open(pth, mode="w") as f: | ||
| f.write("import basilisp.sitecustomize") | ||
| return str(pth) | ||
| def unbootstrap_python(site_packages: Optional[list[str]] = None) -> list[str]: | ||
| """Remove any `basilispbootstrap.pth` files found in any Python site-packages | ||
| directory (as by :external:py:func:`site.getsitepackages`). Return a list of | ||
| removed filenames.""" | ||
| def unbootstrap_python(site_packages: Optional[str] = None) -> Optional[str]: | ||
| """Remove the `basilispbootstrap.pth` file found in the Python site-packages | ||
| directory (corresponding to "purelib" in :external:py:func:`sysconfig.get_paths`). | ||
| Return the path of the removed file, if any.""" | ||
| if site_packages is None: # pragma: no cover | ||
| site_packages = site.getsitepackages() | ||
| site_packages = sysconfig.get_paths()["purelib"] | ||
| assert site_packages, "Expected at least one site-package directory" | ||
| assert site_packages, "Expected a site-package directory" | ||
| removed = [] | ||
| for d in site_packages: | ||
| p = Path(d) | ||
| for file in p.glob("basilispbootstrap.pth"): | ||
| try: | ||
| file.unlink() | ||
| except FileNotFoundError: # pragma: no cover | ||
| pass | ||
| else: | ||
| removed.append(str(file)) | ||
| removed = None | ||
| pth = Path(site_packages) / "basilispbootstrap.pth" | ||
| try: | ||
| os.unlink(pth) | ||
| except FileNotFoundError: # pragma: no cover | ||
| pass | ||
| else: | ||
| removed = str(pth) | ||
| return removed |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
1153600
0.05%17901
0.19%