![](https://files.mastodon.social/accounts/avatars/109/245/682/115/185/687/original/67c8da8c12656fe7.png)
2024-04-26 18:00:49
No, #Python, this really is a gotcha, and a stupid one at that.
https://docs.python-guide.org/writing/gotchas/#mutable-default-arguments
Whow, #Python leads the current Tiobe Index by a wide margin: https://python-basics-tutorial.readthedocs.io/en/latest/intro.html
Missing: a :python: #Python package to make flowcharts with #pythonRich, i.e. to draw arrows between (auto-arranged) renderables.
https://g…
El gran problema de #python es el puto indentado. Si llegas a combinar tabulación y espacios todo se vuelve un caos 😫
I've added `dev-python/legacy-cgi` to #Gentoo, as a "forward-port" of the removed #Python `cgi` (and `cgitb`) module to Python 3.13. That said, it's only a stop-gap solution to make semi-dead packages work and not something you should rely on, so it's marked as deprecated immediately after being added.
Also, ideally please avoid keeping it installed in your dev environments. Once installed, all `import cgi` statements will suddenly start working, so you're going to miss Python 3.13 incompatibility issues (and therefore miss the dependency on this package).
Video tutorials for modern ideas and open source tools. #python
Why should folks doing #Development use test-driven development?
I wrote a #Python utility to help me collect and manage systems from a variety of platforms. Originally it started as a one-off so I wasn't concerned about tests, but the code continued to grow as …
Technically, a large part of what amounts to #Gentoo #Python 3.13 porting could be automated. In fact, we already have most of the pieces — tooling to find next candidates, update PYTHON_COMPAT, run tests. Why do I do it semi-manually then?
Well, for a start it gives me an opportunity to look into the ebuilds. Look for old issues, improve code, sometimes discover we ought to have removed something a long time ago. At the same time, looking at build logs also sometimes makes me notice incorrectly working tests (particularly, tests not failing correctly on failure).
Not to mention it gives me a bit of purpose when the damn fever prevents me from doing anything requiring more focus.
Teaching #Python folks the joys of clear and explicit object type definitions. An interesting experience...
#Programming
Ah, things I found interesting...
- Figuring out if there are `NaN` numbers in a Python list: `any(i != i for i in float_list)`.
- Replacing single newlines while ignoring double newlines: `"\n\n".join([i.replace("\n", ' ') for i in cool_string.split("\n\n")])`
#python
🧮 50x faster conda environment solving with "sharded" repodata
(… nice to see that Python packaging systems are finally discovering that cache matters!)
https://prefix.dev/blog/sharded_repodata
Come for wisdom on tox & Nox – stay for unrelated gems that will improve your life! #python #video
https://youtu.be/ImBvrDvK-1U
If anyone is still wondering whether #setuptools is a good #PEP517 build system, let me point out that right now it vendors… (checks notes) 12 packages, including two different versions of more-itertools.
Of these packages, 5 use setuptools and 1 uses hatchling. Ironically, it's the packages maintained by setuptools upstream that use the former and therefore introduce cyclic dependencies. Third parties seem to be more concerned that their packages are used by setuptools and therefore should use minimal build systems to avoid the cyclic dependency problem.
In other news, setuptools finally acknowledged the cyclic bootstrap problem with `wheel`, and started vendoring it.
#Gentoo #Python
I think I have finally™️ (for the third or so time) found myself a solution for :python: #Python development on :nixos: #NixOS that allows me to just work with #pythonPoetry et. al. as on other distros.
…BeeTeeDubs, I'm going live in ten with a #LiveCoding #Python Tutorial drawing flags with turtle graphics.
Really it's about abstraction and decomposition.
#ComputerScience
#Python
As I'm working on my #networking diagnostic script which relies on my OS abstraction layer for system information I built a number of years back, I decided it would make more sense to formally port this API up to pypi as a standalone library. (It doesn…
These is one of these days when it occurs to you: "hey, packages using #Python and #RustLang, may have *both* Python and Cargo-level tests." And then you spend a lot of time going over all Rust-enabled dev-python/* packages and adding `cargo_src_test` where appropriate.
As it turns out, many of them did. Most of these don't actually link to libpython, so I suppose it's fine to test them once. Pydantic-core does, so I test per-impl (but also can't test on PyPy). Cryptography has Rust-level tests that don't even build (they fail at linking).
#Gentoo
I'm close to having @… sorted out. With a new API comes slightly different data points. #python
Time for your daily dose of #RustLang complaints. Yep, the ecosystem is doing great.
#UV depends on tokio-tar library. Tokio-tar is broken on #PowerPC, doesn't have a bug tracker (!) and seems to be quite dead, with a bunch of PRs ignored since 2022 (last activity mid-2023). Nevertheless, I've filed a PR to fix PowerPC, with little hope that it'll be merged, released and that we could get UV working on PowerPC.
On top of that, it seems that tokio-tar was forked in early 2021 from async-tar. It doesn't seem to have synced the few commits from 2021, and async-tar is dead since late 2021. But at least it has a bug tracker to keep track of how dead it is.
Rewriting stuff in Rust is great. Maintaining it afterwards for the sake of reverse dependencies isn't.
#Gentoo #Python
Hübscher Kommentar im #Quellcode:
# Erstelle eine schöne XML-Struktur
#python 🤪
Made it safely to #PyDataLondon tutorials! Now attending Adam Hill's one on #Prefect #python #pydata
Hrmm, this might be a slight issue...pretty sure the map shouldn't be "generic white box"... #python
One more thing about porting #Gentoo packages to a new #Python version is that every time you discover how many *new* packages are now abandoned and broken. However, the rate at which packages are abandoned is not what's most the most terrifying thing — it's how many other packages still use these packages, years after the last commit, years after distro developers had to start patching them to have them work at all.
I'm talking of clint (2015), I'm talking of passlib (2020, though author reappeared recently), WebOb (2021), Genshi (2022). I'm talking of Bottle whose author doesn't seem to be able to accept `cgi` removal from stdlib. I'm talking of Aesara that used to be a fork of Theano, and that apparently has been forked again. I'm talking of HttpBin that was abandoned in 2018, then revived by PSF, but it's far from being well-maintained right now.
The world has moved on, apparently.
My final act before vacation is done: structlog 24.2.0! #Python
Enjoy a bunch of bug fixes, better Logfmt support, and some optimizations!
https://github.com/hynek/structlog/rel
I'm close to having @… sorted out. With a new API comes slightly different data points. #python
Can one pre-build a buildFHSUserEnv in configuration.nix and then have a command like 'fhs' that yanks you into a shell with all your environment.systemPackages in an FHS layout?
All my tries have given me either infinite recursion errors or other problems.
Seems like a way out of the #Python development misery on
Essentially, distro developers are firefighters, putting out fires made by careless upstreams.
What I've wasted time on, today:
- making the non-standalone test suite of #Hatchling (sigh) work without #UV again, so that a critical build dependency of a growing number of #Python packages could be tested everywhere
#PassLib not to break random stuff via printing warnings when using newer #BCrypt versions
#ImageIO work using an offline copy of test data, rather than cloning its git repository at the beginning of tests
#Gentoo
Went ahead and posted the code for the NWS weather stuff to GitHub for ya @… however I'm not vouching for its quality. #python #programming
Alright, I've got the maps being generated and shared via a quick `python -m http.server` command and being fronted by my `nginx` server. Everything looks good from outside the network. Now we wait for the next watch/warning to pop. #programming #python
Can one pre-build a buildFHSUserEnv in configuration.nix and then have a command like 'fhs' that yanks you into a shell with all your environment.systemPackages in an FHS layout?
All my tries have given me either infinite recursion errors or other problems.
Seems like a way out of the #Python development misery on
@… Every time you run the script, it gets the JSON feed from the Kopp’s website, builds a collection in a #ChromaDB vector database, populates it with what today is, what today’s flavor is, and what tomorrow’s flavor is, and then uses that for the embedding. I wasn’t expecting to need to tell it what today’s date is.
#Ollama #Python
What would cause :git: #git to shell out at 'git -C repo fetch --all'?
I call git via #Python's subprocess module (no, not with shell=True) and it apparently shells out to my default :fish_shell: #fishShell
What I could do: Continue working on my flat so that I might eventually have a desk again, with luxuries such as an external screen or an actual keyboard.
What I am doing: Being hunched over my laptop, abusing #Python with the little knowledge I can gather from the back of my brain to write a small application to share my vast collection of reaction
For a project that's supposed to avoid the vices of C, #CPython sure crashes a lot.
This time I was bisecting a regression in 3.13.0b2 that causes the interpreter crash when `freezegun` is imported. And no, not because freezegun was doing something hacky. Just some crazy internal extension state thingy.
#Gentoo #Python
# !/usr/bin/env python3
# small_universe_test.py
import pandas as pd
const lightyear = 9461000000000000
const size = 930000000000 * lightyear # 8798730000000000000000000000
# largest number on some registers is 9223372036854775807 or 18446744073709551615
universe = sphere(radius=size,x=0,y=0,z=0,t=0)
pd.Series(universe, filling_function)
pd.Plot()
#cosmology #astrophysics #python
#CPython 3.13 has some new fun flags for #Gentoo ricers.
USE=jit − enable to get Just-in-Time compiler and make stuff faster. Note that you're also going to see random segfaults, etc.
USE=gil − disable to get rid of Global Interpreter Lock and get a freethreading #Python. Expect some random breakage, race conditions, etc.
I just scheduled two @… Open Space sessions. If you are interested in AI and RAG, I am going to be presenting "Crafting Intelligent Python Apps with Retrieval-Augmented Generation" on May 31 and June 28 (in case you can't make the first date).
#ThatConference #AI #LLM #RAG #Python
#UV is truly the future of #Python packaging.
Except that its test suite relies on specific version of random packages happening to be the newest in #PyPI (and some other random third-party package index) at any given time. Which means that the test suite already fails *a few hours* after a release.
Oh, and upstream does drive-by updates to these broken assumptions while making other changes.
So… how are we supposed to mark any version stable in #Gentoo if we can't even hope for any single version to pass tests for a few days?
Also, that test is actually meaningless now, due to test assumptions no longer matching.
#RustLang
Making progress on the push notifications. Targeting Discord at the moment, but I think that the maps really help out with the information. Not satisfied with the formatting, but I'm not sure how much I want to dedicate to it. #programming #python
#UV is truly the future of #Python packaging.
Except that its test suite relies on specific version of random packages happening to be the newest in #PyPI (and some other random third-party package index) at any given time. Which means that the test suite already fails *a few hours* after a release.
Oh, and upstream does drive-by updates to these broken assumptions while making other changes.
So… how are we supposed to mark any version stable in #Gentoo if we can't even hope for any single version to pass tests for a few days?
Also, that test is actually meaningless now, due to test assumptions no longer matching.
#RustLang
How about tests that fail in a completely nondescript way if your hostname is 12 characters long? I mean, the bash prompt gets into output and breaks matching in one environment, and doesn't in an environment with a shorter hostname.
As it turns out, it was caused by putting a wrong path to bashrc override while adding zsh support to #ArgComplete. I guess most people didn't get a long enough bash prompt to hit the failure.
#Gentoo #Python
Okay, after a few hours of troubleshooting I've got the county and warning polygons rendering correctly. So much profanity, but it works. Aspect ratio and zoom levels also seem to work. Next up: linking the messages with the images. #programming #python
In the past, many NumPy-based projects built their wheels against `oldest-supported-numpy` package to ensure the best ABI compatibility between multiple #NumPy versions.
Then NumPy 2 came and reversed that — now you need to build against NumPy 2 rather than 1.x, to gain ABI compatibility with both versions.
That said, if you want to maintain support for #Python 3.8, then you have to hack even more:
#Gentoo
Please don't use #Mercurial. It's not well-maintained software.
People like to point out that Mercurial works great for a few BigTech corporations. That's great for them. The side effect is that the development is focused on these corporations, and if you find a bug that doesn't affect them, you better be ready to provide a fix yourself.
#Python 3. The first release with Python 3 was made *two months* before Python 2 went EOL.
#RustLang. Funny thing is, Mercurial with Rust extensions enabled still doesn't work on Python 3.12. Apparently, they've chosen to use some NIH Python/Rust bridge rather than PyO3.
#Gentoo
Here's my newest optimization idea for #Gentoo #Python: for pure Python packages and packages using the stable #CPython API, let's reuse previously built wheels if they're compatible instead of building them separately for each Python implementation.
This is mostly a major gain for the lot of packages using #setuptools when you're using multiple PYTHON_TARGETS, since calling into that build system has a significant cost. However, it also saves some actual compiling in the packages using the stable API (particularly, Rust packages).
https://github.com/gentoo/gentoo/pull/36672
https://bugs.gentoo.org/931689
It took me almost 3 hours but #PipX 1.6.0 is now in #Gentoo, with an updated test shim that makes it possible to test using fake wheels and is only 70 KiB (vs. upstream that uses ~160 MiB for every single implementation).
What's more important, this time it isn't a handmade proof-of-concept anymore but a proper script with instructions that can be used to easily deal with future releases.
#Python
I’m rewriting @… to use a new API (because the old one doesn't work right anymore), rewriting it to be in #Python instead of #Node, and moving it from #Pipedream to a local #Docker container on my homelab machine.
You can probably expect a few articles on @… about this.
#Homelab #Linux #Networking
So if you are looking for a #Python
You know what's great about #Python stable ABI? That you can take a binary package of, say, cryptography, and it will work on CPython 3.13, even though it's been built with older CPython version.
You know what's not so great about #PyO3? That you won't be able to build this package using Python 3.13 because it's going to reject it as "too new". Even if the package in question is only using the stable ABI compatible with CPython 3.9. Sigh.
So, of course, everything on #Gentoo will be blocked, until individual packages update their dependencies to use PyO3 new enough to support 3.13.
#RustLang
So I'm bumping a package and the test suite fails with suspicious timestamp-related failures. So I do the obvious thing, and set TZ=UTC. It still fails. I do a quick math, and the timestamp difference looks weird — 8 hours.
I clone the repo to try to reproduce the problem. While that, I check how upstream runs tests and notice a comment:
# system should be in "America/Los_Angeles" timezone for all tests to pass
Well, okay. Then I make a bet that kloczek has already filed a bug about tests passing without actually bothering to try to figure it out. Of course he did:
#Python #Gentoo #PLD
Does #setuptools maintainer think it is a good idea to use setuptools as a #PEP517 build system?
Yep, he probably does. And to prove it, he installs `docs` straight into `site-packages`.
#Gentoo #Python
The most recent #Django releases, 5.0.5 and 4.2.12 are broken. Most likely they were done on #Windows, and that obviously is sufficient to break stuff.
[UPDATE: 5.0.6 and 4.2.13 are good. Thanks a lot!]
So far, we've noticed the following issues:
1. The directory is named lowercase `django-X.Y.Z` instead of capital-case `Django-X.Y.Z` (the filename remains capital-case).
2. All files have CRLF line endings instead of LF.
3. All files that should have the executable bit, have lost it.
As a result, the releases don't pass their own tests.
I hope to report this upstream, but their Trac is down now. So you can't even download the releases right now.
#Gentoo #Python