Skip to main content

Some tools/functions/snippets used across projects.ions.

Project description

mypythontools

Python versions PyPI version Language grade: Python Documentation Status License: MIT codecov

Some tools/functions/snippets used across projects.

Links

Official documentation - readthedocs

Official repo - github

It's called mypythontools, but it's also made for you...

Usually used from IDE. Used paths are infered and things like sphinx rst docs generation, building application with pyinstaller or deploying to Pypi is matter of calling one function, or clicking one button (e.g. Vs code task).

Many projects - one codebase.

If you are not sure whether structure of your app will work with this code, check project-starter on github in content folder.

Paths are infered, but if you have atypical structure or have more projects in cwd, use mypythontools.misc.set_paths().

Modules

  • build
  • deploy
  • misc
  • pyvueeel (for applications build with eel and vue)
  • utils (various functions callable from one push_pipeline function)

Check modules help with examples.

Installation

Python >=3.6 (Python 2 is not supported).

Install just with

pip install mypythontools

Content

There are some other things that are not installed via pip in mypythontools library.

project-starter

Project scaffolding fast and easy.

Download project-starter from (github)[https://github.com/Malachov/mypythontools/tree/master/content/project-starter] (You may need to download all mypythontools repository in zip)

And start developing.

In your IDE do bulk renaming across files and replace SET_YOUR_APP_NAME with name of your app / library.

This starter is for vue-eel applications (desktop as well as web) but also for python libraries that will be stored on Pypi.

Used as a python library

If it's python library, delete gui folder.

Used as an application It can be opened as web page from explorer, or it can be opened as standalone desktop application (looks similar to electron and require chrome or chromium on the background).

If it's app with gui, delete setup.py, __init__.py and remove Installation and Modules from README. Also from assets delete mdi.css if not using icons and formulate.css if not using vue formulate. In package.json uncomment library you will be using.

Install used python libraries via pip install -r requirements.txt and install JS libraries as well with npm install in folder where package.json is.

To run an app in develop mode, you have to run both frontent as well as python. Run frontent with debugging app.py (do not run, just debug). Then run frontend with npm run serve in gui folder (or use Task explorer if using VS Code). Open your favourite browser and open http://localhost:8080.

It's recommended to use Vue.js devtools extension where you can see what component is on cursor, edit props values or see list of all used mutations.

In opened app, there is a little help button where there is simple overview about how to develop with these tools.

Delete is faster than write, so there is many working examples like for example plot, various formating (flex row, flex column), settings panel, function call from python to js and vice versa or automatic alerting from python. If you want to see how some example is working, just use ctrl + F in IDE or check components for it's props.

This is how the example looks like

project-starter-gui

For a desktop version where user does not have python installed, you have to build it first. Use mypython build module (trigger with tasks button).

Docs It includes docs structure for sphinx docs generations from docstrings. Edit first few lines in conf.py, index.rst, navi.html and if you want, add static files like logo to _static.

Usually used with readthedocs free hosting that trigger deploy automatically after pushing to master. Because of correct relative redirecting in index.rst and navi.html use for readthedocs /path/ before relative link to ohter module.

It's also necassary to generate other modules rst files for other pages but it's if using push_script.py as CI/CD (see below), it's generated automatically via apidoc.

It's recommended to use with sphinx-alabaster-css (see below).

CI/CD Project include .travis.yml for Travis CI, but it's not recommended to use it. There is file push_script.py in folder utils which for my use case is better (faster) than travis and can do most of what you want from CI like run pipeline - running tests / generate docs / increment version / push to github / push to pypi.

You can delete .travis.yml. If you want to generate test coverage badge (usually from travis), you can use github actions yml file for pushing codecov coverage file (without token).

Check utils module for more informations.

IDE files It also include some default project specific settings for VS Code. You can also delete it.

If developing py - vue - eel app this is the recommended way, but if you want to build just what is necassary from scratch, you can use this tutorial readthedocs.

requirements

Install many libraries at once (no need for Anaconda). Download requirements.txt file from (github)[https://github.com/Malachov/mypythontools/tree/master/content/requirements] and in that folder use

pip install -r requirements.txt

It's good for python libraries that other users with different versions of libraries will use. If not standalone application where freezing into virtual env is good idea - here is possible to use this requirements with using --upgrade from time to time to be sure that your library will be working for up to date version of dependencies.

sphinx-alabaster-css

It's good idea to generate documentation from code. If you are useing sphinx and alabaster theme, you can use this css file for formating.

Tested on readthedocs hosting (recommended).

CSS are served from github and it's possible to change on one place and edit how all projects docs look like at once.

Just add this to sphinx conf.py

html_css_files = [
    "https://malachov.github.io/readthedocs-sphinx-alabaster-css/custom.css",
]

Also of course if you want you can download it and use locally from project if you need.

Result should look like this

sphinx-alabaster-css

Tasks

There are VS Code tasks examples in utils and build module, but here is small tutorial how to use it. Run command Tasks: Open User Tasks, add tasks from github/content/tasks or if have no task yet, you can copy / paste all.

Install extension Task Explorer

On root copy folder utils from content/tasks

You are ready to go. You should see something like this

tasks

You can do CI / CD pipeline or Build app with one click now.

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

mypythontools-0.0.40.tar.gz (24.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mypythontools-0.0.40-py3-none-any.whl (25.9 kB view details)

Uploaded Python 3

File details

Details for the file mypythontools-0.0.40.tar.gz.

File metadata

  • Download URL: mypythontools-0.0.40.tar.gz
  • Upload date:
  • Size: 24.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.2

File hashes

Hashes for mypythontools-0.0.40.tar.gz
Algorithm Hash digest
SHA256 4535e785572e9ee51e43304f6f840bb1352629e3a19c1b0fcfbee9c0af570c7a
MD5 49559b49ff2cbe9cd0130147d92dbe57
BLAKE2b-256 d27a6ad19c6e642fee237588c33246d8a9abc457fa466968fd8d257e05b1511f

See more details on using hashes here.

File details

Details for the file mypythontools-0.0.40-py3-none-any.whl.

File metadata

  • Download URL: mypythontools-0.0.40-py3-none-any.whl
  • Upload date:
  • Size: 25.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.2

File hashes

Hashes for mypythontools-0.0.40-py3-none-any.whl
Algorithm Hash digest
SHA256 da0d8b9100ab0adf2530b755236eacaf6e436ca1d11bad71545366e0e6e7cf99
MD5 47f1e90a565e689c6a7dea34fcf5aacc
BLAKE2b-256 13e1f045016dffeb139360203463fffa63a708cd928176e3cc31b7b0d5de839b

See more details on using hashes here.

Supported by

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