primitive 0.1.2__tar.gz → 0.1.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- primitive-0.1.4/.vscode/settings.json +10 -0
- {primitive-0.1.2 → primitive-0.1.4}/PKG-INFO +1 -1
- primitive-0.1.4/linux setup.md +26 -0
- {primitive-0.1.2 → primitive-0.1.4}/src/primitive/__about__.py +1 -1
- primitive-0.1.4/src/primitive/lint/actions.py +67 -0
- primitive-0.1.4/src/primitive/lint/commands.py +17 -0
- primitive-0.1.4/src/primitive/utils/files.py +16 -0
- {primitive-0.1.2 → primitive-0.1.4}/src/primitive/utils/printer.py +1 -1
- primitive-0.1.4/src/primitive/utils/shell.py +63 -0
- primitive-0.1.4/src/primitive/utils/verible.py +51 -0
- primitive-0.1.2/.vscode/settings.json +0 -3
- primitive-0.1.2/src/primitive/lint/actions.py +0 -6
- primitive-0.1.2/src/primitive/lint/commands.py +0 -15
- {primitive-0.1.2 → primitive-0.1.4}/.git-hooks/pre-commit +0 -0
- {primitive-0.1.2 → primitive-0.1.4}/.gitattributes +0 -0
- {primitive-0.1.2 → primitive-0.1.4}/.github/workflows/lint.yml +0 -0
- {primitive-0.1.2 → primitive-0.1.4}/.github/workflows/publish.yml +0 -0
- {primitive-0.1.2 → primitive-0.1.4}/.gitignore +0 -0
- {primitive-0.1.2 → primitive-0.1.4}/LICENSE.txt +0 -0
- {primitive-0.1.2 → primitive-0.1.4}/Makefile +0 -0
- {primitive-0.1.2 → primitive-0.1.4}/README.md +0 -0
- {primitive-0.1.2 → primitive-0.1.4}/pyproject.toml +0 -0
- {primitive-0.1.2 → primitive-0.1.4}/requirements.txt +0 -0
- {primitive-0.1.2 → primitive-0.1.4}/src/primitive/__init__.py +0 -0
- {primitive-0.1.2 → primitive-0.1.4}/src/primitive/auth/__init__.py +0 -0
- {primitive-0.1.2 → primitive-0.1.4}/src/primitive/auth/actions.py +0 -0
- {primitive-0.1.2 → primitive-0.1.4}/src/primitive/auth/commands.py +0 -0
- {primitive-0.1.2 → primitive-0.1.4}/src/primitive/cli.py +0 -0
- {primitive-0.1.2 → primitive-0.1.4}/src/primitive/client.py +0 -0
- {primitive-0.1.2 → primitive-0.1.4}/src/primitive/files/actions.py +0 -0
- {primitive-0.1.2 → primitive-0.1.4}/src/primitive/files/commands.py +0 -0
- {primitive-0.1.2 → primitive-0.1.4}/src/primitive/graphql/__init__.py +0 -0
- {primitive-0.1.2 → primitive-0.1.4}/src/primitive/graphql/sdk.py +0 -0
- {primitive-0.1.2 → primitive-0.1.4}/src/primitive/hardware/actions.py +0 -0
- {primitive-0.1.2 → primitive-0.1.4}/src/primitive/hardware/commands.py +0 -0
- {primitive-0.1.2 → primitive-0.1.4}/src/primitive/projects/__init__.py +0 -0
- {primitive-0.1.2 → primitive-0.1.4}/src/primitive/projects/actions.py +0 -0
- {primitive-0.1.2 → primitive-0.1.4}/src/primitive/simulations/__init__.py +0 -0
- {primitive-0.1.2 → primitive-0.1.4}/src/primitive/simulations/actions.py +0 -0
- {primitive-0.1.2 → primitive-0.1.4}/src/primitive/utils/actions.py +0 -0
- {primitive-0.1.2 → primitive-0.1.4}/src/primitive/utils/config.py +0 -0
- {primitive-0.1.2 → primitive-0.1.4}/src/primitive/utils/git.py +0 -0
- {primitive-0.1.2 → primitive-0.1.4}/src/primitive/utils/memory_size.py +0 -0
- {primitive-0.1.2 → primitive-0.1.4}/tests/__init__.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: primitive
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.4
|
4
4
|
Project-URL: Documentation, https://github.com//primitivecorp/primitive-cli#readme
|
5
5
|
Project-URL: Issues, https://github.com//primitivecorp/primitive-cli/issues
|
6
6
|
Project-URL: Source, https://github.com//primitivecorp/primitive-cli
|
@@ -0,0 +1,26 @@
|
|
1
|
+
linux setup
|
2
|
+
|
3
|
+
```
|
4
|
+
curl https://pyenv.run | bash
|
5
|
+
|
6
|
+
# for .bashrc
|
7
|
+
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
|
8
|
+
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
|
9
|
+
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
|
10
|
+
|
11
|
+
# for .bash_profile
|
12
|
+
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
|
13
|
+
echo '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
|
14
|
+
echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
|
15
|
+
|
16
|
+
# python compilation requirements https://github.com/pyenv/pyenv/wiki#suggested-build-environment
|
17
|
+
# FOR UBUNTU
|
18
|
+
sudo apt update; sudo apt install build-essential libssl-dev zlib1g-dev \
|
19
|
+
libbz2-dev libreadline-dev libsqlite3-dev curl git \
|
20
|
+
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
|
21
|
+
|
22
|
+
pyenv install 3.12.5
|
23
|
+
pyenv global 3.12.5
|
24
|
+
pip install --upgrade pip
|
25
|
+
|
26
|
+
```
|
@@ -0,0 +1,67 @@
|
|
1
|
+
from pathlib import Path
|
2
|
+
from primitive.utils.actions import BaseAction
|
3
|
+
import subprocess
|
4
|
+
from typing import Tuple
|
5
|
+
from loguru import logger
|
6
|
+
from ..utils.files import find_files_for_extension
|
7
|
+
from ..utils.verible import install_verible
|
8
|
+
|
9
|
+
|
10
|
+
class Lint(BaseAction):
|
11
|
+
def execute(self, source: Path = Path.cwd()) -> Tuple[bool, str]:
|
12
|
+
logger.debug("Starting linter...")
|
13
|
+
files = find_files_for_extension(source, ".sv")
|
14
|
+
if not files:
|
15
|
+
message = "No files found to lint."
|
16
|
+
logger.warning(message)
|
17
|
+
return False, message
|
18
|
+
|
19
|
+
logger.debug("Checking if verible is installed")
|
20
|
+
try:
|
21
|
+
subprocess.run(["verible-verilog-lint", "--version"], capture_output=True)
|
22
|
+
except FileNotFoundError:
|
23
|
+
logger.debug("Did not find verible. Installing...")
|
24
|
+
try:
|
25
|
+
system_info = self.primitive.hardware.get_system_info()
|
26
|
+
install_verible(system_info=system_info)
|
27
|
+
except Exception as exception:
|
28
|
+
message = f"Failed to install verible. {exception}"
|
29
|
+
logger.error(message)
|
30
|
+
return False, message
|
31
|
+
|
32
|
+
try:
|
33
|
+
subprocess.run(["verible-verilog-lint", "--version"], capture_output=True)
|
34
|
+
except FileNotFoundError:
|
35
|
+
message = "Verible is not installed. Please install it to run lint."
|
36
|
+
logger.error(message)
|
37
|
+
return False, message
|
38
|
+
|
39
|
+
# TODO:
|
40
|
+
# run is great for now! we will need to switch to Popen if we want to stream the output
|
41
|
+
logger.debug("Running linter...")
|
42
|
+
result = subprocess.run(
|
43
|
+
["verible-verilog-lint", *files],
|
44
|
+
capture_output=True,
|
45
|
+
text=True,
|
46
|
+
)
|
47
|
+
|
48
|
+
logger.debug("Linting complete.")
|
49
|
+
|
50
|
+
message = ""
|
51
|
+
if self.primitive.DEBUG:
|
52
|
+
if result.stderr:
|
53
|
+
logger.error("\n" + result.stderr)
|
54
|
+
if result.stdout:
|
55
|
+
logger.info("\n" + result.stdout)
|
56
|
+
message = "See above logs for linter output."
|
57
|
+
else:
|
58
|
+
message = result.stderr
|
59
|
+
|
60
|
+
if result.returncode != 0:
|
61
|
+
if not self.primitive.DEBUG:
|
62
|
+
message = result.stderr
|
63
|
+
return (False, message)
|
64
|
+
else:
|
65
|
+
message = "Linting successful."
|
66
|
+
|
67
|
+
return True, message
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import click
|
2
|
+
from pathlib import Path
|
3
|
+
import typing
|
4
|
+
from ..utils.printer import print_result
|
5
|
+
|
6
|
+
if typing.TYPE_CHECKING:
|
7
|
+
from ..client import Primitive
|
8
|
+
|
9
|
+
|
10
|
+
@click.command("lint")
|
11
|
+
@click.pass_context
|
12
|
+
@click.argument("source", type=click.Path(exists=True), default=".")
|
13
|
+
def cli(context, source: str):
|
14
|
+
"""Lint"""
|
15
|
+
primitive: Primitive = context.obj.get("PRIMITIVE")
|
16
|
+
result, message = primitive.lint.execute(source=Path(source))
|
17
|
+
print_result(message=message, context=context)
|
@@ -0,0 +1,16 @@
|
|
1
|
+
from typing import List, Tuple
|
2
|
+
from pathlib import Path
|
3
|
+
from loguru import logger
|
4
|
+
|
5
|
+
|
6
|
+
def find_files_for_extension(source: Path, extensions: Tuple[str]) -> List[Path]:
|
7
|
+
matching_files = []
|
8
|
+
logger.debug(f"Looking for files at {source} with extensions {extensions}")
|
9
|
+
for dirpath, dirnames, filenames in source.walk():
|
10
|
+
for filename in filenames:
|
11
|
+
if filename.endswith(extensions):
|
12
|
+
matching_files.append(dirpath.joinpath(filename))
|
13
|
+
logger.debug(
|
14
|
+
f"Found {len(matching_files)} following files that match: {matching_files}"
|
15
|
+
)
|
16
|
+
return matching_files
|
@@ -7,7 +7,7 @@ from loguru import logger
|
|
7
7
|
def print_result(message: str, context: click.Context, fg: str = None):
|
8
8
|
"""Print message to stdout or stderr"""
|
9
9
|
if context.obj["DEBUG"]:
|
10
|
-
logger.
|
10
|
+
logger.info(json.dumps(message))
|
11
11
|
else:
|
12
12
|
if context.obj["JSON"]:
|
13
13
|
message = json.dumps(message, indent=2)
|
@@ -0,0 +1,63 @@
|
|
1
|
+
from pathlib import Path
|
2
|
+
import subprocess
|
3
|
+
|
4
|
+
|
5
|
+
def add_path_to_shell(path: Path):
|
6
|
+
try:
|
7
|
+
subprocess.run(["fish_add_path", path], capture_output=True)
|
8
|
+
return True
|
9
|
+
except FileNotFoundError:
|
10
|
+
pass
|
11
|
+
|
12
|
+
if Path.home() / ".bash_profile":
|
13
|
+
subprocess.run(
|
14
|
+
[
|
15
|
+
"echo",
|
16
|
+
f"'export PATH={path}:$PATH'",
|
17
|
+
">>",
|
18
|
+
"~/.bash_profile",
|
19
|
+
],
|
20
|
+
capture_output=True,
|
21
|
+
)
|
22
|
+
elif Path.home() / ".bashrc":
|
23
|
+
subprocess.run(
|
24
|
+
[
|
25
|
+
"echo",
|
26
|
+
f"'export PATH={path}:$PATH'",
|
27
|
+
">>",
|
28
|
+
"~/.bashrc",
|
29
|
+
],
|
30
|
+
capture_output=True,
|
31
|
+
)
|
32
|
+
elif Path.home() / ".zshrc":
|
33
|
+
subprocess.run(
|
34
|
+
[
|
35
|
+
"echo",
|
36
|
+
f"'export PATH={path}:$PATH'",
|
37
|
+
">>",
|
38
|
+
"~/.zshrc",
|
39
|
+
],
|
40
|
+
capture_output=True,
|
41
|
+
)
|
42
|
+
elif Path.home() / ".profile":
|
43
|
+
subprocess.run(
|
44
|
+
[
|
45
|
+
"echo",
|
46
|
+
f"'export PATH={path}:$PATH'",
|
47
|
+
">>",
|
48
|
+
"~/.profile",
|
49
|
+
],
|
50
|
+
capture_output=True,
|
51
|
+
)
|
52
|
+
elif Path.home() / ".bash_login":
|
53
|
+
subprocess.run(
|
54
|
+
[
|
55
|
+
"echo",
|
56
|
+
f"'export PATH={path}:$PATH'",
|
57
|
+
">>",
|
58
|
+
"~/.bash_login",
|
59
|
+
],
|
60
|
+
capture_output=True,
|
61
|
+
)
|
62
|
+
else:
|
63
|
+
raise Exception(f"Failed to add {path} to PATH")
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import tarfile
|
2
|
+
import requests
|
3
|
+
from .shell import add_path_to_shell
|
4
|
+
from pathlib import Path
|
5
|
+
|
6
|
+
from loguru import logger
|
7
|
+
|
8
|
+
|
9
|
+
VERIBLE_MAC_OS_LINK = "https://github.com/chipsalliance/verible/releases/download/v0.0-3752-g8b64887e/verible-v0.0-3752-g8b64887e-macOS.tar.gz"
|
10
|
+
VERIBLE_WINDOWS_64_OS_LINK = "https://github.com/chipsalliance/verible/releases/download/v0.0-3752-g8b64887e/verible-v0.0-3752-g8b64887e-win64.zip"
|
11
|
+
VERIBLE_LINUX_X86_64_OS_LINK = "https://github.com/chipsalliance/verible/releases/download/v0.0-3752-g8b64887e/verible-v0.0-3752-g8b64887e-linux-static-x86_64.tar.gz"
|
12
|
+
VERIBLE_LINUX_ARM64_LINK = "https://github.com/chipsalliance/verible/releases/download/v0.0-3752-g8b64887e/verible-v0.0-3752-g8b64887e-linux-static-arm64.tar.gz"
|
13
|
+
|
14
|
+
|
15
|
+
def install_verible(system_info: dict) -> bool:
|
16
|
+
url = None
|
17
|
+
if system_info.get("os_family") == "Darwin":
|
18
|
+
url = VERIBLE_MAC_OS_LINK
|
19
|
+
elif system_info.get("os_family") == "Windows":
|
20
|
+
url = VERIBLE_WINDOWS_64_OS_LINK
|
21
|
+
elif system_info.processor == "x86_64":
|
22
|
+
url = VERIBLE_LINUX_X86_64_OS_LINK
|
23
|
+
elif system_info.processor == "arm":
|
24
|
+
url = VERIBLE_LINUX_X86_64_OS_LINK
|
25
|
+
|
26
|
+
verible_dir_name = url.split("/")[-1].split(".tar.gz")[0]
|
27
|
+
file_download_path = Path.home() / f"{verible_dir_name}.tar.gz"
|
28
|
+
|
29
|
+
logger.debug("Downloading verible")
|
30
|
+
response = requests.get(url, stream=True)
|
31
|
+
if response.status_code == 200:
|
32
|
+
with open(file_download_path, "wb") as file:
|
33
|
+
file.write(response.raw.read())
|
34
|
+
else:
|
35
|
+
raise Exception(
|
36
|
+
f"Failed to download verible. {response.status_code}. {response.text}"
|
37
|
+
)
|
38
|
+
|
39
|
+
logger.debug("Untaring verible")
|
40
|
+
with tarfile.open(file_download_path) as tar:
|
41
|
+
tar.extractall(Path.home())
|
42
|
+
|
43
|
+
logger.debug("Deleting tar.gz artifact")
|
44
|
+
file_download_path.unlink()
|
45
|
+
|
46
|
+
verible_bin = Path.home() / verible_dir_name / "bin"
|
47
|
+
|
48
|
+
logger.debug("Adding verible to PATH")
|
49
|
+
add_path_to_shell(verible_bin)
|
50
|
+
|
51
|
+
return True
|
@@ -1,15 +0,0 @@
|
|
1
|
-
import click
|
2
|
-
|
3
|
-
|
4
|
-
import typing
|
5
|
-
|
6
|
-
if typing.TYPE_CHECKING:
|
7
|
-
from ..client import Primitive
|
8
|
-
|
9
|
-
|
10
|
-
@click.command("lint")
|
11
|
-
@click.pass_context
|
12
|
-
def cli(context):
|
13
|
-
"""Lint"""
|
14
|
-
primitive: Primitive = context.obj.get("PRIMITIVE")
|
15
|
-
primitive.lint.run_lint()
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|