Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #41 from unparalleled-js/feat/get-compiler-settings
Browse files Browse the repository at this point in the history
fix: issue with dependencies
  • Loading branch information
dtdang authored Jan 5, 2023
2 parents ccf5e1b + 1d98db7 commit 95384ab
Show file tree
Hide file tree
Showing 14 changed files with 83 additions and 40 deletions.
15 changes: 8 additions & 7 deletions .github/ISSUE_TEMPLATE/bug.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
---
name: Bug report
about: Report an error that you've encountered.
labels: 'bug'
labels: bug
---

### Environment information

* `ape` and plugin versions:
- `ape` and plugin versions:

```
$ ape --version
Expand All @@ -15,16 +16,16 @@ $ ape plugins list
# ...copy and paste result of above command here...
```

* Python Version: x.x.x
* OS: macOS/linux/win
- Python Version: x.x.x
- OS: macOS/linux/win

### What went wrong?

Please include information like:

* what command you ran
* the code that caused the failure (see [this link](https://help.github.com/articles/basic-writing-and-formatting-syntax/) for help with formatting code)
* full output of the error you received
- what command you ran
- the code that caused the failure (see [this link](https://help.github.com/articles/basic-writing-and-formatting-syntax/) for help with formatting code)
- full output of the error you received

### How can it be fixed?

Expand Down
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/feature.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
---
name: Feature request
about: Request a new feature, or an improvement to existing functionality.
labels: 'enhancement'
labels: enhancement
---

### Overview

Provide a simple overview of what you wish to see added. Please include:

* What you are trying to do
* Why Ape's current functionality is inadequate to address your goal
- What you are trying to do
- Why Ape's current functionality is inadequate to address your goal

### Specification

Expand Down
21 changes: 14 additions & 7 deletions .github/ISSUE_TEMPLATE/work-item.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,48 @@
---
name: Work item
about: New work item for Ape team
labels: 'backlog'

labels: backlog
---

### Elevator pitch:

<!-- 1-2 line summary of the scope of this work item -->

### Value:

<!--
Who is this for?
Persona or group of people whom will derive value from the scenario.
What benefits will be achieved or business metrics improved?
-->

### Dependencies:

<!-- Call out key people, teams, tech dependencies, or assumptions. -->

### Design approach:

<!--
Free text / diagram / whiteboard picture / etc. that clearly shows your approach and considerations to build the task list.
Existing code patterns in production code base that you will base your work off of.
-->

### Task list:

<!-- Bulleted list describing the exit criteria, desired end state and any documentation, monitors, work for DRI, etc. that will need to be added to make sure someone else can support once it's live. -->
* [ ] Tasks go here

### Estimated completion date:
- [ ] Tasks go here

### Estimated completion date:

### Design review:

<!-- 1-2 people needed for signoff -->

Do not signoff unless:
- 1) agreed the tasks and design approach will achieve acceptance, and
- 2) the work can be completed by one person within the SLA.
Design reviewers should consider simpler approaches to achieve goals.

- 1. agreed the tasks and design approach will achieve acceptance, and
- 2. the work can be completed by one person within the SLA.
Design reviewers should consider simpler approaches to achieve goals.

(Please leave a comment to sign off)
1 change: 1 addition & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
### What I did

<!-- The `fixes:` field denotes an issue that will be marked resolved by merging this PR -->

fixes: #

### How I did it
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/commitlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.9

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.8

Expand Down
26 changes: 18 additions & 8 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,22 @@ on: ["push", "pull_request"]

name: Test

concurrency:
# Cancel older, in-progress jobs from the same PR, same workflow.
# use run_id if the job is triggered by a push to ensure
# push-triggered jobs to not get canceled.
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
linting:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.8

Expand All @@ -22,20 +29,23 @@ jobs:
- name: Run Black
run: black --check .

- name: Run isort
run: isort --check-only .

- name: Run flake8
run: flake8 .

- name: Run isort
run: isort --check-only .
- name: Run mdformat
run: mdformat . --check

type-check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.9

Expand All @@ -56,10 +66,10 @@ jobs:
python-version: [3.8, 3.9]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/title.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.9

Expand Down
1 change: 1 addition & 0 deletions .mdformat.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
number = true
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ repos:
- id: mypy
additional_dependencies: [types-setuptools]

- repo: https://github.com/executablebooks/mdformat
rev: 0.7.14
hooks:
- id: mdformat
additional_dependencies: [mdformat-gfm, mdformat-frontmatter]


default_language_version:
python: python3
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Ape compiler plugin around [the Cairo language](https://github.com/starkware-lib

## Dependencies

* [python3](https://www.python.org/downloads) version 3.8 or greater, python3-dev
- [python3](https://www.python.org/downloads) version 3.8 or greater, python3-dev

## Installation

Expand Down
18 changes: 16 additions & 2 deletions ape_cairo/compiler.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from pathlib import Path
from typing import List, Optional, Set
from typing import Dict, List, Optional, Set, cast

from ape.api import CompilerAPI, PluginConfig
from ape.exceptions import CompilerError, ConfigError
from ape.utils import get_relative_path
from ethpm_types import ContractType, PackageManifest
from pkg_resources import get_distribution
from semantic_version import Version # type: ignore
from starknet_py.compile.compiler import CairoFilename, starknet_compile # type: ignore
from starkware.starknet.services.api.contract_class import ContractClass # type: ignore

Expand All @@ -30,7 +31,19 @@ def name(self) -> str:

@property
def config(self) -> CairoConfig:
return self.config_manager.get_config("cairo") # type: ignore
return cast(CairoConfig, self.config_manager.get_config("cairo"))

def get_compiler_settings(
self, contract_filepaths: List[Path], base_path: Optional[Path] = None
) -> Dict[Version, Dict]:
settings: Dict[Version, Dict] = {}
for version in self.get_versions(contract_filepaths):
if version in settings:
continue

settings[version] = {}

return settings

def load_dependencies(self, base_path: Optional[Path] = None):
_ = self.project_manager.dependencies
Expand Down Expand Up @@ -75,6 +88,7 @@ def load_dependencies(self, base_path: Optional[Path] = None):
raise CompilerError(f"Dependency '{dependency_name}={version}' missing.")

source_manifest = PackageManifest.parse_raw(source_manifest_path.read_text())
destination_base_path = base_path / ".cache" / dependency_name / version

if dependency_name not in [d.name for d in self.config_manager.dependencies]:
raise ConfigError(f"Dependency '{dependency_item}' not configured.")
Expand Down
11 changes: 7 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
"types-setuptools", # Needed due to mypy typeshed
"flake8>=5.0.4", # Style linter
"isort>=5.10.1", # Import sorting linter
"mdformat>=0.7.16", # Auto-formatter for markdown
"mdformat-gfm>=0.3.5", # Needed for formatting GitHub-flavored markdown
"mdformat-frontmatter>=0.4.1", # Needed for frontmatters-style headers in issue templates
],
"release": [ # `release` GitHub Action job uses this
"setuptools", # Installation tool
Expand Down Expand Up @@ -54,10 +57,10 @@
url="https://github.com/ApeWorX/ape-cairo",
include_package_data=True,
install_requires=[
"cairo-lang>=0.10.1,<0.11",
"starknet.py>=0.10.0a0,<0.11",
"eth-ape>=0.5.5,<0.6",
"ethpm-types",
"cairo-lang>=0.10.3,<0.11",
"starknet_py>=0.12.0a0,<0.13",
"eth-ape>=0.5.9,<0.6",
"ethpm-types", # Use same version as eth-ape
],
python_requires=">=3.8,<3.11",
extras_require=extras_require,
Expand Down
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def project(config):
copy_tree(str(PROJECT_DIRECTORY.as_posix()), str(project_dest_dir))
with config.using_project(project_dest_dir) as project:
yield project
if project._project._cache_folder.is_dir():
shutil.rmtree(project._project._cache_folder)
if project.local_project._cache_folder.is_dir():
shutil.rmtree(project.local_project._cache_folder)


# NOTE: Params converted to strings to looks nicer in pytest case outputs
Expand Down

0 comments on commit 95384ab

Please sign in to comment.