GithubHelp home page GithubHelp logo

gkluoe / cookiecutter-py-mac-tool Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 0.0 38 KB

Template for a basic macOS python tool, with autopkg integration

Python 80.21% Shell 19.79%
python admin macos cookiecutter cookiecutter-template autopkg

cookiecutter-py-mac-tool's Introduction

CookieCutter Py-Mac-Tool

A minimal cookiecutter template for a python tool, with a focus on deployment to macOS.

cookiecutter

Inspired by: cookiecutter-pipproject

Goals

The goal of this template is to provide a quick and simple starting point for macOS admins who want to quickly write, test and release a simple tool, and keep on top of release management after that.

The template provides:

  • Basic skeleton for a python commandline tool
  • Testing with pytest
  • Versioning with bumpversion
  • Scripted release management
  • An autopkg template (the only macOS specific thing about it)

It's deliberately minimal and is supposed to provide a more robust and scalable alternative to just bashing out a few lines one day, and realising you have a sprawling Cthulu of code the next!

Using the template

Clone the template

$ pip install cookiecutter
$ cookiecutter https://github.com/gkluoe/cookiecutter-py-mac-tool.git

You will be asked about your basic info (name, project name, app name, etc.). This info will be used in your new project.

A new directory will be created, matching your chosen app name, and a new local git repository will be initialised in it.

Initialise Git

At this point you'll probably want to make sure you have an empty git repository on a server ready for your new project. If a repository is found at https://github.com/yourusername/projectname, then you'll be asked:

We found a remote git repository which looks like it matches this project.
Do you want to add it as a git remote?

If you answer yes, the remote repository will be added as a git remote, ready for you to push your first commit.

Add some functionality

The file projectname/__init__.py is set up so that you can add some arguments to the process_args() function, and then do something with them in main().

That's really all there is to it!

Add some tests

The template is configured to be used with pytest. Any function named test_*() in any file named test_*.py inside the 'tests' folder will be collected and run as a test.

Included are 2 sample tests, which:

  1. Run your project against pylint (test_lint())
  2. Check that the version number reported by the tool matches the version number in setup.py (test_version())

Run the tests

$ python setup.py test

Make a release

Once you're happy with your functionality, you can make a release.

$ ./release.sh [ major | minor | patch ]

This creates a new tag and commits it locally. You'll then want to push the release to your git server:

$ git push origin [new version]

And then, you probably want to build a package for deployment. The directory autopkg-recipe contains an autopkg recipe which you could either copy to your recipes repo, or use directly, like so:

$ autopkg run --verbose -d autopkg-recipes [project].pkg

You'll end up with a package to install your tool to /usr/local/bin. The tool is a wrapper script which uses the functionality in your __init__.py file.

Contributing

Issues/Pull requests welcome. I'm particularly keen for this documetation to be helpful to newcomers, so suggestions for modifications are really appreciated.

License

Apache licensed.

cookiecutter-py-mac-tool's People

Contributors

asmodehn avatar bmihelac avatar gkluoe avatar ojengwa avatar wdm0006 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.