Skip to content

zookinheimer/Lunch

Repository files navigation

Lunch

@zookinheimer's masterpiece. Gonna fill in the blanks and/or add tooling.

@pythoninthegrass

Setup

Usage

lunch.py

# install tkinter library on macos
brew install python-tk

# asdf
asdf install python 3.9

# asdf local version of python
asdf local 3.9.10

# run app in poetry
poetry env use 3.9.10
poetry shell
python lunch.py

Poetry

# Install
curl -sSL https://install.python-poetry.org | $(which python3) -

# Change config
poetry config virtualenvs.in-project true           # .venv in `pwd`
poetry config experimental.new-installer false      # fixes JSONDecodeError on Python3.10

# Activate virtual environment (venv)
poetry shell

# Deactivate venv
exit  # ctrl-d

# Install multiple libraries
poetry add google-auth google-api-python-client

# Initialize existing project
poetry init

# Run script and exit environment
poetry run python your_script.py

# Install from requirements.txt
poetry add `cat requirements.txt`

# Update dependencies
poetry update

# Remove library
poetry remove google-auth

# Generate requirements.txt
poetry export -f requirements.txt --output requirements.txt --without-hashes

Docker

# clean build (remove `--no-cache` for speed)
docker-compose build --no-cache --parallel

# start container
docker-compose up --remove-orphans -d

# exec into container
docker attach lunch

# run command inside container
python hello.py

# destroy container
docker-compose down

Docker Troubleshooting

  • Watch logs in real-time: docker-compose logs -tf --tail="50" hello
  • Check exit code
    $ docker-compose ps
    Name                          Command               State    Ports
    ------------------------------------------------------------------------------
    docker_python      python manage.py runserver ...   Exit 0

Packaging

Local test pypiserver and official repo.

NOTE
Confirm repo name is available before uploading to PyPi.

## BOTH
# build package
poetry build

## DOCKER
# setup mount directory
mkdir -p auth

# use passlib to setup .htpasswd
htpasswd -sc auth/.htpasswd someuser

# run local pypi
docker run -p 80:8080 -v $(pwd)/auth/:/data/auth pypiserver/pypiserver:latest -P /data/auth/.htpasswd -a update,download,list /data/packages

# configure repo
poetry config repositories.test http://localhost

# "upload" package to docker
poetry publish -r test

## PYPI
# "upload" package to pypi (build switch is optional)
export API_TOKEN=super_secret_api_key
poetry publish -u __token__ -p $API_TOKEN --build

TODO

  • Add README.md
  • PR
  • Clone
  • QA
    • Excluded lunch.db in .gitignore
      • Will pollute original DB with future commits
      • Possibly add a separate shell script to populate robust sqlite DB
    • macOS 12.1
      • Changed root.geometry to `"500x100"
      • List All button doesn't scroll down list
  • Document
  • Convert to PySimpleGUI
  • Extend
    • Fancy category
    • Images
    • Menus
    • API calls to Yelp, Google, etc.
    • Faithful tkinter translation via
    • Tinder swipe right/left mechanic hehehe

Further Reading

Call reference - PySimpleGUI

Python Poetry, finally easy build and deploy packages | by Jose Alberto Torres Agüera | Lambda Automotive | Medium

Python 101: Developing Package with Poetry | by Julio Anthony Leonard | Bootcampers | Medium

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published