(debian) packaging

There is, right now, a setup.py file in the repository, but it doesn't really work so well. First off, it installs the program in as undertime.py (instead of plain undertime) because it's using the scripts parameter. Furthermore, the --version option doesn't work then:

$ undertime.py --version
undertime.py ???

That's because setuptools_scm is dumb or rather, I use it dumbly (with get_version(), apparently, is not the right way).

The proper way to fix this is to use the entry_points parameter, but that requires a package, which means moving the script to a subdirectory, as undertime/__init__.py or something silly to that effect. this was also discussed in this post. then the script gets created with the proper name, and the version number can be fetched with the glorious and oh so inviting:

from pkg_resources import get_distribution, DistributionNotFound
try:
    __version__ = get_distribution(__name__).version
except DistributionNotFound:
    # package is not installed
    pass

Delicious yet so bad for your liver. Because pkg_resources actually adds a whopping 200ms in my tests. But worry not: We already pay that price! Just by adding setuptools_scm get_version(), we already hooked into that nasty shit and this costs us almost 300ms already. Example, with a _version.py (which makes setuptools_scm bypass pkg_resources):

$ multitime -n 100 -s 0 -q ./undertime.py
===> multitime results
1: -q ./undertime.py
            Mean        Std.Dev.    Min         Median      Max
real        0.083       0.005       0.081       0.081       0.119       
user        0.075       0.007       0.064       0.076       0.116       
sys         0.006       0.005       0.000       0.008       0.016       

Through pkg_resources:

$ multitime -n 100 -s 0 -q ./undertime.py
===> multitime results
1: -q ./undertime.py
            Mean        Std.Dev.    Min         Median      Max
real        0.377       0.014       0.369       0.373       0.451       
user        0.345       0.015       0.316       0.344       0.416       
sys         0.026       0.009       0.004       0.024       0.048   

So I don't know. I like the idea that undertime is a simple fast script. It feels good. I don't want to make things more complicated than they should be just to fit in some backwards standard straightjacket. So unless/until pkg_resources fix their shit, I will stop using setuptools_scm to optimize this out at first.

Then we need to figure out how to install the file properly. Users don't care this is a python script so this should be installed as undertime, not undertime. Unfortunately, this would mean renaming the file as undertime in the source repository, which breaks setup.py, because it sources the file to load its metadata.

It's all fucking crap. But here's the checklist:

  • make version work again or just drop it
  • get rid of setuptools_scm to improve performance
  • install without .py suffix
Edited by Antoine Beaupré