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

Use uv for Python dependency management and code execution #107

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

prrao87
Copy link
Member

@prrao87 prrao87 commented Oct 10, 2024

Now that uv has more or less stabilized, we can update the instructions in all READMEs to make the Python workflows more or less identical to that of Rust 🎉.

The commits in this PR will work their way through each of the pieces one by one, showing how to do Python dependency management and code execution via uv instead of the system Python.

  • Upgrade to latest uv release
  • Update hello_world
  • Update intro
  • Update simple_csv

@prrao87
Copy link
Member Author

prrao87 commented Oct 10, 2024

Hi @sanders41, I'm finally getting around to updating the examples to use uv instead of system Python + venv. It should be pretty straightforward. I think there are two things to take care of as the migration is done:

  1. mypy checks seem to be failing in the pre-commit hooks (I think we'll have to figure out how to run mypy via uv - have you figured this out already for other projects?)
  2. I currently manage Python on my machine using pyenv, which is set to my global Python when I call python from the command line. When I do uv run main.py, it's defaulting to using the pyenv-managed Python. What I'd like to do instead, is move away from pyenv entirely (I don't think it's required any more), and instead manage all my Python installs locally via uv instead

Just wanted to keep you aware as I move forward with this. I'll progressively update the docs over the coming days on this.

Copy link
Collaborator

@sanders41 sanders41 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I only had a quick minute to look at things, but I figured out why pre-commit is failing. We need the root level pyproject.toml with the mypy settings.

I still don't understand the issues I had with my local pre-commit, but it finally started working. which pre-commit originally showed the system pre-commit. I deactivated my virtual environment, went to another repo and check it, it showed pre-commit from the virtual environment. I came back to this repo activated again and this time it used pre-commit from the virtual environment and started working 🤷

pyproject.toml Outdated Show resolved Hide resolved
src/hello_world/python/.python-version Show resolved Hide resolved
@prrao87
Copy link
Member Author

prrao87 commented Oct 16, 2024

@sanders41 the pre-commit fixes worked! Not sure how that root level pyproject.toml got removed in the first place 😅 . I think we're good, thanks!

@prrao87
Copy link
Member Author

prrao87 commented Oct 16, 2024

Err one of the tests is failing - it's the mock data for PyO3 - any ideas as to why?

@sanders41
Copy link
Collaborator

My guess based on the error (and it's only a guess at this point) is ubuntu-latest was recently and it has to do with that. This update recently caused me issues with maturin in CI. The error was different, but still makes me wonder if that could be the cause since it looks like it can't find a C file.

I'll have some time tomorrow I can mess around with it to see if I can get it working.

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

Successfully merging this pull request may close these issues.

2 participants