Giter Club home page Giter Club logo

pywinwrap's Introduction

pywinwrap

Pywinwrap is a simple console application to conveniently start a Python console script on Windows. When run, it will look for a Python script in the same directory as itself and with the same name, safe for a different suffix in place of its extension (default is -script.py), and run it as a Python script, delegating all arguments.

This approach is similar to run.exe that comes with setuptools, which unfortunately refused to work for me on some machines. So I wrote my own.

  • Shebang lines (e.g. #!c:\python27\python.exe) with a path to a Python interpreter (e.g. as set by the setuptools Windows installers) are recognized and that particular interpreter is started. If there is no valid shebang line, Python is assumed to be in the path.
  • Shebang detection works for scripts in ANSI, UTF-8, and UTF-16 big and little endian encoding, with or without BOM.
  • Same executable works with 32-bit and 64-bit Python versions.
  • Comes with two UPX-compressed prebuilt versions: one dynamically linked to the Visual C runtime (msvcr100.dll, 6 KB) and a statically-linked version (29 KB) that is a little bigger, but should work anywhere.

Usage

Just rename script and a copy of the executable (<name>-script.py and <name>.exe, respectively) and deploy.

Disclaimer

This is an intentionally simple approach that happens to work very well for my use cases. Some alternatives:

  • A wrapping .bat file. Unfortunately, there doesn't seem to be workaround for the annoying prompt when interrupting a script via Ctrl-C.
  • Adding .py to PATHEXT. That works well, but requires some user cooperation or additional setup.
  • A much more sophisticated approach is described in PEP-397 and implemented here. That seems a bit more invasive, though.

Todo

  • There is no equivalent to setuptools' cli.exe to start GUI scripts yet.
  • Trailing arguments in the shebang line are not supported yet.

pywinwrap's People

Watchers

Jens Weggemann 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.