mirror of https://github.com/Nonannet/copapy.git
Script for downloading binaries added, readme updated
This commit is contained in:
parent
22e55fa5d8
commit
4dbfe64195
66
README.md
66
README.md
|
|
@ -1,9 +1,9 @@
|
||||||
# State of the project
|
# Copapy
|
||||||
|
|
||||||
Development is in a very early stage. Only very few components are in a working state.
|
Development is in a very early stage. Only very few components are in a working state.
|
||||||
|
|
||||||
|
|
||||||
# Introduction
|
## Introduction
|
||||||
|
|
||||||
Copapy is a python based embedded domain specific language (eDSL) with a copy & patch compiler. It compiles to machine code. It uses the python interpreter for compilation. It generates a directed graph of variables and operations. The compiler generates machine code by composing pre-compiled stencils derived from C code with gcc -O3.
|
Copapy is a python based embedded domain specific language (eDSL) with a copy & patch compiler. It compiles to machine code. It uses the python interpreter for compilation. It generates a directed graph of variables and operations. The compiler generates machine code by composing pre-compiled stencils derived from C code with gcc -O3.
|
||||||
|
|
||||||
|
|
@ -20,13 +20,69 @@ The language aims to be:
|
||||||
- No runtime errors
|
- No runtime errors
|
||||||
- Immutable types
|
- Immutable types
|
||||||
|
|
||||||
# How it works
|
### How it works
|
||||||
|
|
||||||
## Compilation
|
### Compilation
|
||||||
The Compilation step starts with the directed graph of variables and operations generated by the python interpreter.
|
The Compilation step starts with the directed graph of variables and operations generated by the python interpreter.
|
||||||
|
|
||||||
## Tooling
|
### Tooling
|
||||||
Because the language is an embedded language, it can relay heavily on python tooling. While copapy is static typed, it uses Python to derive types during compile time wherever possible. It can get full benefit from python type checkers, to catch type errors even before compilation. Python and Copapy code can be combined seamlessly. Python acts as macro-language for the Copapy program. However, the project is designed in a way that the distinction has typically not to be considered by the programmer.
|
Because the language is an embedded language, it can relay heavily on python tooling. While copapy is static typed, it uses Python to derive types during compile time wherever possible. It can get full benefit from python type checkers, to catch type errors even before compilation. Python and Copapy code can be combined seamlessly. Python acts as macro-language for the Copapy program. However, the project is designed in a way that the distinction has typically not to be considered by the programmer.
|
||||||
|
|
||||||
|
|
||||||
|
## Developer Guide
|
||||||
|
Contributions are welcome, please open an issue or submit a pull request on GitHub.
|
||||||
|
|
||||||
|
To get started with developing the package, follow these steps.
|
||||||
|
|
||||||
|
First, clone the repository to your local machine using Git:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/Nonannet/copapy.git
|
||||||
|
cd copapy
|
||||||
|
```
|
||||||
|
|
||||||
|
You may setup a venv:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python -m venv .venv
|
||||||
|
source .venv/bin/activate # On Windows use `.venv\Scripts\activate`
|
||||||
|
```
|
||||||
|
|
||||||
|
Build and install the package and dev dependencies:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install .[dev]
|
||||||
|
```
|
||||||
|
|
||||||
|
If this fails because you have no suitable c compiler installed you can either install a
|
||||||
|
compiler or use the binary from pypi:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install copapy[dev]
|
||||||
|
```
|
||||||
|
|
||||||
|
When using pytest it will run the binary from pypi but the local python code from the repo.
|
||||||
|
|
||||||
|
For running all tests you need the stencil object files and the compiled runner.
|
||||||
|
You can download the stencils and binary runner from GitHub or build them with gcc your self.
|
||||||
|
|
||||||
|
For downloading the files run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python tools/get_binaries.py
|
||||||
|
```
|
||||||
|
|
||||||
|
To build the binaries from source on linux run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
bash tools/build.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
Ensure that everything is set up correctly by running the unit tests:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pytest
|
||||||
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,9 @@ copapy = ["obj/*.o", "py.typed"]
|
||||||
dev = [
|
dev = [
|
||||||
"ruff",
|
"ruff",
|
||||||
"mypy",
|
"mypy",
|
||||||
"pytest"
|
"pytest",
|
||||||
|
"requests",
|
||||||
|
"types-requests"
|
||||||
]
|
]
|
||||||
|
|
||||||
[tool.mypy]
|
[tool.mypy]
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
import os
|
||||||
|
import requests
|
||||||
|
|
||||||
|
OWNER = "Nonannet"
|
||||||
|
REPO = "copapy"
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
# Get all releases (includes prereleases)
|
||||||
|
api_url = f"https://api.github.com/repos/{OWNER}/{REPO}/releases"
|
||||||
|
resp = requests.get(api_url, timeout=10)
|
||||||
|
resp.raise_for_status()
|
||||||
|
releases = resp.json()
|
||||||
|
|
||||||
|
assert releases, "No releases found."
|
||||||
|
|
||||||
|
release = releases[0] # newest release (first in list)
|
||||||
|
tag = release["tag_name"]
|
||||||
|
print(f"Found latest release: {tag}")
|
||||||
|
|
||||||
|
assets = release.get("assets", [])
|
||||||
|
assert assets, "No assets found for this release."
|
||||||
|
|
||||||
|
for asset in assets:
|
||||||
|
url = asset["browser_download_url"]
|
||||||
|
name: str = asset["name"]
|
||||||
|
|
||||||
|
if name.endswith('.o'):
|
||||||
|
dest = 'src/copapy/obj'
|
||||||
|
elif name == 'coparun.exe' and os.name == 'nt':
|
||||||
|
dest = 'bin'
|
||||||
|
elif name == 'coparun' and os.name == 'posix':
|
||||||
|
dest = 'bin'
|
||||||
|
else:
|
||||||
|
dest = ''
|
||||||
|
|
||||||
|
if dest:
|
||||||
|
os.makedirs(dest, exist_ok=True)
|
||||||
|
print(f"- Downloading {name} ...")
|
||||||
|
r = requests.get(url, stream=True, timeout=30)
|
||||||
|
r.raise_for_status()
|
||||||
|
with open(os.path.join(dest, name), "wb") as f:
|
||||||
|
for chunk in r.iter_content(chunk_size=8192):
|
||||||
|
f.write(chunk)
|
||||||
|
print(f"- Saved {name} to {dest}")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Loading…
Reference in New Issue