Giter Club home page Giter Club logo

dwarf_copier's Introduction

Github PyPi Python CI

Note: some badges above will not work until Github CI has been set up and the app is published in Pypi

Introduction

The dwarf_copier project gives a straightforward way to extract image files from a Dwarf II smart telescope onto a PC for further processing (e.g. using Siril) or as a backup.

Development Tools

There are multiple good Python IDE, but I'm would suggest using vscode with at least these plugins:

  • Python to add python language support
  • Mypy for type checking
  • ruff formatting and linting your code
  • even-better-toml for a better TOML file support (and poetry configuration file is a toml file)
  • textual validates Textual's CSS

Poetry is used to handle dependencies:

  • poetry add to add a new dependencies
  • poetry install to create a virtualenv with all needed libraries to run your app
  • poetry shell to enter your virtualenv and run your app or tests
  • poetry build to create a distributable binary package of your app

Run the tests

To run the tests, you need to be in the virtualenv then just run tox or pytest:

# init your virtualenv if it is not
$ poetry install

# enter your virtualenv
$ poetry shell

# note that your shell prompt is updated once you are in a virtualenv
(dwarf_copier-py3.10) $ pytest
====================================== test session starts ======================================
platform linux -- Python 3.10.13, pytest-7.2.0, pluggy-1.0.0
rootdir: /home/kupuguy/dwarf_copier
plugins: dotenv-0.5.2, cov-4.0.0
collected 3 items

tests/test_cli.py ...                                                                     [ 66%]
tests/test_user.py .                                                                      [100%]

======================================= 3 passed in 0.07s =======================================

Build your app

You can use Poetry to build the app and get a .whl

$ poetry build
Building cool-project (0.1.0)
  - Building sdist
  - Built cool_project-0.1.0.tar.gz
  - Building wheel
  - Built cool_project-0.1.0-py3-none-any.whl

$ ls -l dist
total 20
-rw-r--r-- 1 seb users 8569 17 oct.  11:12 cool_project-0.1.0-py3-none-any.whl
-rw-r--r-- 1 seb users 7484 17 oct.  11:12 cool_project-0.1.0.tar.gz

Publish your app

You can use Poetry to publish your app to PyPI

$ poetry publish

By default, Github Actions are configured to

  • build your app and run your unit tests with coverage on every push
  • build the wheel package and upload it to Pypi on every tag

Note: to allow Github CI to publish on PyPI, you need to create a token and add it to your project settings, the name of the token should be PYPI_TOKEN

I personnally use this command to bump the version using poetry, create the associated git tag and push to Github:

# for a patch bump
$ poetry version patch && git commit -a -m '๐Ÿ”– New release' && git tag -f $(poetry version -s) && git push --tags
# for a minor bump
$ poetry version minor && git commit -a -m '๐Ÿ”– New release' && git tag -f $(poetry version -s) && git push --tags
# for a major bump
$ poetry version major && git commit -a -m '๐Ÿ”– New release' && git tag -f $(poetry version -s) && git push --tags

How to install your app

Install from the sources

$ pip3 install poetry
$ pip3 install git+https://github.com/jdoe/cool-project
$ cool-command --help

Install from PyPI if you published it

$ pip3 install cool-project
$ cool-command --help

TODO - clean this up!

Start a new project from scratch

# create the new project folder
$ mkdir cool-project && cd cool-project

# create a README
$ cat << EOF >> README.md
Here is my cool project
EOF

# configure excluded files
$ cat << EOF >> .gitignore
# Generated files
__pycache__
*.pyc
/.pytest_cache
/.coverage*
/dist
# IDE configuration
/.vscode/*
!/.vscode/settings.json
EOF

# init the root python module
$ mkdir cool_project
$ cat << EOF >> cool_project/__init__.py
from importlib.metadata import version

__version__ = version(__name__)
EOF

# create the first commit
$ git init
$ git add .
$ git commit -m "๐Ÿš€ First release"

# init the poetry pyproject.toml
$ poetry init -n

# configure poetry to create the virtualenv dir in the project folder
$ cat << EOF >> poetry.toml
[virtualenvs]
in-project = true
EOF

# create the virtualenv
$ poetry shell

# add some runtime dependencies
$ poetry add colorama

# add some development dependencies
$ poetry add --group dev black isort pylint pytest pytest-cov pytest-dotenv

# install your package
$ poetry install

# test that your app is installed in your virtualenv
$ python -c 'import cool_project; print(cool_project.__version__)'

Snippet to add an entrypoint

[tool.poetry.scripts]
mycommand = 'cool_project.cli:run'

dwarf_copier's People

Contributors

kupuguy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.