Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: forge Vyper incompatibility with PEP 440 #9123

Closed
2 tasks
pcaversaccio opened this issue Oct 16, 2024 · 7 comments · Fixed by foundry-rs/compilers#213 or #9133
Closed
2 tasks

bug: forge Vyper incompatibility with PEP 440 #9123

pcaversaccio opened this issue Oct 16, 2024 · 7 comments · Fixed by foundry-rs/compilers#213 or #9133
Labels
A-compiler Area: compiler T-bug Type: bug

Comments

@pcaversaccio
Copy link
Contributor

pcaversaccio commented Oct 16, 2024

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (cc8e430 2024-10-16T00:22:08.572482504Z)

What command(s) is the bug in?

forge test

Operating System

Linux

Describe the bug

Foundry Vyper is not compatible with PEP 440 version specifiers.


[OUTDATED]

All of my snekmate pipelines are currently broken (see, e.g. here), due to the latest Vyper commit here: vyperlang/vyper@039d369. forge will throw with:

[⠰] Compiling...
Error:
Found Vyper sources, but no compiler versions are available for it
Build failed: ['forge', 'build', '--ast', '--root', 'snekmate', '--extra-output', 'storageLayout', 'metadata']

image

But if you install one commit before:

pip install git+https://github.com/vyperlang/vyper@8f9a8cac49aafb3fbc9dde78f0f6125c390c32f0

it will succeed. I haven't debugged it yet fully but it's probably related to the commit hash.

@pcaversaccio pcaversaccio added T-bug Type: bug T-needs-triage Type: this issue needs to be labelled labels Oct 16, 2024
@zerosnacks zerosnacks added A-compiler Area: compiler and removed T-needs-triage Type: this issue needs to be labelled labels Oct 16, 2024
@pcaversaccio
Copy link
Contributor Author

Ok I have investigated the issue. It's a pragma issue due to the latest Vyper beta release: v0.4.1b1:

vyper.exceptions.VersionException: Version specification "~=0.4.1" is not compatible with compiler version "0.4.1b1"

  line 1:0
  ---> 1 # pragma version ~=0.4.1
  -------^
       2 """

It would have been super helpful if forge had displayed this error as well. This needs some investigation as in older Vyper commits, the error would have been displayed properly.

@zerosnacks
Copy link
Member

zerosnacks commented Oct 16, 2024

Triaged this w/ @pcaversaccio over Telegram, appears to be unrelated to Foundry but rather related to new pragma formatting. There may be a follow-up on Foundry's side in regards to improving the Found Vyper sources, but no compiler versions are available for it error that is raised.

On the initial build w/ my existing Vyper installation of 0.4.0 it did raise so it might be related to the pragma not being recognized and therefore throwing a catch-all error.

Location: src/snekmate/auth/access_control.vy
Version specification "~=0.4.1" is not compatible with compiler version "0.4.0"

  line 1:0 
  ---> 1 # pragma version ~=0.4.1
  -------^
       2 """

To reproduce:

python3 -m venv env
source env/bin/activate
pip install git+https://github.com/vyperlang/vyper@039d36926cf19916ada19f36b7e8ee9b09c1eec5
forge build

@zerosnacks zerosnacks added T-to-investigate Type: to investigate and removed T-to-investigate Type: to investigate labels Oct 16, 2024
@pcaversaccio
Copy link
Contributor Author

hmm actually it still fails if the pragma is fixed. You can do this in the snekmate repo:

git grep -l '=0.4.1' | xargs sed -i 's/=0.4.1/=0.4.1b1/g'

This will replace all pragma versions with a pragma version that compiles with Vyper commit vyperlang/vyper@039d369.

After run again:

forge build

@zerosnacks
Copy link
Member

hmm actually it still fails if the pragma is fixed.

Was able to track it down to a SemverError(Error("unexpected character 'b' after patch version number")) as 0.4.1b1 is invalid semver

@zerosnacks
Copy link
Member

Turns out it 0.4.1b1 is valid pep440 used since Vyper 0.4.0 but invalid SemVer cc @klkvr

@zerosnacks zerosnacks changed the title Found Vyper sources, but no compiler versions are available for it bug: Found Vyper sources, but no compiler versions are available for it incompatibility with 0.4.1b1 Oct 16, 2024
@pcaversaccio
Copy link
Contributor Author

Correct. The relevant PR is this one. For the pre-releases, you can find the versioning specification here:

X.YaN   # Alpha release
X.YbN   # Beta release
X.YrcN  # Release Candidate
X.Y     # Final release

Also, note that I use PEP 440 compatible version specifier ~ in snekmate (and not ^): https://peps.python.org/pep-0440/#version-specifiers

@pcaversaccio pcaversaccio changed the title bug: Found Vyper sources, but no compiler versions are available for it incompatibility with 0.4.1b1 bug: forge Vyper incompatibility with PEP 440 Oct 16, 2024
@DaniPopes
Copy link
Member

cc @klkvr

klkvr added a commit to foundry-rs/compilers that referenced this issue Oct 16, 2024
Closes foundry-rs/foundry#9123

I've done similar workaround for rc before. For semver we need those to
be prepended by a dash.

PEP440 pragmas are still might not be parsed correctly but this is not a
showstopper as we're just ignoring them right now, and user would see a
vyper error in case of mismatch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-compiler Area: compiler T-bug Type: bug
Projects
Status: Done
3 participants