Skip to content

Commit ed7d266

Browse files
committed
Initial commit
0 parents  commit ed7d266

File tree

7 files changed

+145
-0
lines changed

7 files changed

+145
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# This workflows will upload a Python Package using Twine when a release is created
2+
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3+
4+
name: Upload Python Package
5+
6+
on:
7+
release:
8+
types: [created]
9+
10+
jobs:
11+
deploy:
12+
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Set up Python
18+
uses: actions/setup-python@v2
19+
with:
20+
python-version: '3.x'
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install setuptools wheel twine
25+
- name: Build and publish
26+
env:
27+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
28+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
29+
run: |
30+
python setup.py sdist bdist_wheel
31+
twine upload dist/*

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*/version.py
2+
.eggs
3+
*.egg-info
4+
__pycache__add

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
EDA Container Wrapper
2+
=====================

edacontainerwrapper/__init__.py

Whitespace-only changes.

edacontainerwrapper/main.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import argparse
2+
import os
3+
import sys
4+
5+
from .run import run, RunArguments, RunArgumentsDefaults, tools
6+
7+
def main():
8+
if os.path.basename(sys.argv[0]) == "eda-container-wrapper":
9+
parser = argparse.ArgumentParser()
10+
parser.add_argument('--split-cwd-tail', type=int, default=RunArgumentsDefaults.split_cwd_tail)
11+
parser.add_argument('--tool-version')
12+
parser.add_argument('tool', choices=tools.keys())
13+
parser.add_argument('toolargs', nargs='*')
14+
args = parser.parse_args()
15+
tool = args.tool
16+
toolargs = args.toolargs
17+
args = RunArguments(
18+
split_cwd_tail = args.split_cwd_tail,
19+
tool_version = args.tool_version if args.tool_version else tools[tool].default_version
20+
)
21+
else:
22+
tool = sys.argv[0]
23+
args = RunArguments(split_cwd_tail=0)
24+
toolargs = sys.argv[1:]
25+
26+
run(tool, args, toolargs)
27+
28+
if __name__ == "__main__":
29+
main()

edacontainerwrapper/run.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import sys
2+
import subprocess
3+
from collections import namedtuple
4+
import os
5+
6+
RunArguments = namedtuple("RunArguments", "split_cwd_tail tool_version")
7+
RunArgumentsDefaults = RunArguments(split_cwd_tail=0, tool_version=None)
8+
9+
def split_path(path, depth):
10+
base = path
11+
tail = ""
12+
for d in range(depth):
13+
base, t = os.path.split(base)
14+
tail = os.path.join(t, tail)
15+
return (base, tail)
16+
17+
ToolContainer = namedtuple("Toolcontainer", "image projectpath default_version")
18+
19+
tools = {
20+
"verilator": ToolContainer(
21+
image="verilator/verilator",
22+
projectpath="/work",
23+
default_version="latest"),
24+
"openlane": ToolContainer(
25+
image="edalize/openlane-sky130",
26+
projectpath="/project",
27+
default_version="v0.12")
28+
}
29+
30+
def run(toolname, args, toolargs):
31+
if toolname not in tools:
32+
raise RuntimeError(f"Unknown Tool: {toolname}")
33+
34+
tool = tools[toolname]
35+
36+
version = os.getenv("TOOL_VERSION", args.tool_version)
37+
38+
root, tail = split_path(os.getcwd(), int(os.getenv("SPLIT_CWD_TAIL", args.split_cwd_tail)))
39+
workdir = os.path.join(tool.projectpath, tail)
40+
41+
cmd = ["docker", "run", "-ti",
42+
"-v", f"{root}:{tool.projectpath}",
43+
"-u", f"{os.getuid()}:{os.getgid()}",
44+
"-w", f"{workdir}",
45+
f"{tool.image}:{version}"
46+
] + toolargs
47+
48+
return subprocess.call(" ".join(cmd), shell=True)

setup.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from setuptools import setup, find_packages
2+
import pathlib
3+
4+
here = pathlib.Path(__file__).parent.resolve()
5+
6+
long_description = (here / 'README.md').read_text(encoding='utf-8')
7+
8+
setup(
9+
name='eda-container-wrapper',
10+
description="Synchronize ICS to Exchange",
11+
packages=["edacontainerwrapper"],
12+
use_scm_version={
13+
"relative_to": __file__,
14+
"write_to": "edacontainerwrapper/version.py",
15+
},
16+
long_description=long_description,
17+
long_description_content_type='text/markdown',
18+
url='https://github.com/librecores/eda-container-wrapper',
19+
author="Stefan Wallentowitz",
20+
author_email='[email protected]',
21+
classifiers=[
22+
"License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)",
23+
"Topic :: Utilities",
24+
],
25+
entry_points={"console_scripts": ["eda-container-wrapper = edacontainerwrapper.main:main"]},
26+
setup_requires=[
27+
"setuptools_scm",
28+
],
29+
install_requires=[
30+
]
31+
)

0 commit comments

Comments
 (0)