Skip to main content

Conscript console scripts in your own Swiss Army Knife.

Project description

Conscript: console scripts in your own Swiss Army Knife.

PyPI Version License Supported Pythons CI

Conscript provides a console script you can use to conveniently expose all other console scripts in a virtual environment. In a traditional virtual environment this is of little use. In a zipapp, it gives you capabilities similar to BusyBox.

Use

To create a BusyBox, simply add conscript to your dependencies and set your application main entrypoint to the conscript console script.

Examples

Examples are probably the best way to demonstrate the utility of Conscript. Both Pex and Shiv are popular tools for creating zipapps with third party dependencies; so they lead to concise examples.

Pex

  1. Create the BusyBox PEX zipapp:
    $ pex cowsay fortune conscript --script conscript --output-file speak
    
  2. Examine the available embedded apps:
    $ ./speak -h
    usage: speak [-h] [PROGRAM]
    
    A speak busy box.
    
    positional arguments:
      PROGRAM     The program to execute.
    
                  The following programs are available:
                  + cowsay
                  + fortune
    
    optional arguments:
      -h, --help  Show this help message and exit.
    
  3. Run an embedded app:
    $ ./speak cowsay "Conscript is my Swiss Army Knife!"
      _________________________________
    | Conscript is my Swiss Army Knife! |
      =================================
                                     \
                                      \
                                        ^__^
                                        (oo)\_______
                                        (__)\       )\/\
                                            ||----w |
                                            ||     ||
    
  4. Or another one:
    $ ./speak fortune -h
    Usage: speak [OPTIONS] [fortune_file]
    
    Options:
      -h, --help     show this help message and exit
      -V, --version  Show version and exit.
    
    If fortune_file is omitted, fortune looks at the FORTUNE_FILE environment
    variable for the path.
    $ ./speak fortune /usr/share/fortune/science
    Nondeterminism means never having to say you are wrong.
    
  5. Target an embedded app via a symlink:
    $ ln -s speak cowsay
    $ ./cowsay Nifty.
      ______
    | Nifty. |
      ======
          \
           \
             ^__^
             (oo)\_______
             (__)\       )\/\
                 ||----w |
                 ||     ||
    

Shiv

The capabilities exposed by Conscript are the same as in the Pex example, so this example is abbreviated to the basics. The primary difference is that Shiv does not fully isolate requested dependencies in the zipapp from incidental dependencies and so we see more available console scripts than in the Pex case.

  1. Create the BusyBox shiv zipapp:
    $ shiv cowsay fortune conscript --python '/usr/bin/env python' --console-script conscript --output-file say
    Collecting cowsay
      Using cached cowsay-4.0-py2.py3-none-any.whl (24 kB)
    Collecting fortune
      Using cached fortune-1.1.0-py2.py3-none-any.whl (5.9 kB)
    Collecting conscript
      Using cached conscript-0.1.1-py2.py3-none-any.whl (7.5 kB)
    Collecting grizzled-python>=1.0
      Using cached grizzled_python-2.2.0-py2.py3-none-any.whl (36 kB)
    Installing collected packages: grizzled-python, fortune, cowsay, conscript
    Successfully installed conscript-0.1.1 cowsay-4.0 fortune-1.1.0 grizzled-python-2.2.0
    
  2. Use it:
    $ ./say -h
    usage: say [-h] [PROGRAM]
    
    A say busy box.
    
    positional arguments:
      PROGRAM     The program to execute.
    
                  The following programs are available:
                  + cowsay
                  + easy_install
                  + easy_install-3.8
                  + fortune
                  + pip
                  + pip3
                  + pip3.8
                  + shiv
                  + shiv-info
    
    optional arguments:
      -h, --help  Show this help message and exit.
    $ ./say cowsay --version
    4.0
    

Project details


Download files

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

Source Distribution

conscript-0.1.6.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

conscript-0.1.6-py2.py3-none-any.whl (9.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file conscript-0.1.6.tar.gz.

File metadata

  • Download URL: conscript-0.1.6.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.1 CPython/3.11.4

File hashes

Hashes for conscript-0.1.6.tar.gz
Algorithm Hash digest
SHA256 b895f680fd7b0a40b7bfb6f05cbcb852f9bc0834de351f8c3f61d902d16529c5
MD5 0d1d505478bc31f7a49c6c25477dec56
BLAKE2b-256 9ce8ebd9b3bbab7c44c3dc08ea4f7d06f750d68abda89ac5f00b032481c51dea

See more details on using hashes here.

File details

Details for the file conscript-0.1.6-py2.py3-none-any.whl.

File metadata

  • Download URL: conscript-0.1.6-py2.py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.1 CPython/3.11.4

File hashes

Hashes for conscript-0.1.6-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 32ad9bd8ec75341291cf38f9c98b76b31b1f554c1a18f114643058d92bd49462
MD5 36423023c3947122109ffbb4718ed022
BLAKE2b-256 a7370730cbeb66bd2747b7dfcb0194f210f751dda2cb859d0dee89c0b2413734

See more details on using hashes here.

Supported by

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