packaging.python.org icon indicating copy to clipboard operation
packaging.python.org copied to clipboard

Add a tutorial/guide for creating a command line tool

Open bhrutledge opened this issue 5 years ago • 8 comments

Related to #614.

As a companion to the packaging tutorial and installing command line tools guide, it'd be nice to have a walkthrough of transforming a command-line utility from running python my_utility.py in the script's directory to running my_utility in an arbitrary location (maybe via pipx?).

bhrutledge avatar May 06 '19 21:05 bhrutledge

@theacodes Something that occurred to me while talking to Brian about this is that we have a potentially interesting opportunity here around the following structure:

  • how to package a utility to make it installable with pipx (tutorial, perhaps?)
  • how to use briefcase to take a utility installable with pipx, and create platform native installers for it

(cc @freakboy3742)

ncoghlan avatar May 08 '19 17:05 ncoghlan

I'd love guides along those two lines.

On Wed, May 8, 2019, 10:27 AM Nick Coghlan [email protected] wrote:

@theacodes https://github.com/theacodes Something that occurred to me while talking to Brian about this is that we have a potentially interesting opportunity here around the following structure:

  • how to package a utility to make it installable with pipx (tutorial, perhaps?)
  • how to use briefcase to take a utility installable with pipx, and create platform native installers for it

(cc @freakboy3742 https://github.com/freakboy3742)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pypa/packaging.python.org/issues/615#issuecomment-490576644, or mute the thread https://github.com/notifications/unsubscribe-auth/AAB5I4ZFQWUHZX4FRV47R3DPUMEPDANCNFSM4HLDRCKQ .

theacodes avatar May 08 '19 17:05 theacodes

Briefcase doesn't currently have any tooling for supporting command line scripts - it's focused on packaging traditional "app" bundles (i.e., icons on a launcher that create a window). However, I don't have any objection to adding a mode for adding command line scripts.

freakboy3742 avatar May 08 '19 19:05 freakboy3742

I did what I think is the minimum amount of work to convert a standalone script to an installable utility in the first release of a personal utility. The next release added a README and LICENSE.

I know this doesn't follow a lot of best practices (package instead of module, __main__, tests, ...), but I was aiming for the shortest path to pipx install.

bhrutledge avatar May 08 '19 20:05 bhrutledge

A guide on PyApp usage, which emerged just recently but is already quite successful, should be useful, too.

chrysle avatar May 26 '24 07:05 chrysle

Updating the status of Briefcase on this: we are nearing completion of a PR that will add support for packaging command line apps. We anticipate this will be merged very soon, with a release soon after (probably by mid June).

freakboy3742 avatar May 27 '24 00:05 freakboy3742

Happy to package that into a guide once it's ready!

chrysle avatar May 27 '24 12:05 chrysle