direnv with python

What is direnv direnv is a tool that allows you to change your environment based on the configuration in that folder. e.g. You can set different environment variables for different folders. The reason I revisited direnv is because for python project, we need to switch to different virtual environment each time we change a project. Wouldn’t it be nice if correct virtual environment was activated when you change to that directory

Continue Reading »

Django: Create new project in an existing folder

Default command for creating a new project is : django-admin startproject my_new_project Django will then create a folder called my_new_project (if it does not exist) But if folder my_new_project exists (even if empty) we get error like : CommandError: '/path/to/my_new_project' already exists The way around is to specify a folder name after the project name like django-admin startproject my_new_project existing_folder See the documentation for details.

UV: Superfast pip replacement written in Rust

It is (almost) drop-in replacement for pip. We just need to invoke it as uv pip instead of pip How to install ? pipx install uv : This makes it available everywhere. Other alternatives are curl (recommended) and brew (on macOS) It is superfast I tried installing Django $ uv pip install Django Resolved 3 packages in 138ms Downloaded 3 packages in 2.53s Installed 3 packages in 228ms + asgiref==3.8.1 + django==5.

Continue Reading »

Used Python After Long Time

Today I wrote (OK, copy/pasted sample code and modified) python after more than a year. (Is it a year or an year - confusing. I think either works) I had to start from installing python. Why did I use python ? At work, we are trying to connect to Azure Service Bus over AMQP. Ruby is not officially supported by MS anymore. Python is. But we wanted to try non-azure client.

Continue Reading »

Bundler

If I were to explain bundler to pythonista (like myself) I would say Bundler in Ruby land is like poetry in python land, except it does not create sandbox environment To explain it a little more. It tracks dependencies in a Gemfile (and Gemfile.lock) which then goes in your repo. Other engineers sharing your code would then run bundle install, and they get exact same Gems (including versions) on their machines.

Continue Reading »