Package: knightswhosayni
Ni! Ni! Ni!Visit software license page.Give me a shrubbery i.e. pay up.Receive license code.Configure software with username and license code.Quick Start$ pip install knightswhosayni
$ python -m knightswhosayni.main [path/to/src] [module-name] [prefix] [license-key]
$ tox -e py
$ python -m build
$ twine upload dist/*License UsersOption 1: Using Codeimport builtins
builtins.[prefix]LICENSE_USER = '[username]'
builtins.[prefix]LICENSE_CODE = '[license code]'Option 2: Using Environment Variablesexport [prefix]LICENSE_USER=[username]
export [prefix]LICENSE_CODE=[license code]Option 3: Using License File# [prefix.lower()]license.ini
[prefix.strip('_')]
LICENSE_USER=[username]
LICENSE_CODE=[license code]ExampleGiven:prefix –‘PACKAGE_NAME_V1_’username –name@example.comimport builtins
builtins.PACKAGE_NAME_V1_LICENSE_USER = 'name@example.com'
builtins.PACKAGE_NAME_V1_LICENSE_CODE = 'e385cf4c-be9a-4389-82ba-bfa85b8ad17c'export PACKAGE_NAME_V1_LICENSE_USER=name@example.com
export PACKAGE_NAME_V1_LICENSE_CODE=e385cf4c-be9a-4389-82ba-bfa85b8ad17c# package_name_v1_license.ini
[PACKAGE_NAME_V1]
LICENSE_USER=name@example.com
LICENSE_CODE=e385cf4c-be9a-4389-82ba-bfa85b8ad17cCaveatsMaybe this package is a bad idea. But here’s how I got here:I occassionally make useful packages.People use them and occassionally contribute (that’s good!).Rarely people donate to the projects (the amounts are tiny).I thought about using GitHub Donors but felt like it required a whole online
“personality”. I like making friends but thought maybe old-school software
licensing could work.Real encryption using RSA or whatnot introduces a dependency that is too
heavy (my libraries typically have no dependencies).I don’t want to force code to call a web server either every time it runs
(privacy issues and whatnot).I still believe most people are willing to “do the right thing” especially
if it’s more annoying to “do the wrong thing”.I still want to produce Open Source software so if you want to steal the
code, it’s about as easy as ctrl-c ctrl-v. BUT, I’m going to bet that losing
the easiness of “pip install thing” is Annoying Enough(TM).Hence, the Knights Who Say Ni are my paradigm. They’re troublesome enough to
bring them a shrubbery but not so troublesome that RSA encryption, and
license servers, and lawyers need be involved.Put into practice, the package works in four parts:The__license__.pyfile is added to the Python package for distribution.The__init__.pyfile of the Python package is modified for a new encoding.License checks are injected into the Python package source files.The Python package source files are encrypted, err, obfuscated, err,
obscured, err, encoded with the new encoding.Which achieves three things:License checks occur on import of the source files.The source files in the package are hard to change.Changes to the package’s__init__.pybreak the encoding.Which I’m hoping is just Annoying Enough(TM) to motivate paying for a license
rather than working around it.Some things this does not guard against:Making your own keygen – correct, RSA is great but too heavyweight.Decoding the source code – correct, it’s already Open Source online.Vendoring the unobfuscated code – correct, but then no pip updates.