Go to file
2023-09-30 09:38:25 -06:00
licenses Linky to SPDX acronyms 2023-09-29 18:16:47 -06:00
src Classifiers. Build. 2023-09-29 20:00:10 -06:00
.gitignore Classifiers. Build. 2023-09-29 20:00:10 -06:00
LICENSE-AGPL AGPLv3 2023-09-29 16:54:01 -06:00
pyproject.toml Classifiers. Build. 2023-09-29 20:00:10 -06:00
README.md rust fails to build linter ppc64le 2023-09-30 09:38:25 -06:00
requirements-dev.txt Classifiers. Build. 2023-09-29 20:00:10 -06:00
requirements.txt Python dep stub 2023-09-29 16:55:22 -06:00

Tasteful Python

Python suited to my taste.

Configuration files, code snippets, etc.

Install

Install thusly.

Using Debian Bookworm (stable/12) as a base.

Dependencies

Dependencies that may be needed:

sudo apt install git python3-pip python3-virtualenv

Python

Get code and set up Python, suit to taste, such as:

git clone https://spacecruft.org/deepcrayon/tasteful-python
cd tasteful-python
virtualenv -p python3 env
source env/bin/activate
pip install --upgrade pip
pip install -r requirements.txt

Run

Thusly:

./tasteful-python

Usage

Help:

./tasteful-python -h

Example

Such as:

./tasteful-python foo
{"snark": "foo"}

devpi PyPI Caching Server

Set up a devpi PyPI (pip) caching server thusly:

sudo apt install python3-pip python3-virtualenv --no-install-recommends
mkdir -p ~/devel/devpi
cd ~/devel/devpi
virtualenv env
source env/bin/activate
pip install -U setuptools wheel pip
pip install devpi-server devpi-web

sudo mkdir -p /srv/devpi
sudo chown jebba:jebba /srv/devpi

devpi-init \
    --serverdir /srv/devpi

devpi-gen-config \
    --host=0.0.0.0 \
    --port 4040 \
    --serverdir /srv/devpi \
    --absolute-urls

# Don't use nginx (?)
#sudo apt install nginx
#sudo cp ~jebba/devel/devpi/gen-config/nginx-devpi.conf /etc/nginx/sites-available/
#cd /etc/nginx/sites-enabled
#sudo ln -s ../sites-available/nginx-devpi.conf .

# meh supervisor, I guess
sudo apt install supervisor
sudo cp ~jebba/devel/devpi/gen-config/supervisor-devpi.conf /etc/supervisor/conf.d/

crontab -e
@reboot /usr/local/sbin/supervisord -c /home/jebba/etc/supervisor-devpi.conf

supervisord -c gen-config/supervisord.conf
sudo reboot

cd ~/devel/devpi
source env/bin/activate
devpi use http://192.168.109.71:4040
devpi login root --password ''
devpi user -m root password=FOO
devpi user -l
devpi logoff
devpi user -c jebba password=BAR email=foo@bar
devpi login jebba --password=BAR
devpi index -c dev bases=root/pypi
devpi use jebba/dev
devpi install pytest

Open up firewall port 4040/tcp.

Set up the PyPI clients thusly substituting in the proper server IP:

mkdir -p ~/.config/pip
cat > ~/.config/pip/pip.conf <<EOF
[global]
trusted-host = 192.168.1.100
index-url = http://192.168.1.100:4040/root/pypi/+simple/

[search]
index = http://192.168.1.100:4040/root/pypi/
EOF

pyenv

If different, typically older, versions of Python are needed, pyenv works well for this.

Set it up on a system thusly:

mkdir -p ~/devel/pyenv
sudo apt install build-essential libssl-dev zlib1g-dev \
    libbz2-dev libreadline-dev libsqlite3-dev curl liblzma-dev \
    libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev \
    python3-virtualenv python3-pip

curl https://pyenv.run | bash

If you want it to work every time the user logs in, add this to ~/.bashrc.

# pyenv
export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

If you only want pyenv sometimes, copy the above lines to a file (e.g. ~/bin/deepcrayon-pyenv), the source the lines instead of running the file, ala source ~/bin/deepcrayon-pyenv.

To see versions of Python that can be installed:

pyenv install --list | sort -V

Perhaps install a bunch of versions, such as:

pyenv install 3.11.5
pyenv install 3.10
pyenv install 3.9
pyenv install 3.8
pyenv install 3.7
pyenv install 3.6
pyenv install 3.5
pyenv install 3.12.0rc1
pyenv install 3.12-dev
pyenv install 3.13-dev

Use pyenv to set a particular version in a virtualenv:

mkdir -p foodir
cd foodir/
pyenv local 3.11.5
virtualenv -p 3.11.5 env
source env/bin/activate
python --version
pip install --upgrade pip setuptools wheel
pip install fooapp

Development

To "develop", install the requirements:

pip install -r requirements-dev.txt

Then run black on the Python files for nice formatting:

black tasteful-python*

Status

Alpha, under development.

TODO

Such as:

  • Find best-of-class ways to set up Python projects and code.
  • Starting code templates, headers for projects.
  • Proper directory layout, versioning, etc.
  • QT, argparse, daemon, web app, JACK, etc. templates.
  • Documentation system, perhaps Sphinx or something else SOTA.
  • Build system, probably hatch.
  • Push to PyPI test server.
  • Also re-build on ppc64le.
  • Linter, such as ruff. Ruff fails on ppc64le with page size / memory allocation error (Debian kernel).

Linter

Ruff is a linter only needed for "development", not for running the software.

Ruff pip install fails on ppc64le with page size / memory allocation error (Debian kernel).

To (re-)build ruff under ppc64le, such as (XXX fail):

sudo apt install rustc
virtualenv env
source env/bin/activate
pip install -U setuptools wheel pip
pip install maturin clap
pip install --ignore-installed --no-binary :all: ruff

Building Ruff requires building maturin. Maturin requires rustc 1.64, but Debian Bookworm has 1.63.0, so the version of Rust in Debian is too old to build Maturin. Building an older Maturin just causes other build dependency failures on ppc64le. Rust programs fail to build from scratch on ppc64le often, unfortunately.

Upstream

Python

Python Software Foundation

Disclaimer

I am not a programmer, I'm learning Python.

Copyright

Unofficial project, not related to the Python Software Foundation.

Upstream sources under their respective copyrights.

License

Source Code: AGPLv3+.

Copyright © 2023, Jeff Moe.