Skip to content

Commit

Permalink
fix: allow source install of vyper (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey authored Jan 22, 2022
1 parent 80f3be2 commit eddd325
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions ape_vyper/compiler.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import re
import shutil
from pathlib import Path
from typing import Dict, List, Optional, Set, Union

Expand Down Expand Up @@ -65,7 +66,9 @@ def package_version(self) -> Optional[Version]:
try:
import vyper # type: ignore

return Version(vyper.__version__)
# Strip off parts from source-installation
version = Version.coerce(vyper.__version__)
return Version(major=version.major, minor=version.minor, patch=version.patch)

except ImportError:
return None
Expand Down Expand Up @@ -100,9 +103,10 @@ def compile(
pragma_spec = get_pragma_spec(source)
# check if we need to install specified compiler version
if pragma_spec:
if pragma_spec is not pragma_spec.select(self.installed_versions):
if pragma_spec and not pragma_spec.select(self.installed_versions):
vyper_version = pragma_spec.select(self.available_versions)
if vyper_version:

if vyper_version and vyper_version != self.package_version:
_install_vyper(vyper_version)
else:
raise VyperInstallError("No available version to install.")
Expand All @@ -118,7 +122,9 @@ def compile(
try:
result = vvm.compile_source(
source,
base_path=base_path,
vyper_version=vyper_version,
vyper_binary=shutil.which("vyper") or None,
)["<stdin>"]
except Exception as err:
raise VyperCompileError(err) from err
Expand Down

0 comments on commit eddd325

Please sign in to comment.