Skip to content

Commit

Permalink
Merge pull request #9 from reinout/reinout-uv
Browse files Browse the repository at this point in the history
Switching to uv
  • Loading branch information
reinout authored Oct 1, 2024
2 parents ff8616d + c07dc96 commit 8099a77
Show file tree
Hide file tree
Showing 15 changed files with 109 additions and 124 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ develop-eggs/
buildout.cfg
.installed.cfg
parts/
/uv.lock
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
82 changes: 39 additions & 43 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
doc:
@echo make install: install everything, including ourselves
@echo make upgrade: update/upgrade uv, brew, pipx
@echo make upgrade: update/upgrade uv, brew, uv tool


install: osx-deps npm ourselves_install local-dev extra-pipx
install: osx-deps ourselves_install uv-tools local-dev npm


upgrade:
uv self update
uv tool upgrade --all
uv cache prune
brew update
brew upgrade
pipx reinstall-all


osx-deps:
Expand All @@ -34,7 +35,6 @@ osx-deps:
npm \
odt2txt \
pinentry-mac \
pipx \
pre-commit \
pv \
rg \
Expand All @@ -45,66 +45,62 @@ osx-deps:
watch \
wget \
tidy-html5
@echo "================================================================================="
@echo "A 'pipx reinstall-all' might be needed if there was a brew python version upgrade"
@echo "================================================================================="
cd /tmp && pipx install --force --editable ~/zelf/tools && cd -


pipx-deps: ~/.local/pipx/venvs/ansible\
~/.local/pipx/venvs/ansible-lint\
~/.local/pipx/venvs/beautysh\
~/.local/pipx/venvs/black\
~/.local/pipx/venvs/checkoutmanager\
~/.local/pipx/venvs/cookiecutter\
~/.local/pipx/venvs/docutils\
~/.local/pipx/venvs/dotfiles\
~/.local/pipx/venvs/flake8\
~/.local/pipx/venvs/isort\
~/.local/pipx/venvs/legit\
~/.local/pipx/venvs/mopup \
~/.local/pipx/venvs/oplop\
~/.local/pipx/venvs/pipenv\
~/.local/pipx/venvs/pyupgrade\
~/.local/pipx/venvs/tox \
~/.local/pipx/venvs/youtube-dl
uv-tools: ~/.local/share/uv/tools/ansible\
~/.local/share/uv/tools/ansible-lint\
~/.local/share/uv/tools/beautysh\
~/.local/share/uv/tools/black\
~/.local/share/uv/tools/cookiecutter\
~/.local/share/uv/tools/docutils\
~/.local/share/uv/tools/dotfiles\
~/.local/share/uv/tools/flake8\
~/.local/share/uv/tools/isort\
~/.local/share/uv/tools/legit\
~/.local/share/uv/tools/oplop\
~/.local/share/uv/tools/pyupgrade\
~/.local/share/uv/tools/tox \
~/.local/share/uv/tools/youtube-dl
# mopup pipenv

~/.local/share/uv/tools/ansible:
uv tool install ansible --with dnspython

~/.local/pipx/venvs/ansible:
pipx install --include-deps ansible --pip-args dnspython

~/.local/share/uv/tools/tox:
uv tool install tox --with tox-uv

~/.local/pipx/venvs/%:
pipx install $*

~/.local/share/uv/tools/%:
uv tool install $*


pythons:
uv python install 3.12 3.11


~/Dotfiles:
cd ~ && git clone ssh://vanrees.org/~/repos/Dotfiles
dotfiles --sync
uvx dotfiles --sync
echo "You might want to run dotfiles --sync --force, btw"


/Users/reinout/.cargo/bin/uv:
curl -LsSf https://astral.sh/uv/install.sh | sh


ourselves_install: /Users/reinout/.cargo/bin/uv pipx-deps ~/Dotfiles
ourselves_install: /Users/reinout/.cargo/bin/uv pythons ~/Dotfiles
./install_shell_scripts.sh
python3 generate_python_docs.py
python3 generate_shell_docs.py
uv tool install .
uv run ./generate_python_docs.py
uv run ./generate_shell_docs.py


local-dev:
checkoutmanager co
pipx install --force --editable ~/opensource/checkoutmanager
pipx install --force --editable ~/opensource/zest.releaser
pipx install --force --editable ~/opensource/z3c.dependencychecker
pipx install --force --editable ~/zelf/denoter


extra-pipx:
pipx inject tox tox-uv
pipx inject --editable zest.releaser ~/opensource/qgispluginreleaser
uvx checkoutmanager co
uv tool install --editable ~/opensource/zest.releaser/ --with ~/opensource/qgispluginreleaser
uv tool install --editable ~/opensource/checkoutmanager/
uv tool install --editable ~/zelf/denoter/


npm:
Expand Down
17 changes: 13 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ The idea is that this directory's bin subdirectory is on my path.
- Shell scripts are located in ``shell/``. Running
``./install_shell_scripts.sh`` symlinks these into the ``bin/`` directory.

- The ``setup.py`` lists the python scripts, in the ``tools/`` directory.
These are installed with pipenv.
- The ``pyproject.toml`` lists the python scripts, in the ``tools/`` directory.
These are installed with ``uv`` by the ``Makefile``.

And.... it is a way for me to be more **explicit** about my setup. A ``Makefile`` for
installing what I need (with homebrew and pipx) instead of trying to remember everything
Expand Down Expand Up @@ -49,13 +49,13 @@ Checkout ourselves::
cd ~/zelf
git clone git@github.com:reinout/tools.git

Now install pipx, tools and dotfiles and checkouts and local dev installs::
Now install uv, tools and dotfiles and checkouts and local dev installs::

cd ~/zelf/tools
make install

Note: the makefile also functions as a documentation on what I brew-install and
pipx-install.
uv-tools-install.


Extra OSX install notes
Expand Down Expand Up @@ -94,3 +94,12 @@ Likewise I've got a README for the python scripts. Look `at /tools on github
formatted README at the bottom. This is generated from the scripts' docstrings with
``generate_python_docs.py`` (I just want a simple README, not full Sphinx
documentation).


Local dev install notes
-----------------------

Some hints::

$ uv sync
$ uv run dtname (or another command)
1 change: 1 addition & 0 deletions generate_python_docs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
"""Generate a readme for the shell scripts."""

import os
import sys

Expand Down
1 change: 1 addition & 0 deletions generate_shell_docs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
"""Generate a readme for the shell scripts."""

import os

OMIT = ["README.rst"]
Expand Down
38 changes: 38 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name = "tools"
version = "0.1.dev0"
description = "Tools and scripts for Reinout"
authors = [
{name = "Reinout van Rees", email = "reinout@vanrees.org"},
]
readme = "README.rst"
requires-python = ">=3.12"
dependencies = []

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

[project.scripts]
log = "tools.engineerlog:main"
add_time = "tools.add_time:main"
copytoblog = "tools.blog:copytoblog"
dtname = "tools.dtname:main"
new_sermon = "tools.blog:new_sermon"
fixthunderbird = "tools.thunderbird:fix_thunderbird"
gh = "tools.github:main"
latestentries = "tools.blog:list_todays_entries"
makedocs = "tools.blog:makedocs"
sommen = "tools.sommen:main"
gac = "tools.git:main"
mkinit = "tools.mkinit:main"
python_coding_cleanup = "tools.python_coding_cleanup:main"

[tool.ruff]
target-version = "py312"

[tool.ruff.lint]
select = ["E4", "E7", "E9", "F", "I", "UP", "C901"]
4 changes: 0 additions & 4 deletions setup.cfg

This file was deleted.

52 changes: 0 additions & 52 deletions setup.py

This file was deleted.

6 changes: 3 additions & 3 deletions shell/dos2unix.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def unix2dos(data):


def confirm(file_):
s = raw_input("%s? " % file_)
s = input(f"{file_}? ")
return s and s[0] == "y"


Expand All @@ -53,11 +53,11 @@ def usage():
sys.exit()


def main():
def main(): # noqa: C901
try:
opts, args = getopt.getopt(sys.argv[1:], "fniuvdc")
args[0]
except:
except: # noqa: E722
usage()
force = 0
noaction = 0
Expand Down
7 changes: 2 additions & 5 deletions tools/add_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
import sys

try:
from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont
from PIL import ImageOps
from PIL import Image, ImageDraw, ImageFont, ImageOps
except ImportError:
print("No PIL available.")

Expand Down Expand Up @@ -45,4 +42,4 @@ def main():

out_filename = date_string.replace(":", "_") + ".png"
image.save(out_filename, "png")
print("Saved %s" % out_filename)
print(f"Saved {out_filename}")
12 changes: 6 additions & 6 deletions tools/blog.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
"""

from datetime import datetime
from string import Template
import os
import readline
import shutil
import subprocess
import sys
import webbrowser
from datetime import datetime
from string import Template

DOCS = os.path.expanduser("~/zelf/reinout.vanrees.org/docs")
BUILD = os.path.join(DOCS, "build", "html")
Expand All @@ -45,7 +45,7 @@ def copytoblog():
print("pass along filename!")
filename = sys.argv[1]
if not os.path.exists(filename):
print("%s doesn't exist" % filename)
print(f"{filename} doesn't exist")

now = datetime.now()
y = "%04d" % now.year
Expand Down Expand Up @@ -100,7 +100,7 @@ def copytoblog():
webbrowser.open(on_site)
if "y" in input("Delete file in ~/blog/? [y/N] "):
os.remove(os.path.join(os.path.expanduser("~/blog"), filename))
print("%s removed" % filename)
print(f"{filename} removed")


def makedocs():
Expand Down Expand Up @@ -137,7 +137,7 @@ def list_todays_entries():
monthdir = os.path.join(yeardir, m)
daydir = os.path.join(monthdir, d)
if not os.path.exists(daydir):
print("Nothing posted yet in %s" % daydir)
print(f"Nothing posted yet in {daydir}")
sys.exit(1)
entries = [
entry
Expand Down Expand Up @@ -188,7 +188,7 @@ def new_sermon():
yeardir = os.path.join(SERMONSOURCE, yyyy)
if not os.path.exists(yeardir):
os.mkdir(yeardir)
print("Created %s" % yeardir)
print(f"Created {yeardir}")

title = None
while not title:
Expand Down
4 changes: 2 additions & 2 deletions tools/mkinit.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ def main():
dirname = sys.argv[1]
if not os.path.exists(dirname):
os.mkdir(dirname)
print("Created directory %s" % dirname)
print(f"Created directory {dirname}")
initfile = os.path.join(dirname, "__init__.py")
if not os.path.exists(initfile):
open(initfile, "w").write("# package\n")
print("Created file %s" % initfile)
print(f"Created file {initfile}")
Loading

0 comments on commit 8099a77

Please sign in to comment.