Environment Manager

Environment Manager

  1. conda
  2. venv
    1. used by:
      1. uv
      2. rye
  3. mamba
  4. poetry
Link to original

Making Packages

Making Packages

  1. Pipenv,
  2. pip-tools,
  3. PDM
  4. Poetry
  5. rye
  6. uv

Pipenv, pip-tools, PDM, or Poetry? : r/Python (reddit.com)

https://github.com/astral-sh/rye/discussions/6#discussioncomment-7454958

rye uses pip-tools and create platform dependent lock file

poetry create platform independent lock file

https://star-history.com/#indygreg/python-build-standalone&pdm-project/pdm&astral-sh/rye&python-poetry/poetry&pypa/hatch&pypa/pipenv&astral-sh/uv&jazzband/pip-tools&pypa/pip&Date

uv is growing to become a full replacement of rye uv is used by rye uv is catching up to poetry in terms of github stars

Link to original

Testing Packages

Testing Packages

python testing for multiple python environment versions

  • tox

python testing

  • pytest
Link to original

Publishing Packages Methods

Publish Location

  • PyPi
  • anaconda

Publishing procedure

Link to original

Diagrams as Code

Diagrams as Code

potential diagrams inmarkdown

Commonmark out of box doesn't seem to support any diagram render capability. Hence everything here is targeting some flavour of markdown.

example of failing to rendering graphviz diagram in github readme due to multi line inside link

![Alt text](“https://g.gravizo.com/svg? digraph G { size =“4,4”; main [shape=box]; main parse [weight=8]; parse execute; main init [style=dotted]; main cleanup; execute { make_string; printf} init make_string; edge [color=red]; main printf [style=bold,label=“100 times”]; make_string [label=“make a string”]; node [shape=box,style=filled,color=“.7 .3 1.0”]; execute compare; } “)

example of rendering the diagram via kroki.io

bash script that generate kroki link from .dot file(can be self hosted)

 
# syntax used here is bash parameter expansion
# https://stackoverflow.com/questions/2013547/assigning-default-values-to-shell-variables-with-a-single-command-in-bash
file="${1:-content/Learn/DevOps/example2.dot}"
cat $file | python -c "import sys; import base64; import zlib; print(base64.urlsafe_b64encode(zlib.compress(sys.stdin.read().encode('utf-8'), 9)).decode('ascii'))" | sed 's/^/ https:\/\/kroki.io\/graphviz\/svg\//'
 

example .dot file of terraform graph

digraph {
compound = "true"
newrank = "true"
subgraph "root" {
  "[root] aws_instance.example"
  [label = "aws_instance.example", shape = "box"]
  "[root] aws_security_group.instance"
  [label = "aws_security_group.instance", shape =a "box"]
  "[root] provider.aws"
  [label = "provider.aws", shape = "diamond"]
  "[root] aws_instance.example" ->
  "[root] aws_security_group.instance"
  "[root] aws_security_group.instance" ->
  "[root] provider.aws"
  "[root] meta.count-boundary (EachMode fixup)" ->
  "[root] aws_instance.example"
  "[root] provider.aws (close)" ->
  "[root] aws_instance.example"
  "[root] root" ->
  "[root] meta.count-boundary (EachMode fixup)"
  "[root] root" ->
  "[root] provider.aws (close)"
  }
}

result

rendered diagram

Link to original

Documenting package

Documenting package

generate doc website for package from docstrings

other options

https://www.reddit.com/r/Python/comments/lohyb/rpython_what_documentation_system_do_you_use_and/

readme standards

https://codingnomads.com/python-101-documentation-readme

Visualizing code

Link to original