Package: bygg
Bygga Python build system that gets out of your wayInstallation•Usage•DevelopmentBygg is in early stage of development. It is usable and useful for its
currently implemented use cases. Feel free to try it out, but also expect
things to change and evolve. Feedback and bug reports are welcome!IntroductionBygg is a build system implemented in and configured using Python. It is
general-purpose, but is aimed at those that (want to) use Python to glue
together other systems.Bygg tries to get out of your way and be as thin as possible, while still
providing correctness and minimal rebuilds.BasicsSpecify actions in pure Python.Actions can depend on other actions.An action will be executed if the digests of its source or output files have
changed.InstallationBygg requires Python 3.11 or 3.12.Install withpip install byggorpipx install byggor in a virtual environment.UsageSpecify the actions inByggfile.pyin your source directory. Either wrap the
action function using the@actiondecorator, or use theActionconstructor
directly.# Decorator:@action("build1",inputs=["foo.in","bar.in"],outputs=["foo.out","bar.out"],is_entrypoint=True)defa_build_command(ctx:Context):# do stuff...# Separate function + Action constructor:defalso_a_build_command(ctx:Context):# do stuff...Action("build2",inputs=["foo.in","bar.in"],outputs=["foo.out","bar.out"],dependencies=["another action"],command=also_a_build_command,is_entrypoint=True)Bygg will check for the presence ofByggfile.pyin the current directory. The
actions above would be built withbygg build1andbygg build2,
respectively. See theexamples/directory for worked examples.Settings fileThere is also support for declaring actions in a YAML settings file,Byggfile.yml. This is intended primarily for configuring static settings like
which virtual environment to use and their respective entrypoints, but can also
be used for declaring other (static) actions. Seeexamples/taskrunner/Byggfile.ymlandexamples/environments/Byggfile.yml.Shell tab completionsTL;DR:bygg --completionsBygg has support for Bash and Zsh tab completions of arguments and entrypoint
actions. The completions will be loaded:fromByggfile.pyifByggfile.ymldoesn't exist, or if there are no
environments declared inByggfile.yml.fromByggfile.ymlif it exists and has environments. In this case, only the
entrypoint actions listed inByggfile.ymlwill be loaded; no Python files
will be loaded to look for entrypoint actions since this might require an
lengthy (in the context) install of environments.To install completions, do:bygg--completionsIt will output a line that you can then add to.bashrcor.zshrc.Don't forget to open a new shell instance after you've made changes to the
settings files.Manual stepsAdd the following line to.bashrcor.zshrc:eval"$(.your_bygg_venv/bin/register-python-argcomplete.your_bygg_venv/bin/bygg)"Note for Zsh + argcomplete v2 usersThe recommended setup above uses the argcomplete that is installed with Bygg,
since this version (starting with v3) has proper support for Zsh so that the
action completions will show descriptions. If you for whatever reason need to
use a lower version of argcomplete you need to load the Bash compatibility
layer first, and then the Bygg completions:autoload-Ubashcompinit;bashcompiniteval"$(register-python-argcompletebygg)"Getting a local copyIf you want to try out the examples or even develop Bygg itself, Bygg can be
tried out and worked on without installing it globally:First, clone this repo and cd into it, then execute the commands below.bootstrap.pycreates a virtual environment and installs Bygg into it together
with its dependencies../bootstrap.py
..venv/bin/activateNow you can try out one of the examples:cdexamples/trivial
byggtransformIn the above,byggis the command to executebygg, andtransformis an
action (much like a target in aMakefile). Seeexamples/trivial/Byggfile.pyfor details.The target can be cleaned withbyggtransform--cleanDevelopmentRunning testsWith Bygg's virtual environment activated per above, tests can be run from the root directory:pytestWith the virtual environmentdeactivated, the full test suite can be run withNox. Nox should be installed outside of
the virtual environment since it manages its own virtual environments:pipinstall--user--upgradenoxAfter that, run tests withnox