2024-02-09 06:09:12
Until last week I supervised a weekly online lecture on :python: #Python for #engineering at @…
Now I am thinking on continuing this as a public Q&…
Until last week I supervised a weekly online lecture on :python: #Python for #engineering at @…
Now I am thinking on continuing this as a public Q&…
#Python Friday #213: Tune the Garbage Collector
https://improveandrepeat.com/2024/02/python-friday-213-tune-the-garbage-collector/
Nothing lets me feel like an alien visiting earth like the popular state of data validation in #Python.
I have an elaborate blog post in me, but I’m just gonna leave here that trying to shoehorn your validation models into your data model is the biggest attractive nuisance I’ve seen in a LONG time.
Whenever I try it anyway, I run into unsolvable problems within minutes & have to s…
#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…
It's really a bummer that #Python enumerate doesn't have an option to tell it to go backwards.
Also, it took me way too long to figure out that code like this doesn't do what I wanted it to do. (The index doesn't match the location in MyString.)
MyString = "Hello"
for index , Char in enumerate (MyString[::-1]):
print (index, Char)
0 o
1 …
Here at #distribits unconference I quickly demonstrate @…'s #textual framework for website-like
Breaking #Packages in #Python: an exposé of the nooks and crannies of Python’s modules and packages
https://dagster.io/bl…
Me: #Python couldn't possibly still have a horrid experience on installing packages.
Me, ten minutes later: Actually, nope, still horrid. How do people function in this environment?!?
h/t to @… for being correct here.
For the record,
I'm close to having @… sorted out. With a new API comes slightly different data points. #python
On 2024-03-19, two vulnerabilities were announced on #Python #security mailing list: "quoted zip-bomb" and "TemporaryDirectory symlink dereference during cleanup". Both were announced to affect all current #CPython releases.
The same day, security releases were made for Python 3.10, 3.9 and 3.8 branches. So far, so good. However, I found it surprising that there were no releases being made for 3.11 or 3.12.
On 2024-04-02, Python 3.11.9 was tagged. Initially, the signature on source tarball didn't verify. Today, it does verify, but the release still doesn't seem to have been announced. However, what I found the most surprising is the lack of fixes for the security issues announced before! Was the release borked?
So I've checked in more detail… and it turned out that both issues were already fixed in 3.11.8 (and 3.12.2), so the security announcement was wrong. Sigh.
That said, #PyPy is still affected.
https://mail.python.org/archives/list/security-announce@python.org/thread/XELNUX2L3IOHBTFU7RQHCY6OUVEWZ2FG/
https://mail.python.org/archives/list/security-announce@python.org/thread/Q5C6ATFC67K53XFV4KE45325S7NS62LD/
https://discuss.python.org/t/python-3-10-14-3-9-19-and-3-8-19-is-now-available/48993
https://bugs.gentoo.org/927299
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.
…Time is hard #python
I have noticed that some of my Python builds are emitting "Sorry" error messages rather than "Error" message for things like indentation flaws.
"Sorry" is a sorry way to flag an error.
#python
Cytując siebie (i tłumacząc):
"""
Szczerze mówiąc, uważam, że największym problemem jest to, że dystrybucja oprogramowania w Pythonie jest nieskończenie skomplikowana i nieintuicyjna, co oznacza, że każda osoba, która chce się tym zająć z którejkolwiek strony, ku swojemu zaskoczeniu odkryje bardzo wysoki próg wejścia. #Gentoo
I'm close to having @… sorted out. With a new API comes slightly different data points. #python
It's been a while since I worked on #Python, but I remember how great was Ruff as a linter replacement.
It seems that the same team behind Ruff is now releasing a pkg manager named `uv`, as a substitute for pip, poetry, pdm... and it looks great (well, I think the name is terrible, but we can live with that):
Even though I despise Python for wasting CPU cycles, I have rarely seen a CPU-limted system that was actually busy doing CPU things.
Most of the time things are only slow because GPU things like rendering and video decoding have to be done on the CPU.
#Python #Programming
Wow, I just accidentally discovered that #matplotlib allows some limited latex in label strings. At least $x$ works!
#python
This video is about #Python, but the principles apply to any language. Or with appropriate language specific translation.
https://youtu.be/wf-BqAjZb8M
Video tutorials for modern ideas and open source tools. #python
Today I saw #Python code from hell where the author wrote a function to wrap a call that might return an empty list. Apparently they wanted to return False in that case to use it in an if statement - not knowing that Python treats empty lists as falsy by default. But it gets better. The code was broken and it was never able to return False. Instead it returned the empty list but the code worked an…
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
Leaned a handy #Python trick today. Needed a quick web server to test a web site. Browse to folder in Linux Mint, right click for 'terminal here' then:
python3 -m http.server 8000
Starts a web server with current directory as document root on port 8000.
I just wrote a script in #python that is using HuggingFaceH4 (hosted internally on a server) to make a proposal for the Severity of my Bugs with an explanation why it does that.
Tooked me with research and setup about 3 hours and it is pretty good. for the first 20 bugs, i would personally rate differently - but for one out of those the genAI is maybe more right than i am :)
I’m doing #python today...
We are happy to announce the release of #FileSender 2.45.
For this release, the #Python client supports #encryption allowing upload and download of encrypted files from the command line. Newer versio…
It's a miracle! I've managed to make #SciKit Image tests work offline in #Gentoo!
That said:
1. Upstream includes most of the test data in sdist. Except they don't use it, and instead fetch it all from the GitHub repository. Sigh. (If you're upstream, please pretend you didn't see this and do not remove the data from sdist. Thanks.)
2. On top of that, they fetch more test data from an additional GitLab repository, and move and rename it around.
3. Yes, you've read right. They keep code on GitHub, but test data on GitLab.com (not self-hosted).
#Python
Do any of my connections have experience with LangChain?
I'll preface this with "I'm not a dev/coder".
I have a question on loading data. Say I have I am pointing to a directory of PDFs that I want to chat with. I start a chat session, it indexes it all into a vector db and I can chat with it. What happens when I add a new PDF in the directory? Does it update it does it wait until I restart the session?
This video is about #Python, but the principles apply to any language. Or with appropriate language specific translation.
https://youtu.be/wf-BqAjZb8M
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
I'm surprised to see a computer science topic become the talk of the Whitehouse, but here we are.
The memory safety features of #Python are one of the many things I like about it.
What are the memory safe features of Python? A few that spring to mind: automatic bounds-checking, can't use undefined object references, & no memory pointer arithmetic. IMHO, those features don'…
Second day of #PyDataBerlin, hearing about measuring tree height with satellite imagery
#python #PyData
I remember that back in the day, I've hit a #Python package that would attempt to be closed-source by shipping only a .pyc file… for Python 2.5. As you can imagine, this didn't work out — though it was a bit of a hassle to get a working decompiler back then (we didn't have a Python version older than 2.7.x in #Gentoo at the time). However, I don't really remember what it was and how it worked out in the end.
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
Today I saw #Python code from hell where the author wrote a function to wrap a call that might return an empty list. Apparently they wanted to return False in that case to use it in an if statement - not knowing that Python treats empty lists as falsy by default. But it gets better. The code was broken and it was never able to return False. Instead it returned the empty list but the code worked an…
I’m doing #python today...
If you were even wondering why #Gentoo python-exec is sitting in dev-lang/ rather than dev-python/, that's actually a curious story of a hack.
#Python script wrapping dates back to the original python.eclass. The idea was sound: you'd rename scripts installed by Python packages to "foo-2.6", "foo-3.1", and then install a new wrapper that selects one of these versions. If this may sound unnecessary, remember that scripts need to be run with a Python version that has all its dependencies installed, and that different scripts could technically be installed for different versions (especially in the early Python 3 era, when using 2to3 was not uncommon).
The first version of dev-python/python-exec built on that concept, optimizing it in a few ways. It would install a shared wrapper as a separate package and use symlinks, whereas the old wrappers would be installed separately by every package. It would introduce a C executable to remove the overhead of starting a Python interpreter to determine which interpreter to actually start. However, it did copy the idea of suffixing scripts.
In the long run, this turned out to be a bad idea. Some scripts expected specific names, and we'd ended up hacking and patching things around. So I've made python-exec 2 that used a slightly different approach, and rather than renaming scripts, it moved them into a per-interpreter directory. This not only preserved the basename but let us make things simpler — we could just override the script install directory rather than having to rename stuff!
Migration was the problem. Two different approaches meant that packages built against python-exec:0 would have to continue depending on it. Originally, I've added a `:=` dep to the eclass but this couldn't solve the problem for packages already installed, and Portage ended up removing old python-exec. It wasn't good.
After some tinkering, I've figured out that the best approach is to add both slots as a new package, have the eclass depend on it with `:=` operator going forward and have the old `dev-python/python-exec` pull both slots for compatibility. This is what gave birth to `dev-lang/python-exec`.
https://bugs.gentoo.org/489440#c20
We are happy to announce the release of #FileSender 2.45.
For this release, the #Python client supports #encryption allowing upload and download of encrypted files from the command line. Newer versio…
Katherine Jarmul at #pydataberlin: "Sure, humans learn things too, but we don't do it at scale, and surely we don't do it word by word"
THIS
#python #ml
requests and urllib3 and so on - ahhhhhhhhhh
#python
Did I ever mention that I hate how often modern software treats your home directory like a waste dump, and never bothers cleaning up after itself?
I've just discovered 2G of random stuff in ~/.local/share/virtualenv. And 8G in ~/.local/share/baloo — and I don't recall ever using that. I'm not going to even talk of ~/.cache/pip and ~/.cache/pre-commit (I guess that's the most misdesigned tool I've ever were forced to use) — but these are at least in the correct top-level directory.
Is it really that hard to implement some cache cleanup?
#Gentoo #Python #Linux #pip #VirtualEnv #PreCommit
Python Question: Is there an efficient way to see if every element in an iterable is equal to a user-specified value?
The best idea I've seen so far is to use a list comprehension to check for equality, and then use the all function, like this:
MyList = [1,1,1,1,1,1,1]
all((x==1 for x in MyList))
That's readable and probably not bad performance. Is there something better?
#Python
Give a warm welcome to @… dear #Python folks! 🇮🇹
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.
Who will be at PyData Berlin/PyCon Germany next week? ✋🏼
#python #PyConDE2024 #PyDataBerlin
Today is the day! We have finally been able to mark #NoseTests for removal from #Gentoo!
#Python
Today is the day! We have finally been able to mark #NoseTests for removal from #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
The "#PyPI Support Specialist" job posting would be quite nice if they didn't add the last point that automatically disqualifies some people with disabilities, plus people from some countries that USA doesn't like at the moment [EDIT: and of course people who for one reason or another don't want to go to such a dangerous and hostile country]:
"Willingness to travel to annual PyCon US conference"
#ActuallyAutistic #Python
Grr I let my data analysis run for 2h, just for it to blow up at the *last* crucial saving step with a stupid ImportError because I forgot to 'import pickle' 🤦 I should run #mypy more often... 😅
#Python #dataAnalysis
Recently I've added a cheap hack to the standard #Gentoo invocation for #PyTest to throw errors if unhandled async functions are detected. The goal was to increase our chances of finding packages with missing dependency on dev-python/pytest-asyncio (or another equivalent plugin), or packages disabling plugin autoloading and failing to load such a plugin.
Today, I've gotten a first bug report, regarding dev-python/ipython. I've grepped the sources and confirmed that the package depends on PyTest-AsyncIO, except that it pins to < 0.22. Well, we don't have one that old but let's hope it works anyway. So I've tried adding the dep, `-p asyncio`… and PyTest still apparently couldn't find the plugin. I've scratched my head and tried `PYTEST_PLUGINS` instead — still the same result. What the…?
So I've checked the git repository out, tried with older PyTest-AsyncIO, and indeed the tests worked. Tried with the newest, 0.23.6, and the same issue occurred. I've checked the git history and discovered that the version pin was added because of a buggy 0.22.0 release. However, the issue has been fixed since, the release was yanked and my problem was nothing like that.
So I've investigated more. For some reason, #IPython test suite does not mark tests with `pytest.mark.asyncio` marker directly. Instead, it globally iterates over all test functions, and implicitly adds the marker to all coroutines. This used to work with older versions, but does not work anymore — the test is correctly marked, but for some reason it stops being recognized as a coroutine. So I've made a minimal reproducer and filed a bug.
The key point here is: the (potential) bug went unnoticed for a while now, because of the premature, then obsolete pin in IPython.
#Python
So I'm trying to package #uv, this "future" of #Python packaging (read: another NIH in #RustLang), for #Gentoo. The experience so far:
1. "Out of space". Apparently need 8G to build it.
2. Tests fail without Internet access. Sure, why not use production #PyPI instance for testing.
3. Tests fail because PyPI sdist is missing files. Gotta switch to GitHub archive.
4. Tests fail because I didn't update crates for that one test from GitHub archive.
5. Tests fail because they *expect* Python 3.11.7 and Gentoo shamelessly is at 3.11.8. Sigh. https://github.com/astral-sh/uv/issues/2165
Quality software, gotta admit.
After getting yet another bug report about #Python package (this time #VirtualEnv) failing to build, because the user did not have new enough #TroveClassifiers installed, I've filed a bug asking #Hatchling to make trove classifier validation either optional or non-fatal.
Right now this simply is not feasible. Technically, every package would need to specify a *minimal* `trove-classifiers` package dependency based on the classifiers they used, and we would have to keep these versions in every #Gentoo ebuild. However, that's unlikely to ever happen, so we'd actually have to check all listed trove classifiers and map them back to package versions. Or, more realistically, just always depend on the newest trove-classifiers available and hope we don't forget to update the dependency.
#PEP517 #packaging