-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into docker-infrastructure
- Loading branch information
Showing
6 changed files
with
124 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: epython | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
main: | ||
|
||
runs-on: ubuntu-latest | ||
timeout-minutes: 35 | ||
defaults: | ||
run: | ||
shell: bash -l {0} | ||
concurrency: | ||
group: ci-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: conda-incubator/setup-miniconda@v2 | ||
with: | ||
miniconda-version: "latest" | ||
mamba-version: "*" | ||
environment-file: conda/dev.yaml | ||
channels: conda-forge,nodefaults | ||
activate-environment: epython | ||
use-mamba: true | ||
miniforge-variant: Mambaforge | ||
|
||
- name: installation | ||
run: | | ||
pip install . | ||
epython tests/simpleone.epy --backend=cpython |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
__pycache__/ | ||
*.egg-info/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
name: epython | ||
channels: | ||
- conda-forge | ||
- nodefaults | ||
dependencies: | ||
- python 3.9.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
__version__ = "0.1.0" | ||
|
||
import epython.importer | ||
|
||
from .epython import register_func |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
""" | ||
Importing this module allows import .epy files like .py files. | ||
The main reason for naming epython files with the .epy file extension is to | ||
avoid confusion with regular Python modules. A package may contain a number | ||
of (sub-) modules of which only some are epython extensions. | ||
For development of epython packages, it is nevertheless very useful to import | ||
.epy files just like .pt files, which is possible by simply importing epython | ||
first. E.g. | ||
import epython | ||
import myext # will import myext.epy | ||
Without importing epython first, myext will not work, which helps to avoid | ||
using epython extensions as pure Python modules (which will be quite slow). | ||
""" | ||
import sys | ||
import imp | ||
from os.path import isfile, join | ||
|
||
|
||
class EPY_Importer(object): | ||
|
||
def find_module(self, fullname, path=None): | ||
name = fullname.rsplit('.', 1)[-1] | ||
for dir_path in path or sys.path: | ||
self.path = join(dir_path, name + '.epy') | ||
if isfile(self.path): | ||
self.modtype = imp.PY_SOURCE | ||
return self | ||
return None | ||
|
||
def load_module(self, fullname): | ||
if fullname in sys.modules: | ||
return sys.modules[fullname] | ||
|
||
mod = imp.new_module(fullname) | ||
mod.__file__ = self.path | ||
mod.__loader__ = self | ||
with open(self.path, 'rb') as fi: | ||
code = fi.read() | ||
|
||
exec(code, mod.__dict__) | ||
sys.modules[fullname] = mod | ||
return mod | ||
|
||
|
||
sys.meta_path.append(EPY_Importer()) |