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

micropip claims it's installing typing-extensions 4.12.2, but it's not #201

Closed
samuelcolvin opened this issue Feb 7, 2025 · 8 comments
Closed

Comments

@samuelcolvin
Copy link
Contributor

See https://pydantic.run/store/0f396bc320c5d2fe,

I'm running

# /// script
# dependencies = ["typing_extensions>=4.12", "pydantic_ai_slim[openai]"]
# ///
from pydantic_ai import Agent
from importlib.metadata import version

print(version('typing_extensions'))

agent = Agent(  
    'test',
    system_prompt='Be concise, reply with one sentence.',  
)

result = await agent.run('Where does "hello world" come from?')  
print(result.data)

and getting an error because the code is using typing-extensions 4.11, but the above print(version('typing_extensions')) is printing 4.12.2.

It seems like there are two (perhaps related) issues:

  • running await micropip.install(["typing_extensions>=4.12", "pydantic_ai_slim[openai]"], keep_going=True) is installing 4.11, not 4.12
  • it somehow setting the importlib metadata to 4.12

I'll note that if I change pydantic.run to use

                for dep in install_dependencies:
                    await micropip.install(dep, keep_going=True)

and install typing_extensions>=4.12 before other pages, the problem goes away.

@ryanking13
Copy link
Member

Thanks for the report @samuelcolvin! I guess this is fixed by #181, could you please try again with micropip 0.9.0?

FYI, what happens is that, we have the typing-extensions==4.11 in the lockfile, and it is installed and overwrites the 4.12 when installing pydantic from the lockfile. But the behavior has been changed in #181 and the package in the lockfile will not overwrite the package downloaded from PyPI anymore

@samuelcolvin
Copy link
Contributor Author

Awesome, thank you, I'll try it.

Sorry for the dumb question, how do I install newer micropip within pyodide?

@hoodmane
Copy link
Member

hoodmane commented Feb 8, 2025

To be honest I'm not really sure either.

@ryanking13
Copy link
Member

Sorry for the dumb question, how do I install newer micropip within pyodide?

You can download micropip directly from the PyPI: pyodide.loadPackage("https://files.pythonhosted.org/packages/27/6d/195810e3e73e5f351dc6082cada41bb4d5b0746a6804155ba6bae4304612/micropip-0.9.0-py3-none-any.whl").

@samuelcolvin
Copy link
Contributor Author

okay, I've installed v0.9.0, but it doesn't solve the problem - same issue occurring.

@samuelcolvin
Copy link
Contributor Author

samuelcolvin commented Feb 8, 2025

There's a bunch of other changes, but you'll see in pydantic/pydantic.run#44 that I'm getting v0.9.0 from pip as you suggested, and getting the same error.

You can see the error in this preview.

@samuelcolvin
Copy link
Contributor Author

samuelcolvin commented Feb 8, 2025

Okay, ignore my comment above, it seems with v0.9.0, the immediate issue is fixed, see pydantic/pydantic.run#44 and preview here.

However I still need to explicitly add typing_extensions>=4.12 as a dependency to get that version installed, even though at least one of the sub-dependencies requires typing_extensions>=4.12.

Should I create another issue?

@samuelcolvin
Copy link
Contributor Author

Closing, I'll create a new issue about the other issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants