July 9th, 2024

Rye: A Hassle-Free Python Experience

Rye is a Python project and package management tool for developers. It simplifies Python installations, project management, dependencies, and virtual environments. Installation instructions are available for Linux, macOS, and Windows systems. Users need Rust and Cargo for Rye.

Read original articleLink Icon
Rye: A Hassle-Free Python Experience

Rye is a project and package management tool for Python, aiming to provide a hassle-free experience for developers of all levels. It offers a unified solution for installing and managing Python installations, projects, dependencies, and virtual environments seamlessly. Designed to support complex projects and facilitate global tool installations, Rye caters to various needs like monorepos. Installation instructions are available for Linux, macOS, and Windows systems, including downloading the binary or using a curl command. It's recommended to have "Developer Mode" activated on Windows before installation. Rye does not use signed binaries yet, so users may need to allow execution manually. Rust and Cargo need to be installed to use Rye, which can be done via cargo install. For further customization and detailed installation guidance, users can refer to the provided resources.

Related

Binrw

Binrw

The tool binrw simplifies binary parsing and serialization with a declarative approach, offering readability and maintainability. It supports common tasks, generics, custom parsers, predefined types, and is safe for various environments.

First Class Contexts – Rye Language

First Class Contexts – Rye Language

Rye Language introduces first-class contexts for scoping Rye words, creating parent-child relationships. Context paths access values, restricting direct changes for control. Evaluation and isolation mechanisms enhance structured code organization.

Show HN: R2R V2 – A open source RAG engine with prod features

Show HN: R2R V2 – A open source RAG engine with prod features

The R2R GitHub repository offers an open-source RAG answer engine for scalable systems, featuring multimodal support, hybrid search, and a RESTful API. It includes installation guides, a dashboard, and community support. Developers benefit from configurable functionalities and resources for integration. Full documentation is available on the repository for exploration and contribution.

Python Modern Practices

Python Modern Practices

Python development best practices involve using tools like mise or pyenv for multiple versions, latest Python version, pipx for app running. Project tips include src layout, pyproject.toml, virtual environments, Black, flake8, pytest, wheel, type hinting, f-strings, datetime, enum, Named Tuples, data classes, breakpoint(), logging, TOML config for efficiency and maintainability.

Python Has Too Many Package Managers

Python Has Too Many Package Managers

Python's package management ecosystem faces fragmentation issues. PEP 621 introduced pyproject.toml for project configurations, leading to new package managers like Poetry. Conda offers robust dependency management, especially for data science workflows.

Link Icon 71 comments
By @charliermarsh - 5 months
A lot of our core packaging development is now happening in uv [1]. Rye uses uv under the hood, so as we improve uv, Rye gets better too.

E.g., we recently added support for "universal" resolution in uv, so you can generate a locked requirements.txt file with a single resolution that works on all platforms and operating systems (as opposed to _just_ the system you're running on). And Rye supports it too in the latest release.

[1] https://github.com/astral-sh/uv

---

I work on Rye and uv, if you have any questions :)

By @Apreche - 5 months
The thing that put me off of Rye is that it strongly encourages you to use non-standard Python builds.

From their philosophy page: https://rye.astral.sh/philosophy/

> No Python Binary Distributions: CPython builds from python.org are completely inadequate. On some platforms you only get an .msi installer, on some you literally only get tarballs. The various Python distributions that became popular over the years are diverging greatly and cause all kinds of nonsense downstream. This is why this Project uses the indygreg standalone builds. I hope that with time someone will start distributing well maintained and reliable Python builds to replace the mess we are dealing with today.

And here is info about those particular indygreg builds.

https://gregoryszorc.com/docs/python-build-standalone/main/

It is, however, possible to choose a different Python.

https://rye.astral.sh/guide/toolchains/

I've never really experienced the problem they are describing. Any official Python build I've gotten from python.org has worked. Every normal old Python I've gotten from my distribution's package manager has worked. Every Python included with an official Docker container image has worked.

I'm sure their special builds will also work just fine, but their non-standardness gives me pause. There's even a list of behavior quirks. Why are we adding quirks to something that has no problems? And the fact that the rye philosophy seems so intent on using them, turns me off from it compared to the alternatives that sensibly default to using the Python you already have available on your OS.

By @barakm - 5 months
Wow, so many haters :(

I love Rye. It does what it says on the tin. It makes the whole venv/Python-version/packaging process actually pleasant, and it’s invisible to someone used to Python-official usage (pyproject.toml et al). And it makes Python feel like Cargo, which is a great thing to work with too.

By @sali0 - 5 months
The cynicism of HN surprises me sometimes.

I love Rye. After using package managers from other languages like cargo and hex, the lack of a similar system for Python always had me yearning for more. I'm really happy to say Rye has completely solved this itch for me, and its a real pleasure to use as someone who doesn't want to install different tools to manage venvs, python versions and my project's dependencies. Rye just does it all.

By @sghiassy - 5 months
A new python dependency manager is like stumbling across a new JavaScript framework
By @sean_pedersen - 5 months
I like pixi (https://pixi.sh/latest/). Let's me pin python version, install packages from conda and PyPI. And also written in Rust.
By @pen2l - 5 months
Worth noting that the uv folks (https://astral.sh/blog/uv) have taken over reins from this Armin project.
By @galoisscobi - 5 months
On the introduction page:

> Rye is still a very experimental tool, but this guide is here to help you get started.

While I’m really excited about this project, I’m planning on waiting until this project is in a more mature stage. I am a big fan of everything else the Astral team has put out so I have high hopes for this.

By @rattray - 5 months
We use rye to develop the openai-python library and it's been great.
By @jekude - 5 months
Rye looks great (i've also really enjoyed using Poetry as well). But man, do I have respect for Go's quality of out-of-the-box tooling. Feels like every time I start a Python project I need to re-learn the state-of-the-art wrt dependency/venv management.
By @thomasfromcdnjs - 5 months
Oh this is incredible. As a non python developer, I never understood why python projects has a terrible DX. Say what you want about npm/node, but it's super easy to bootstrap a project and to understand what dependencies are required.

Is there a reason why Python has taken this long to get a mature alternative to "requirements.txt"?

By @ggm - 5 months
I would think that making it manage musl/alpine first-class and not require a branch in the road to deal with it, was worth the effort. Things like this make it harder enough that people will do hacky modes of work to get around it.

(I hit similar things with libressl/libcrypt from time-to-time. It is not quite exactly a drop-in replacement world for these things. It's painful enough to make back-porting modern SSL dependent code a royal pain, of destroyed shared lib dependencies)

By @spoonfeeder006 - 5 months
>Alternatively if you don't trust this approach, you can download the latest release binary

Is there a security difference between running a shell script that runs a binary vs running a binary directly? Or downloading a executable from the browser vs downloading a shell script using curl?

I get that running the shell script can subjectively look more scary, but doesn't it just basically reveal the inherent danger of running an exe anyhow, assuming there's no code signing keys involved?

By @xeromal - 5 months
https://news.ycombinator.com/item?id=40905891

* Python has too many package managers *

By @1propionyl - 5 months
Rough edges as they may be, I'm just going to put my chips on Hatch because it works well, the defaults for build/formatting/testing/publication are sane and built on other tools, I can actually read the source code easily enough to PR it (which I have done), and it's under the auspices of the PyPA. In short, it's a good facade.

Also, the CLI tooling doesn't even depend on using Hatchling as a build system, which is an understated benefit.

Unless one's got a particularly weird use case where they actually need to know the ins and outs of PEP 517 (Maturin/PyO3 with system specific dependencies, for example) it is going to be completely fine for the vast majority of packages with minimal additional configuration.

By @DanielKehoe - 5 months
I'm sure experienced Python developers will continue to use the familiar pyenv/venv/pip toolset, or its many variations. However, Rye is better for beginners and developers coming from other languages. First, Rye is an all-in-one tool, written in Rust for speed, with a unified set of commands for setting a Python version and installing packages, with environments created automatically. Second, the tool uses a folder/project approach to development like languages such as JavaScript and Ruby, where a developer sets up a project in a folder and then specifies a language version and dependencies, rather than the old Python approach where packages get installed into a Python version that is shared among projects (unless a virtual environment is created with venv). The Rye documentation is good, still I thought it's good to offer a tutorial for beginners, so I wrote "How to install Python on Mac" [0] and "How to use Rye for Python" [1]. I don't know if Rye will catch on, but it's a breath of fresh air.

[0] https://mac.install.guide/python/install [1] https://mac.install.guide/python/use-rye

By @datadeft - 5 months
The amount of effort that goes into making Python usable is insane.
By @robertlagrant - 5 months
Question about the company Astral: how does it make money? I see it has backers, and a mission, and beliefs, but is there something that's sold?
By @p5a0u9l - 5 months
Here I am and pip+venv+pyproject.toml work just fine. I don’t distribute outside our team, maybe that’s why?
By @jimmcslim - 5 months
If I want to dip a toe in and run Rye and pyenv side-by-side on the same machine (not for the same project obviously)... is that going to be a footgun? I'm assuming... yes, since the shims from both are going to conflict?

Update: looks like this might be supported, from the FAQ...

Can I use Rye Alongside Other Python Installations?

Rye given it's experimental nature does not want to disrupt already existing Python workflows. As such using it alongside other Python installations is intentionally supported. Even if the Rye shims come first on the PATH, Rye will automatically resolve to a different Python installation on the search path when invoked in a folder that contains a non Rye managed project.

As such the answer is a clear yes!

By @prmoustache - 5 months
Just watched the video introduction. I don't mind people preferences regarding keyboard kind, but those noisy mechanical keyboards sounds awful, tiresome and downright aggressive when watching a recording as they stand out and sound a bit like a machine gun in an FPS. I don't need that kind of aggression, especially when it is so loud it is covering the voice of the presenter.

I would appreciate it if people doing videos presentation would switch to quieter keyboard, use directionnal microphones so that only their voice is recorded or edit the sound afterwards to quiet down the keyboard frequencies out of respect to their audience. It is not hard to do.

By @scoresmoke - 5 months
Ruff and uv are both excellent tools, which are developed by a VC-backed company, Astral: https://astral.sh/about. I wonder what their pitch was.
By @est - 5 months
I recommend Rye because of its python bianries (credit to Indygreg). What a time saver!
By @globular-toast - 5 months
I'm not sure about Rye, but I've been experimenting with uv as a replacement for pip-tools and so far I'm impressed. I've been using and contributing to pip-tools for years now but it has a few quirks that I don't like. uv seems to solve them already, and it's way faster.

There's a few bits I don't like in uv, but I intend to submit patches soon.

The one thing I think sets these projects back is the naming. Rye, uv... They just aren't as good names as pip, pip-tools, venv etc. This could make it harder to convince people of their legitimacy. But I could be wrong, maybe they will succeed based on their merits.

A "Cargo for Python" I find a bit misleading. Python is very different to Rust and upon learning Rust I didn't find anything that I hadn't already got in all my Python work. If anything Cargo is just 'the best parts of all packaging software so far, including Python".

By @tamimio - 5 months
It looks interesting; I'll keep an eye on it. Side note: The intro video is great, but the keyboard clicks were annoying.
By @jari_mustonen - 5 months
As a Mac user, I'd be interested if you could add:

* Installation through Homebrew * Plugin for Oh My Zsh!

By @Ennea - 5 months
I have not yet tried Rye, but the installation guide shows me that it's yet another (seemingly new, too) tool that creates yet another folder in the user's home directory (as opposed to ~/.config or ~/.local/share). Why?
By @rtpg - 5 months
Rye has been wonderful for me. Works so nicely and isn't adding too many opinions. Things like poetry tend to really be not amenable to certain workflows, which has likely made many people stick around to `pip -r requirements.txt`.
By @1attice - 5 months
[context: honest question from occasional Python user] What's wrong with poetry?
By @TekMol - 5 months
My world is really simple and I wonder if I am missing anything:

1: I develop and run Python projects in Docker containers.

2: Each Python project has a setup.py.

3: The setup.py installs dependencies from their git repos.

What benefit would I get from using any additional tools?

By @wodenokoto - 5 months
If I'm not building a shared library, what is the benefit of having my project as a package? It seems Rye only supports python packages, but most my stuff never touches PyPI or anything similar.
By @kelvie - 5 months
One that that isn't clear is editor support -- I recently switched to poetry for a few repos at work because it took the pain out of editor setup for my team -- it works with intellij, vscode, and emacs (well, doom emacs made it pretty easy) -- anyone know how well this integrats with e.g. emacs?

A quick search turned up this unanswered question: https://github.com/astral-sh/rye/issues/888

By @prmoustache - 5 months
Presentation shows that if you decide to fix a python-version in a .python-version file, rye sync will not work and complain, and you will have to fetch it manually with `rye fetch <version>`.

I am wondering why the developers chose not to propose to fetch the missing version when doing `rye sync`. I would expect anyone preparing the video tutorial to think "wait, this is stupid, let's fix this asap" instead of showing off potential users how unfriendly the ux is.

By @mark_l_watson - 5 months
I read this thread early this morning and have been trying Rye for the first time over the last several hours. I like it and a few things have helped: 1) add a Makefile targets for auto-creating a requirements.txt file to make my two new projects play well with pip, etc. for people not wanting to use Rye. 2) ChatGPT saved me time setting up VSCode and Emacs for Rye+Python dev.

So far, I love Rye! So fast and no roadblocks yet.

By @verdverm - 5 months
> desire to establish a one-stop-shop for all Python users, Rye provides a unified experience to install and manages Python installations

This seems an impossible task on linux, where yum/apt packages are installed long before any higher-level python tools like poetry or rye. With the continual sprawl of "one tool to rule them all" in Py & Js, I'm thankful for Go being a much more consistent ecosystem.

By @fermigier - 5 months
I'm still using Poetry for dependency management, but that will most probably change someday (hopefully with automated conversion of the pyproject.tml files).

I'm OK with the pythons that are provided my the OS I'm using (including Deadsnakes) so this side of rye doesn't appeal to me. I've started using uv to create virtualenvs, though, so that's probably the gateway drug. We'll see.

By @ericfrederich - 5 months
Why Rust? Aren't you alienating Python devs from working on it?

I see that UV is bragging about being 10-100x faster than pip. In my experience the time spent in dependency resolution is dwarfed by the time making web requests and downloading packages.

Also, this isn't something that runs every time you run a Python script. It's ran once during installation of a Python package.

By @awinter-py - 5 months
their uv tool is incredible -- it is substantially faster than vanilla pip even on a fast laptop, and they were smart to adopt pip-tools commands for pinning

will not go back to pipenv / poetry unless uv does something truly awful to me

I feel more meh about rye, except as a way to use uv for package management

and I don't understand why astral is a company

By @noisy_boy - 5 months
I have a project managed by Poetry - how easy would it be to switch that to use rye? What are the upsides/downsides compared to Poetry?
By @mvelbaum - 5 months
While we're on this topic:

1. Can anyone recommend a good file layout/organization for a polyglot monorepo that contains Python, C++, and JS?

2. Does the build system need to be use something like Buck/Bazel?

3. How do you usually open your project in an IDE? do you open the root of the monorepo, or do you open each subproject separately?

By @1attice - 5 months
Ironic that this just went by as well https://dublog.net/blog/so-many-python-package-managers/
By @JodieBenitez - 4 months
I kinda like that it downloads its own interpreters... could be useful when using pyinstaller to have a more portable interpreter.
By @pnathan - 5 months
conda works really well for local hacking. Whatever it does, it sidesteps almost all the other footguns I have encountered with local pythons.

on the other hand, I've found Go to be meaningfully superior for many things, and Rust to be meaningfully superior for many other things, and Scala excellent for the JVM and I simply can't actually recommend other languages for professional greenfield work outside of exceptionally niche cases.

By @ixxie - 5 months
How experimental is it? Should we use it for production for small app deployments?

We are open to the cutting edge, but it can't be too sharp or rough.

By @maCDzP - 5 months
I read in another thread that people are doing dev in a container. It’s supposed to be awesome.

How does this compare do developing inside a container?

By @chrisjj - 5 months
> The windows installer normally will automatically register the rye path in the PATH environment variable. If this does not work

Why would it not work?

By @Paul-Craft - 5 months
Very interesting! I will definitely try this out.

Out of curiosity though: is there anything like this that exists, but less Python-specific?

By @cbenz - 5 months
ruff, then uv, then rye All of them changed my pythonist everyday life, one after another.

Great thanks to all the team.

By @ris - 5 months
I thought they "really going to get it right this time" N-1 python packaging tools ago.

(happy Nix user)

By @MaximilianEmel - 5 months
Why should I use this over Miniconda?
By @mjfl - 5 months
Hassle isn't really what I think of when I think of Python. C++, yes, but not Python.
By @phgn - 5 months
Could you publish it on Homebrew to make the installation on Mac hassle-free too?
By @riwsky - 5 months
“There should be one, and preferably only one, obvious way to do it—xor it’s packaging”
By @richrichie - 5 months
Pretty cool. Would be nice to have Cython handling.
By @_ZeD_ - 5 months
what do rye offers to a pdm-based project?

https://pdm-project.org/

By @nextaccountic - 5 months
Can Rye work with Conda projects?
By @hallqv - 5 months
How does it differ from Poetry
By @Sparkyte - 5 months
but why?
By @johnisgood - 5 months
Not to be confused with Rye, the programming language: https://ryelang.org
By @jwmoz - 5 months
Confused with uv/rye
By @andrewmcwatters - 5 months
venv, pip, and requirements.txt are just fine.
By @judge2020 - 5 months
Obligatory https://xkcd.com/927 and https://xkcd.com/1987

Probably not actually a large issue here since it uses pyproject.toml which is what Poetry uses and seems to be the standard people are moving to.

By @andrei-akopian - 5 months
By @geenat - 5 months
requirements.txt

daily reminder: you can specify exact commits from git repos.

By @tonymet - 5 months
guys just use matrioshka.py it is your one-stop package management system for python.

just prefix any other package manager with matrioskhka

e.g. python -m matrioskha rye install pip install pipx setup.py install

A single distribution command for all of your projects.

By @Drygord - 5 months
Instead of creating solutions to problems we create…

Why don’t we just stop creating those problems =p

By @ranyml - 5 months
Why is the installation binary? Conda pulls the same shenanigans, which I hate. Why should I trust a self-extracting shell archive?

I only install Conda on untrusted machines.

By @hdhshdhshdjd - 5 months
$ nano thing.py

$ python3 thing.py

Don’t see the hassle there.

By @bmitc - 5 months
I wish people would just stop using Python for large projects. It's such a terrible language and ecosystem with a huge surface area of gotchas.
By @bongodongobob - 5 months
Who needs it. I install everything globally and then when some dependency fucks it all up I just reinstall the OS. Been meaning to learn the venv thing but I've been doing this for years and there's no turning back now. My workflow works for me.