We're sunsetting PodQuest on 2025-07-28. Thank you for your support!
Export Podcast Subscriptions
cover of episode #427 Rise of the Python Lord

#427 Rise of the Python Lord

2025/4/7
logo of podcast Python Bytes

Python Bytes

AI Deep Dive AI Chapters Transcript
People
B
Brian
Python 开发者和播客主持人,专注于测试和软件开发教育。
M
Michael
帮助医生和高收入专业人士管理财务的金融教育者和播客主持人。
Topics
Michael: 我介绍了 Git Town,这是一个用于管理 Git 工作流程的工具。它提供了一组高级命令,简化了创建、同步、切换和合并分支等常见任务。Git Town 解决了在使用 Git CLI 或大多数 GUI 时缺乏内置工作流程的问题,使团队协作更加高效。我分享了 Git Town 的基本和高级命令,并强调了它在处理边缘情况时的优势。我建议观看 Git Town 的七分钟视频以了解更多信息。我还讨论了在 Windows 系统上使用 Git Town 的可能性。 Michael: 我还介绍了两个 Git 工具:git-who 和 watchgha。git-who 用于识别代码库中各个组件或子系统的负责人,这与逐行显示代码作者的 git blame 不同。watchgha 实时显示 GitHub Actions 的运行状态,方便开发者监控 CI/CD 流程。 Michael: 最后,我分享了关于 pysqlscribe v0.5.0 的更新,它现在支持解析创建脚本来自动识别数据库结构。我还讨论了使用 mdformat 格式化 Markdown 文件的经验,并介绍了一个方便的命令行参数组合:`mdformat --number --wrap no`。最后,我总结了使用 uv 工具安装多个依赖项的方法,以及一个用户提供的使用 uv 管理多个 Python 版本虚拟环境的技巧。 Brian: 我讨论了 PEP 751,这是一个新的 Python 依赖项锁文件标准。它解决了不同工具使用不同锁文件格式的问题,提高了安装的可重复性。PEP 751 使用 TOML 格式,并包含了版本、哈希值和上传时间等信息,方便开发者管理依赖项。我提到了一些工具,例如 mouse bender,已经开始支持 PEP 751。 Brian: 我还介绍了 Dave Johnson 的一篇关于使用 uv 工具和 PEP 723 部署 Python 脚本的文章。这篇文章详细介绍了如何使用 uv 添加依赖项、运行脚本以及在不同操作系统上的部署方法。文章还解释了 uv 与其他工具(如 pipx)之间的关系,并提供了一些 Windows 系统上的实用技巧。

Deep Dive

Shownotes Transcript

Topics covered in this episode:

- [**Git Town**](https://www.git-town.com/?featured_on=pythonbytes)) solves the problem that using the Git CLI correctly

Watch on YouTube)

About the show

Sponsored by Posit Package Manager: pythonbytes.fm/ppm)

Connect with the hosts

Join us on YouTube at pythonbytes.fm/live) to be part of the audience. Usually Monday at 10am PT. Older video versions available there too.

Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list), we'll never share it.

Michael #1: Git Town) solves the problem that using the Git CLI correctly

  • Git Town is a reusable implementation of Git workflows for common usage scenarios like contributing to a centralized code repository on platforms like GitHub, GitLab, or Gitea.

  • Think of Git Town as your Bash scripts for Git, but fully engineered with rock-solid support for many use cases, edge cases, and error conditions.

  • Keep using Git the way you do now, but with extra commands to create various branch types, keep them in sync, compress, review, and ship them efficiently.

  • Basic workflow)

  • Commands to create, work on, and ship features.

  • git town hack) - create a new feature branch

  • git town sync) - update the current branch with all ongoing changes

  • git town switch) - switch between branches visually

  • git town propose) - propose to ship a branch

  • git town ship) - deliver a completed feature branch

  • Additional workflow commands)

  • Commands to deal with edge cases.

  • git town delete) - delete a feature branch

  • git town rename) - rename a branch

  • git town repo) - view the Git repository in the browser

Brian #2: PEP 751 – A file format to record Python dependencies for installation reproducibility )

  • Accepted

  • From Brett Cannon)

  • “PEP 751 has been accepted!

  • This means Python now has a lock file standard that can act as an export target for tools that can create some sort of lock file. And for some tools the format can act as their primary lock file format as well instead of some proprietary format.”

  • File name: pylock.toml or at least something that starts with pylock and ends with .toml

  • It’s exciting to see the start of a standardized lock file

Michael #3: git-who) and watchgha)

  • git-who is a command-line tool for answering that eternal question: Who wrote this code?!

  • Unlike git blame, which can tell you who wrote a line of code, git-who tells you the people responsible for entire components or subsystems in a codebase.

  • You can think of git-who sort of like git blame but for file trees rather than individual files.

And watchgha) - Live display of current GitHub action runs by Ned Batchelder

Brian #4: Share Python Scripts Like a Pro: uv and PEP 723 for Easy Deployment)

  • Dave Johnson

  • Nice full tutorial discussing single file Python scripts using uv with external dependencies

  • Starting with a script with dependencies.

  • Using uv add --script [HTML_REMOVED] [HTML_REMOVED] to add a /// script block to the top

  • Using uv run

  • Adding #!/usr/bin/env -S uv run --script shebang

  • Even some Windows advice

Extras

Brian:

  • April 1 pranks done well

  • BREAKING: Guido van Rossum Returns as Python’s BDFL)

  • including

  • Brett Cannon noted as “Famous Python Quotationist”

  • Guido taking credit for “I came for the language but I stayed for the community”

  • which was from Brett

  • then Brett’s title of “Famous Python Quotationist” is crossed out.

  • Barry Warsaw asking Guido about releasing Python 2.8

  • Barry is the FLUFL, “Friendly Language Uncle For Life “

  • Mariatta can’t get Guido to respond in chat until she addresses him as “my lord”.

  • “… becoming one with whitespace.”

  • “Indentation is Enlightenment”

  • Upcoming new keyword: maybe

  • Like “if” but more Pythonic

  • as in Maybe: print("Python The Documentary - Coming This Summer!")

  • I’m really hoping there is a documentary

  • April 1 pranks done poorly

  • Note: pytest-repeat works fine with Python 3.14, and never had any problems

  • If you have to explain the joke, maybe it’s not funny.

  • The explanation

  • pi, an irrational number, as in it cannot be expressed by a ratio of two integers, starts with 3.14159 and then keeps going, and never repeats.

  • Python 3.14 is in alpha and people could be testing with it for packages

  • Test & Code is doing a series on pytest plugins

  • pytest-repeat is a pytest plugin, and it happened to not have any tests for 3.14 yet.

  • Now the “joke”.

  • I pretended that I had tried pytest-repeat with Python 3.14 and it didn’t work.

  • Test & Code: Python 3.14 won't repeat with pytest-repeat)

  • Thus, Python 3.14 won’t repeat.

  • Also I mentioned that there was no “rational” explanation.

  • And pi is an irrational number.

Michael:

  • pysqlscribe v0.5.0) has the “parse create scripts” feature I suggested!

  • Markdown follow up

  • Prettier to format Markdown via Hugo)

  • Been using mdformat on some upcoming projects including the almost done Talk Python in Production book). Command I like is mdformat --number --wrap no ./

  • uv tool install --with is indeed the pipx inject equivalent, but requires multiple --with's:

  • pipx inject mdformat mdformat-gfm mdformat-frontmatter mdformat-footnote mdformat-gfm-alerts

  • uv tool install mdformat --with mdformat-gfm --with mdformat-frontmatter --with mdformat-footnote --with mdformat-gfm-alerts

  • uv follow up

  • From James Falcon

  • As a fellow uv enthusiast, I was still holding out for a use case that uv hasn't solved. However, after last week's episode, you guys finally convinced me to switch over fully, so I figured I'd explain the use case and how I'm working around uv's limitations.

  • I maintain a python library supported across multiple python versions and occasionally need to deal with bugs specific to a python version. Because of that, I have multiple virtualenvs for one project. E.g., mylib38 (for python 3.8), mylib313 (for python 3.13), etc. I don't want a bunch of .venv directories littering my project dir.

  • For this, pyenv was fantastic. You could create the venv with pyenv virtualenv 3.13.2 mylib313, then either activate the venv with pyenv activate mylib313 and create a .python-version file containing mylib313 so I never had to manually activate the env I want to use by default on that project.

  • uv doesn't have a great solution for this use case, but I switched to a workflow that works well enough for me:

  • Define my own central location for venvs. For me that's ~/v

  • Create venvs with something like uv venv --python 3.13 ~/v/mylib313

  • Add a simple function to my bashrc:

  • ``workon() { source ~/v/$1/bin/activate } ` so now I can run \workon mylib313orworkon mylib38when I need to work in a specific environment. uv's.python-version` support works much differently than pyenv's, and that lack of support is my biggest frustration with this approach, but I am willing to live without it.

  • Do you Firefox but not Zen? You can now) make pure Firefox more like Zen’s / Arc’s layout.

Joke: So here it will stay)