Skip to main content

A rocker extension for installing pixi in a container

Project description

cargo_rocker

Continuous Integration Status

Ci Codecov GitHub issues GitHub pull-requests merged GitHub release License Python Pixi Badge

Intro

This a template for creating rocker extensions. It used off-your-rocker as a starting point, and migrated to use pyproject.toml instead of setup.py to help manage the development environment and continuous integration in a modern way using pixi. Pixi is a cross-platform package manager based on the conda ecosystem. It provides a simple and performant way of reproducing a development environment and running user defined tasks and worflows. It more lightweight than docker, but does not provide the same level of isolation or generality.

This has basic setup for

  • pylint
  • ruff
  • black
  • pytest
  • git-lfs
  • basic github actions ci
  • pulling updates from this template
  • codecov
  • pypi upload
  • dependabot

Install

  1. Use github to use this project as a template
  2. Clone the project and run, scripts/update_from_template.sh and then run the scripts/rename_project.sh to rename the project.

If you are using pixi, look at the available tasks in pyproject.toml. If you are new to pixi follow the instructions on the pixi website

Github setup

There are github workflows for CI, codecov and automated pypi publishing in ci.yml and publish.yml.

ci.yml uses pixi tasks to set up the environment matrix and run the various CI tasks. To set up codecov on github, you need to get a CODECOV_TOKEN and add it to your actions secrets.

publish.yml uses pypy-auto-publish to automatically publish to pypi if the package version number changes. You need to add a PYPI_API_TOKEN to your github secrets to enable this.

If you use vscode to attach to your development container it makes it easier to set up specific extensions for each project that don't need to be installed globally.

Development

There are currently two ways of running code. The preferred way is to use pixi to manage your environment and dependencies.

$ cd project

$ pixi run ci
$ pixi run arbitrary_task

Adding Functionality

  1. Rename cargo_rocker/cargo_rocker.py and the class inside to something more appropriate. Use scripts/rename and pass in the new project name.

  2. Update the extension entrypoint in pyproject.toml

    [project.entry-points."rocker.extensions"]

    cargo_rocker = "cargo_rocker.cargo_rocker:CargoRocker"

    e.g.: lazygit = "lazygit_rocker.lazygit_rocker:LazygitExtension"

  3. Update the get_name() function in the extension class. e.g. Updating the name to lazygit would mean that it would be activated by passing --lazygit to rocker

  4. Add/update the docker snippets in the templates folder. Officially the extension is supposed to be .Dockerfile.em to indicate it's passed to the empy library, but I have left them as .Dockerfile as I get Dockerfile highlighting out of the box that way.

  5. Develop your extension. I find that using pip install -e . and running the extension with rocker on my host system is the easiest way to get started.

    rocker --lazygit ubuntu:22.04
    
    #check that everything works as expected
    

Troubleshooting

The main pixi tasks are related to CI. Github actions runs the pixi task "ci". The CI is mostly likey to fail from a lockfile mismatch. Use pixi run fix to fix any lockfile related problems.

vscode tasks

There are two core tasks.

  1. set <cfg> from active file

    This sets <cfg> to the currently opened file in the editor

  2. run <cfg>

    This runs python with the file set in <cfg>

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cargo_rocker-0.0.2.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

cargo_rocker-0.0.2-py2.py3-none-any.whl (5.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file cargo_rocker-0.0.2.tar.gz.

File metadata

  • Download URL: cargo_rocker-0.0.2.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.10

File hashes

Hashes for cargo_rocker-0.0.2.tar.gz
Algorithm Hash digest
SHA256 187cb9254fdb33aa608b111adf074601e820b06507a1c43d57259c009baa086e
MD5 fd67e869cf031c0cf6bc1f1800afab8a
BLAKE2b-256 56cfceaf9fdd7d0f7fd52561bca90b9f56795f7456f07013c688481f0552405a

See more details on using hashes here.

File details

Details for the file cargo_rocker-0.0.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for cargo_rocker-0.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c18062f15a2a024cd1900d8e7b07460ba7c7fe6cb5aaeb373d7bbc836bc0aa1a
MD5 c2eb8246a9f08e1f48a782b88a157b14
BLAKE2b-256 78f62a55ca9602ff4e0d45762fc03a373b9107d86ca0ba7ee799f74497f953a6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page