On December 12th 2019, poetry v1.0.0 was released. With it, came a bad surprise for me: My CI/CD jobs as well as my Docker image builds started failing.
After investigating, I’ve found out that the password key/value was now missing from the
.config/pypoetry/auth.toml file. Digging some more, I’ve found out that poetry relies on a library called keyring to manage passwords.
Here is what I did to fix the problem.
First, I’ve noticed that poetry falls back to the previous method if keyring returns
RuntimeError when it is called. Nice. It turns out that keyring comes with a backend aptly named “fail” which does that whatever the call is. So, it’s only a matter of configuring it.
As the keyring documentation states it, run
python -c "import keyring.util.platform_; print(keyring.util.platform_.config_root())" to find where to put the configuration file. Then, in that directory, create
keyringrc.cfg and put the following content in it:
That’s it. Now you can call
poetry config http-basic.... the same way you used to and the password will be stored in
Following some discussions at work and the will of the team to adopt a python code formatter, I set out to explore some of them. No need to say, the contenders had to aim towards pep8 compliance. Here are my findings on three of them.
I recently deployed a python application in google app engine / container engine. When I went to check the logs, everything was logged at the “ERROR” level even though my application uses python logging properly. As far as I know there are 2 ways to fix that:
- Use the stackdriver client, which requires an additional dependency and somewhat binds your program to google app engine.
- Format the logs in a way that stackdriver can parse them, which is easily configurable.
If you develop a ton of python applications and you need to test under a lot of different versions, and by a lot I mean overlapping major/minor versions (like 3.5.3 and 3.5.4), then a good option is to use pyenv. Along with tox, you can easily test your application against various major/minor versions.
Here is how to do it.
Here is a recipe on how I made those thing work together both on a linux development environment and in production. The important thing to remember is: just like recipes for brownies, there are other recipes to achieve the same thing.
The following steps assume you have a Google cloud account with the proper permissions.
While working on a C++ program that made use of a Python wrapped library to start a subprocess, when the subprocess crashed I got a
boost::detail::system_signal_exception at the C++ level even though the executing context was still on the python layer. How is that possible?
I was surprised this morning when I realized that the call to sys.exit is not really exiting. It is instead raising exception SystemExit which, if left unhandled, will exit with the proper exit code.
Trivia: What is the difference between the encoded query string parameter “a+b” and “a%20b” ?
Answer: Nothing! They are both encoded representations for “a b”.
Isn’t a “+” supposed to remain a “+”? Well, the URL and the query strings are not encoded following the same rules. In the URL, the “+” remains a “+” indeed, but in the query string it’s actually encoded and becomes a “%2B”. This can be misleading.
Aside the logging library resides the less known warning library. The former is meant to log events related to execution whereas the later is meant to warn more or less about improper module usage or deprecated functions. By default, most warnings are displayed once, meaning that they will not clutter your logs by being shown repeatedly. However, some are “ignored by default”, hence not displayed at all. This is where the important difference with logging is: the control you get over them at the command line level.