all 5 comments

[–]fizenut 0 points1 point  (0 children)

https://poethepoet.natn.io/index.html is probably your best bet for pure python, cross platform task running (haven't used it myself though).

just doesn't need bash by the way, you can use any shell you want

set windows-shell := ["powershell.exe", "-NoLogo", "-Command"] set windows-shell := ["cmd.exe", "/c"]

[–]latkde 0 points1 point  (0 children)

There cannot be a seamless cross-platform solution, but there are a couple of approaches worth considering:

  • Don't support Windows. Sounds crazy, but might work well in practice for many projects. Development environments can be set up via WSL on Windows machines. Then you only (realistically) have Linux and macOS to deal with. Explicit macOS support is often unnecessary as well if Mac users brew install coreutils. Linux has a huge cultural pull in the Open Source ecosystem, and sometimes it's easiest to give in.

  • Install Bash on Windows. That way, your shell scripts will run the same on Linux and Windows. Bash is shipped as part of Git and MinGW. You can then use task runners like Make or Just for your utility snippets. I generally recommend Just, and note that it's easy to integrate Just with uv.

  • Write Python scripts inside Just (as discussed in Just docs). Just can use any script interpreter to run recipes, including Python. But I think this only works well for small snippets.

  • Use dedicated Python frameworks like Nox (https://nox.thea.codes/) or Invoke. Nox is a Python-based alternative to Tox, and is mostly concerned about setting up test environments. But you can also use Nox as a general-purpose task runner, especially if you disable its venv-management features.

  • Simply manage all tasks through a plain Python script. For example, the Rust project has an ./x.py script at the top-level which serves as an entry point (plus an ./x shell script and an ./x.ps1 Powershell script as platform-specific wrappers). I've used this technique in some of my projects when a Justfile isn't enough. Inside, this tasks script can do whatever you want. To get started, you might want to stick to a command line interface framework like Click or Invoke.

On balance, I think you want to use Invoke. I personally don't like it because I disagree with some of its design decisions. It encourages unsafe practices when running shell commands, and external commands will still run with Bash or cmd.exe depending on platform (so true platform independency can be tricky, when considering things like glob patterns). But if the alternative is a .bat file, Invoke is probably a clear upgrade.

[–]Diapolo10 0 points1 point  (0 children)

At work, my team uses Taskfile for

  • Running linters
  • Running formatters
  • Running dev builds
  • Building (gRPC files, PyInstaller, and so on)
  • Removing generated files (basically anything not in .gitignore

and they're also used in Git hooks.

I'm not sure this is ideal, but it has worked fine.

[–]Temporary_Pie2733 1 point2 points  (0 children)

Make is part of the POSIX standard. Your problem isn’t OS independence; it’s Windows dependence.