{"id":16937971,"url":"https://github.com/megaing/syntax-extensions-base","last_synced_at":"2026-05-15T13:31:40.533Z","repository":{"id":130791631,"uuid":"322432429","full_name":"MegaIng/syntax-extensions-base","owner":"MegaIng","description":"Base package for syntax-extensions to python","archived":false,"fork":false,"pushed_at":"2021-01-10T20:18:49.000Z","size":17,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-16T04:46:03.079Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MegaIng.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-17T22:57:01.000Z","updated_at":"2023-01-29T11:42:16.000Z","dependencies_parsed_at":"2023-04-04T23:22:08.451Z","dependency_job_id":null,"html_url":"https://github.com/MegaIng/syntax-extensions-base","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MegaIng/syntax-extensions-base","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MegaIng%2Fsyntax-extensions-base","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MegaIng%2Fsyntax-extensions-base/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MegaIng%2Fsyntax-extensions-base/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MegaIng%2Fsyntax-extensions-base/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MegaIng","download_url":"https://codeload.github.com/MegaIng/syntax-extensions-base/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MegaIng%2Fsyntax-extensions-base/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33068360,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-15T11:35:32.926Z","status":"ssl_error","status_checked_at":"2026-05-15T11:35:31.362Z","response_time":103,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T21:00:31.931Z","updated_at":"2026-05-15T13:31:40.511Z","avatar_url":"https://github.com/MegaIng.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# syntax-extensions-base\nBase package for syntax-extensions to python\n\nAllows one to use/create custom syntax extensions for python as simple as possible.\n\n\n## How to get started\n\nFirst, you need to install this package, this can be done via cloning this repo and running `python -m pip install .` inside of the root folder.\n\nThen you need to select a way of preloading `syntax-extensions` before python runs your code with extensions. This can be done a few ways:\n\n\n- creating a `sitecustomize.py`/`usercustomize.py` file with the following content: `import syntax_extensions.activate; syntax_extensions.activate.activate_encoding()`\n  - (This has to be somewhere in your PATH)\n- The same line could also be put inside a `.pth` file. Name is irrelevant, but something clear will help (e.g. `syntax_extensions.pth`)\n  - Needs to be inside `site-packages`\n  - The line can't be split up.\n- Creating an extra `main-wrapper.py` file that first executes the line, and the executes the actual main file.\n- Other options will come in the future (most notably, a preloader script that acts like `main-wrapper.py` for any python command)\n\nNow you need to actually write code using this. Here an example:\n\n```\n# -*- coding: syntax-extensions -*-\nfrom __syntax_extensions__ import test_base\n\nprint(test_base)\n```\n\nNote that the first line is important, since it is what tells python to actually let `syntax_extensions` work on the file before it is parsed.\n\nThe second line tells `syntax_extensions` what to do. These extensions can be installed separately. At the moment, `test_base` is a very simple package to test that the infrastructure is working. It prints `Transforming...` when it is acting on the code and also adds a `print('test_base')` statement at the end of the file.\n\nIf you get an `SyntaxError: encoding problem: syntax-extensions` messages, this (probably) means that `syntax_extensions` isn't correctly preloaded.\n\n\n## How it works\n\n### Basic structure\n`syntax-extensions-base` consists of a few parts:\n\n-`__syntax_extensions__` - A simple module serving a similar purpose as `__future__`: Preventing the default import semantics from complaining about a non-existence module. Also allows one to get some basic info about the extensions.\n-`syntax_extensions` - A namespace package, containing a variety of packages\n  - `.base` The correct implementation: A parser, and a `apply` function (And utils in the future).\n  - `.activate` A package containing glue code making sure that the extensions are applied. Will contain at least two methods, currently only `encoding` is implemented (and `import` is planned. This will override the default import mechanics)\n  - `.__main__` Will at some point in the future be the wrapper script, to allow one to execute `python -m syntax_extensions main.py` without having to install some additional preloader.\n  - `.extensions` Another namespace package. This is where other packages will put their code into.\n\n### How to create your package\n\nUses this template: (TODO)\n\nIn general, you need to create a directory structure of the form `syntax_extensions/extensions/your_extension_name.py` *without* any `__init__.py` files. As long as the parent directory of `syntax_extensions`  is in the path, this should already be it. Now you just need to create a `transform` method inside the file that takes a `syntax_extensions.base.parser.Module` instance and transforms it inplace.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmegaing%2Fsyntax-extensions-base","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmegaing%2Fsyntax-extensions-base","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmegaing%2Fsyntax-extensions-base/lists"}