1
0
mirror of https://github.com/balkian/balkian.github.com.git synced 2025-09-15 22:32:20 +00:00

4 Commits

Author SHA1 Message Date
J. Fernando Sánchez
746dc01428 add uv to python cheatsheet 2025-02-18 00:23:22 +01:00
J. Fernando Sánchez
2c7eb133a9 post about uv 2025-02-18 00:20:50 +01:00
J. Fernando Sánchez
50b6c6995e fix minor hierarchy mistake 2025-02-14 14:21:47 +01:00
J. Fernando Sánchez
ede9c79ad2 Changed README 2025-02-14 14:11:54 +01:00
12 changed files with 139 additions and 69 deletions

View File

@@ -1,69 +1,4 @@
<img align="right" width="150" alt="logo" src="https://user-images.githubusercontent.com/5889006/190859553-5b229b4f-c476-4cbd-928f-890f5265ca4c.png">
My personal website.
# Hugo Theme Stack Starter Template
This is a quick start template for [Hugo theme Stack](https://github.com/CaiJimmy/hugo-theme-stack). It uses [Hugo modules](https://gohugo.io/hugo-modules/) feature to load the theme.
It comes with a basic theme structure and configuration. GitHub action has been set up to deploy the theme to a public GitHub page automatically. Also, there's a cron job to update the theme automatically everyday.
## Get started
1. Click *Use this template*, and create your repository as `<username>.github.io` on GitHub.
![Step 1](https://user-images.githubusercontent.com/5889006/156916624-20b2a784-f3a9-4718-aa5f-ce2a436b241f.png)
2. Once the repository is created, create a GitHub codespace associated with it.
![Create codespace](https://user-images.githubusercontent.com/5889006/156916672-43b7b6e9-4ffb-4704-b4ba-d5ca40ffcae7.png)
3. And voila! You're ready to go. The codespace has been configured with the latest version of Hugo extended, just run `hugo server` in the terminal and see your new site in action.
4. Check `config` folder for the configuration files. You can edit them to suit your needs. Make sure to update the `baseurl` property in `config/_default/config.toml` to your site's URL.
5. Open Settings -> Pages. Change the build branch from `master` to `gh-pages`.
![Build](https://github.com/namanh11611/hugo-theme-stack-starter/assets/16586200/12c763cd-bead-4923-b610-8788f388fcb5)
6. Once you're done editing the site, just commit it and push it. GitHub action will deploy the site automatically to GitHub page asociated with the repository.
![GitHub action](https://user-images.githubusercontent.com/5889006/156916881-90b8bb9b-1925-4e60-9d7a-8026cda729bf.png)
---
In case you don't want to use GitHub codespace, you can also run this template in your local machine. **You need to install Git, Go and Hugo extended locally.**
## Update theme manually
Run:
```bash
hugo mod get -u github.com/CaiJimmy/hugo-theme-stack/v3
hugo mod tidy
```
> This starter template has been configured with `v3` version of theme. Due to the limitation of Go module, once the `v4` or up version of theme is released, you need to update the theme manually. (Modifying `config/module.toml` file)
## Deploy to another static page hostings
If you want to build this site using another static page hosting, you need to make sure they have Go installed in the machine.
<details>
<summary>Vercel</summary>
You need to overwrite build command to install manually Go:
```
amazon-linux-extras install golang1.11 && hugo --gc --minify
```
![](https://user-images.githubusercontent.com/5889006/156917172-01e4d418-3469-4ffb-97e4-a905d28b8424.png)
If you are using Node.js 20, you need to overwrite the install command to install manually Go:
```
dnf install -y golang
```
![image](https://github.com/zhi-yi-huang/hugo-theme-stack-starter/assets/83860323/777c1109-dfc8-4893-9db7-1305ec027cf5)
Make sure also to specify Hugo version in the environment variable `HUGO_VERSION` (Use the latest version of Hugo extended):
![Environment variable](https://user-images.githubusercontent.com/5889006/156917212-afb7c70d-ab85-480f-8288-b15781a462c0.png)
</details>
As of 2025, it is buitl with Hugo and [Hugo theme Stack](https://github.com/CaiJimmy/hugo-theme-stack).
Based on [Hugo Theme Stack Starter](https://github.com/CaiJimmy/hugo-theme-stack-starter/).

View File

@@ -1,6 +1,7 @@
---
title: Emacs
description: Configuration files and tricks for emacs
image: "img/emacs.png"
tags:
- emacs
- org

View File

@@ -2,6 +2,7 @@
title: Linux
author: "Fernando Sánchez"
description: Tips and tricks for GNU/Linux and Unix
image: "img/linux.png"
categories:
- linux
tags:

View File

@@ -1,6 +1,7 @@
---
title: Python
description: Tips and useful libraries for python developers
image: "img/python.png"
categories:
- programming
tags:
@@ -19,3 +20,19 @@ From tqdm's github repository:
![TQDM in action](https://raw.githubusercontent.com/tqdm/tqdm/master/images/tqdm.gif)
## Tools
### [uv](https://github.com/astral-sh/uv)
🚀 A single tool to replace pip, pip-tools, pipx, poetry, pyenv, twine, virtualenv, and more.
⚡️ 10-100x faster than pip.
* Provides comprehensive project management, with a universal lockfile.
* Runs scripts, with support for inline dependency metadata.
* Installs and manages Python versions.
* Runs and installs tools published as Python packages.
* Includes a pip-compatible interface for a performance boost with a familiar CLI.
* Supports Cargo-style workspaces for scalable projects.
* Disk-space efficient, with a global cache for dependency deduplication.
* Installable without Rust or Python via curl or pip.
* Supports macOS, Linux, and Windows.

View File

@@ -1,6 +1,7 @@
---
title: Raspberry Pi
description: Tools, links and configuration for your Raspberry Pi
image: img/rpi.png
tags:
- rpi
---

View File

@@ -54,7 +54,7 @@ Try it with:
uwsgi --socket 127.0.0.1:8888 -w wsgi:application
```
### Extra: Supervisor
## Extra: Supervisor
If everything went as expected, you can wrap your command in a
supervisor config file and let it handle the server for you.

115
content/post/2025-uv.md Normal file
View File

@@ -0,0 +1,115 @@
---
title: "uv - One rust tool to rule all pythons"
description:
date: 2025-02-17T23:02:47+01:00
image:
math:
license:
hidden: false
draft: false
image: img/uv.png
categories:
- Programming
tags:
- python
---
Long story short: I'm now using [uv](https://github.com/astral-sh/uv), and so should you.
It is a great replacement for pip, pip-tools, pipx, poetry, pyenv, twine, virtualenv, and more.
<!--more-->
## Context
For years, my strategy to manage python projects has been a mix of a custom `setup.py`, several hand-crafted `requirements.txt` files (through `pip freeze`), a custom virtualenv per project, and multiple tools to upload to PyPI.
Although this works, this setup has many drawbacks:
- It requires user intervention (creating a venv, sourcing it, handling new deps). This isn't ideal if you want new (probably inexperienced) users to use your projects.
- On a similar note, the whole process needs to be well documented if you want other users to contribute or maintain the code.
- Pinning dependency versions is finicky, and I've run into problems beause of that.
- Creating a new project involves a template, or copying files from an older project.
Of course, this is nothing new.
There is a whole site dedicated to [packaging your Python project](https://packaging.python.org/en/latest/).
A plethora of different projects have come and go, with varying degrees of success.
## Alternatives (poetry)
About a year before trying `uv`, I tried to catch up with the ecosystem and get to know the `blessed new way`.
However, the task proved to be a little more difficult, as the landscape is filled with a myriad of alternatives, each with their own set of drawbacks and detractors.
Packaging has historically been a weak spot, in ironical contradiction to the Zen of Python's "There should be one-- and preferably only one --obvious way to do it",
I eventually settled on [poetry](https://python-poetry.org/).
Mostly because it seemed like the most popular alternative.
There are many things I liked about it.
First of all, having a convention for dependencies (`pyproject.toml`) and a tool that properly handles them was nice.
It also removed the need to remember specific incantations to build and publish my Python projects.
Lastly, I mixed it `poetry2nix` to create reproducible python environments using nix.
This makes for a very powerful experience.
However, there were multiple hiccups.
First of all, it took me some time to figure out which specific fields to use (each tool can define ad-hoc properties in a the `pyproject.toml` file), and some of them seemed redundant with the more generic ones.
Full disclosure, this specific point might be a mistake on my side, and I do not remember the details.
The second one is speed.
(Re-)creating an environment took a non-negligible amount of time.
## Enter ~light~ `uv`
According to its repository, `uv `can replace pip, pip-tools, pipx, poetry, pyenv, twine, virtualenv, and more.
Not only that, but it also claims to do that 10-100 times faster than pip.
I must admit that it being written in rust was a another selling point for me, as I'm looking for excuses to collaborate in a decently-sized rust projejct.
Installing it is dead simple: simply download the binary (e.g., with curl) or run `pip install uv`.
You won't need much more: `uv` seems to just do the right thing out of the box.
And it does it really, really fast.
The rest of the time it gets out of the way.
My only gripe so far is that I don't seem to find a built-in command to drop into a shell, but that is nothing that `uv run $SHELL` cannot fix.
## Common operations
### Initialize a repository
```
uv init
```
### Adding dependencies
```
uv add senpy
```
### Running commands inside the environment
```
uv run <COMMAND>
# e.g., run a shell using your python version and dependencies
uv run $SHELL
```
### Dependency tree
```
uv shell
Resolved 44 packages in 1ms
my-project v0.1.0
├── fastapi[standard] v0.115.8
│ ├── pydantic v2.10.6
│ │ ├── annotated-types v0.7.0
│ │ ├── pydantic-core v2.27.2
│ │ │ └── typing-extensions v4.12.2
│ │ └── typing-extensions v4.12.2
│ ├── starlette v0.45.3
│ │ └── anyio v4.8.0
│ │ ├── exceptiongroup v1.2.2
│ │ ├── idna v3.10
│ │ ├── sniffio v1.3.1
│ │ └── typing-extensions v4.12.2
│ ├── typing-extensions v4.12.2
│ ├── email-validator v2.2.0 (extra: standard)
│ │ ├── dnspython v2.7.0
...
```

BIN
static/img/emacs.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

BIN
static/img/linux.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

BIN
static/img/python.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

BIN
static/img/rpi.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

BIN
static/img/uv.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB