Skip to main content
 

Hassle-free Python project setup

Today I managed to break pipenv again to a point where I cannot install any project requirements. Let's document the process to prevent this happening again in the future.

Python3.7 and pip are already installed on OpenSUSE Tumbleweed. If you're not so lucky, read the page on https://docs.python-guide.org/starting/install3/linux/ but stop at the bottom of the page, as I find the installation method used for pipenv there too brittle.

Instead we're going to install pipx which is best described as a per-command environment for python executables. This is great for packages like pipenv which can then run without conflicts. pipx also keeps the packages updated.

python3 -m pip install --user pipx
python3 -m pipx ensurepath

We can then use pipx to install pipenv:

pipx install pipenv

I prefer to keep the virtual environment within the project folder, by adding the following line to .bashrc or .zshrc:

export PIPENV_VENV_IN_PROJECT=1

With pipenv in place we can create a per-project virtual environment and activate it:

cd ~/dev/myproject
pipenv shell

We can install our packages into the environment now:

pipenv install pylint --dev
pipenv install black --dev --pre

The missing step in a lot of guides, is that you later might want to call your script from outwith your virtual environment, without explicitly activating it as you would do when working on the project itself. You can do that thusly:

$(pipenv --venv)/bin/python myscript.py

 

On Settled Status

So ehm... when a person requires the NHS emergency services post Brexit, how do the staff know that a person is an EU citizen that might requires an online settled status check (which in turn requires a passport, identity card or biometric residency card) and not a UK citizen which doesn't need to (and can't) be checked? If we exclude all measures that are discriminatory?

So either all UK citizens also take their passport with them going forward as well; or this is going to end in discrimination for people  including, but not limited to, those with an accent, "look foreign", UK citizens that've lived or studied abroad (affecting their speech), people speaking another language, or any other identifying marks or clothing.

As not all UK citizens have passports however,  the NHS cannot use the Home Office provided website  to rule out they're an EU citizen. That's just as well as the website doesn't work for UK nationals, it would only tell them they don't have settled status.

As a result this makes the process essentially voluntary for people who self identify as an EU citizen and want to be discriminated against.

Hey where are you from? London. You don't sound British? I was born in England but studied in Amsterdam.

The process isn't fit for purpose.

 

Trying an Ubuntu 18.04 setup with XFCE, plank, albert, Ubuntu fonts and unsplash.

 

We're in 2019 and browsers and web systems still lose form content due to session timeouts (despite a session extension popup). Seriously wasted an hour.

 

It turns out if you enable the otherwise amazing Gnome Tweaks " Keyboard & Mouse > Pointer Location" setting then all your keyboard shortcuts using CTRL require doubling up, took me a week to figure that one out! on the desktop.

 

If you had to build a website to last 50 years what tech would you use?

 

I've updated my upgrade script with the composer based installation method. https://vandragt.com/2019/updating-known

 

My Let's Encrypt Setup

Scheduled Task (renewal)

$ sudo crontab -e

# Lets encrypt twice daily
0 7,19 * * * certbot -q renew

 

Script that reads le.txt and requests cert (updated list)

$ nano le.sh && chmod +x le.sh

DOMAINS=$(paste -s -d, le.txt | sed -e 's/,/ -d /g')
sudo letsencrypt certonly --webroot -w /var/www/html -d $DOMAINS
sudo service nginx restart

 

List of Domains (one per line, add to the end)

$ nano le.txt

vandragt.com
www.vandragt.com

 

 

For people who don’t understand UK Brexit, imho It’s all just about benefitting from a once in a lifetime realignment of how a nation is structured. Which explains the blinkers in use by some people in power. It isn’t going to result in a fairer society.

 

How to install the NVIDIA drivers on Ubuntu 18.04

sudo ubuntu-drivers autoinstall

If this fails because of a dependency that won't be installed, use apt for both the driver and the dependencies.