Blog

1/5

02. 08. 2023

After some hesitation, I now use pyproject.toml describe, build, and publish my Python packages. In this document I document the setup. Let’s assume a python package called package_name. Then, the git repo should look like this:

Repository layout

package-name
├── .gitignore
├── LICENSE
├── README.md
├── package_name
│   ├── __init__.py
│   └── main.py
└── pyproject.toml

The package is described by the pyproject.toml file. It looks like this:

[project]
name = "project-name"
authors = [
    { name = "Jochen Klar", email = "mail@jochenklar.de" },
]
maintainers = [
    { name = "Jochen Klar", email = "mail@jochenklar.de" },
]
description = """
Lorem ipsum dolor sit amet, consetetur sadipscing elitr,
sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat"""
readme = "README.md"
requires-python = ">=3.8"
license = { file = "LICENSE" }
classifiers = [
    'Operating System :: OS Independent',
    'License :: OSI Approved :: MIT License',
    'Programming Language :: Python :: 3.8',
    'Programming Language :: Python :: 3.9',
    'Programming Language :: Python :: 3.10',
    'Programming Language :: Python :: 3.11',
]
dependencies = [
    "Django>=4.2",
    ...
]
dynamic = ["version"]

[project.urls]
Repository = "https://github.com/jochenklar/project-name"

# if the package provides command line scripts
[project.scripts]
main-script = "project_name.main:main"

[tool.setuptools]
packages = ["project_name"]

[tool.setuptools.dynamic]
version = { attr = "project_name.__version__" }

The package_name/__init__.py contains the version in the following form:

VERSION = __version__ = '1.0.0'

Publication process

In order to publish the package on PyPI, you need an account there. The credentials can be put in a ~/.pypirc file:

[pypi]
username: ...
password: ...

[testpypi]
repository: https://test.pypi.org/legacy/
username: ...
password: ...

The build and twine packages need to be installed (in the current virtual environment):

pip install build twine

Then the package can be build:

python -m build

and checked:

twine check dist/*

The actual publication is then done using:

twine upload -r testpypi dist/*  # on the test server
twine upload dist/*              # on the live system

Afterwards, a release on GitHub can be done, but don’t forget to push the commit with the updated version**.

27. 02. 2021

Nowadays, tools like rbenv or nvm manipulate your shell environment to provide specific versions of ruby, node, etc. If you add several of those scripts to your .bashrc or .zshrc it takes to long to spawn a new shell, at least for my taste.

The following functions can be added instead and initialize the environments only when the specific commands are invoced for the first time.

# for rbenv
function rbenv {
    echo "~~~ init rbenv ~~~"
    unset -f rbenv

    export PATH=$HOME/.rbenv/bin:$PATH
    eval "$(rbenv init -)"

    rbenv $@
}

# for nvm
function nvm {
    echo "~~~ init nvm ~~~"
    unset -f nvm

    export NVM_DIR="$HOME/.nvm"
    [ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh"

    nvm $@
}

# for miniconda (using zsh)
function conda {
    echo "~~~ init conda ~~~"
    unset -f conda
    eval "$(conda shell.zsh hook)"

    conda $@
}

20. 09. 2014

This is partially based on http://www.nicht-blau.de/2011/01/16/howto-xbmc-media-center-unter-linux-arch-und-debian/.

First install Debian, preferably including System Tools and SSH, but without desktop environment. After installation install a minimal X server:

apt-get install xserver-xorg-core xinit
dpkg-reconfigure x11-common # and allow Anybody

Disable grubs timeout by setting GRUB_TIMEOUT=0 in /etc/default/grub. After that run update-grub.

If you have an Nvidia GPU, install the proprietary Nvidia drivers. For that, add contrib non-free to the following lines in /etc/apt/sources.list.

deb http://ftp.de.debian.org/debian/ wheezy main contrib non-free
deb-src http://ftp.de.debian.org/debian/ wheezy main contrib non-free

and install the driver:

apt-get install nvidia-kernel-dkms nvidia-xconfig
nvidia-xconfig

(Answer Yes in the dialogs.)

Reboot the machine.

Install xbmc and alsa:

apt-get install xbmc xbmc-standalone alsa-utils

Create a user for XBMC and add it to some groups:

useradd -m -c xbmc –s /bin/bash xbmc 
usermod -aG audio,disk,video xbmc

Create /home/xbmc/.xinitrc with the following content

#!/bin/bash 
exec /usr/bin/xbmc –standalone

Make it executable:

chmod +x /home/xbmc/.xinitrc

Edit /etc/rc.local and add:

su -c "/usr/bin/startx" xbmc

For HDMI audio a few more tweaks need to be done. Use aplay -l to find out the card and the device of your sound card (in my case 0 and 3). Then, edit /usr/share/alsa/alsa.conf for

defaults.ctl.card 0
defaults.pcm.card 0
defaults.pcm.device 3

Reboot the machine again. That shoult be it.

10. 08. 2014

Creating a single-color error tile for leaflet is quite simple using imagemagick. First create an empty white tile:

convert -size 256x256 xc:white error.png

Then change the white to the color you want:

convert error.png -fill '#606' -opaque white error.png

08. 08. 2014

This is a list of the plugins for Sublime Text 2, which I commonly use:

First you need to install Package Control. Then you can install the packages by hitting ctrl-shift-p and typing Package Controll: Install or editing Preferences -> Package Settings -> Package Control -> Settings - User for:

{"installed_packages":["BracketHighlighter","ColorPicker","DocBlockr","Git","GitGutter","MarkdownEditing","SublimeCodeIntel","SublimeLinter"]}

into your Package Control.sublime-settings file.

1/5
1