Skip to content

Commit 0ff6ec9

Browse files
authored
Merge branch 'master' into docker-infrastructure
2 parents 6a4d2b0 + fa0e7a1 commit 0ff6ec9

File tree

6 files changed

+124
-3
lines changed

6 files changed

+124
-3
lines changed

.github/workflows/main.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: epython
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
main:
11+
12+
runs-on: ubuntu-latest
13+
timeout-minutes: 35
14+
defaults:
15+
run:
16+
shell: bash -l {0}
17+
concurrency:
18+
group: ci-${{ github.ref }}
19+
cancel-in-progress: true
20+
21+
steps:
22+
- uses: actions/checkout@v2
23+
24+
- uses: conda-incubator/setup-miniconda@v2
25+
with:
26+
miniconda-version: "latest"
27+
mamba-version: "*"
28+
environment-file: conda/dev.yaml
29+
channels: conda-forge,nodefaults
30+
activate-environment: epython
31+
use-mamba: true
32+
miniforge-variant: Mambaforge
33+
34+
- name: installation
35+
run: |
36+
pip install .
37+
epython tests/simpleone.epy --backend=cpython

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
__pycache__/
2+
*.egg-info/

README.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# epython
2+
23
EPython is a typed-subset of the Python language useful for extending the language with new builtin types and methods.
34

45
The goal is to be able to write things like NumPy, SciPy, Pandas, bitarray, and any other extension module of Python in this language and get equivalent or better perfomance than writing it using the C-API typically provided.
@@ -13,12 +14,16 @@ If you are interested in contributing to the design and goals, then join the Dis
1314

1415
# Installation
1516

16-
pip install epython
17+
```bash
18+
pip install epython
19+
```
1720

1821
# Usage
1922

20-
epython extmodule.epy --backend=cpython
21-
23+
```bash
24+
epython extmodule.epy --backend=cpython
25+
```
26+
2227
Produces a compiled extension module for the given Python backend.
2328

2429
## Docker Development
@@ -33,3 +38,23 @@ From the root of the repository.
3338
To run the interactive session:
3439

3540
`docker run -p 8008:8000 -t epython-wasm:latest `
41+
42+
# Development
43+
44+
Create an environment for **epython**:
45+
46+
```bash
47+
$ conda env create --file conda/dev.yaml
48+
```
49+
50+
Activate the **epython** environment:
51+
52+
```bash
53+
$ conda activate epython
54+
```
55+
56+
Install it locally in development mode:
57+
58+
```bash
59+
$ pip install -e .
60+
```

conda/dev.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name: epython
2+
channels:
3+
- conda-forge
4+
- nodefaults
5+
dependencies:
6+
- python 3.9.*

epython/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
__version__ = "0.1.0"
22

3+
import epython.importer
4+
35
from .epython import register_func

epython/importer.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
"""
2+
Importing this module allows import .epy files like .py files.
3+
4+
The main reason for naming epython files with the .epy file extension is to
5+
avoid confusion with regular Python modules. A package may contain a number
6+
of (sub-) modules of which only some are epython extensions.
7+
8+
For development of epython packages, it is nevertheless very useful to import
9+
.epy files just like .pt files, which is possible by simply importing epython
10+
first. E.g.
11+
12+
import epython
13+
import myext # will import myext.epy
14+
15+
Without importing epython first, myext will not work, which helps to avoid
16+
using epython extensions as pure Python modules (which will be quite slow).
17+
"""
18+
import sys
19+
import imp
20+
from os.path import isfile, join
21+
22+
23+
class EPY_Importer(object):
24+
25+
def find_module(self, fullname, path=None):
26+
name = fullname.rsplit('.', 1)[-1]
27+
for dir_path in path or sys.path:
28+
self.path = join(dir_path, name + '.epy')
29+
if isfile(self.path):
30+
self.modtype = imp.PY_SOURCE
31+
return self
32+
return None
33+
34+
def load_module(self, fullname):
35+
if fullname in sys.modules:
36+
return sys.modules[fullname]
37+
38+
mod = imp.new_module(fullname)
39+
mod.__file__ = self.path
40+
mod.__loader__ = self
41+
with open(self.path, 'rb') as fi:
42+
code = fi.read()
43+
44+
exec(code, mod.__dict__)
45+
sys.modules[fullname] = mod
46+
return mod
47+
48+
49+
sys.meta_path.append(EPY_Importer())

0 commit comments

Comments
 (0)