https://github.com/dwighthubbard/python_shebang
Python script similar to /usr/bin/env but allows specifying the interpreter and modules required
https://github.com/dwighthubbard/python_shebang
Last synced: 5 months ago
JSON representation
Python script similar to /usr/bin/env but allows specifying the interpreter and modules required
- Host: GitHub
- URL: https://github.com/dwighthubbard/python_shebang
- Owner: dwighthubbard
- License: apache-2.0
- Created: 2014-04-17T19:42:42.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-11-10T23:26:28.000Z (over 9 years ago)
- Last Synced: 2024-11-20T11:56:24.777Z (7 months ago)
- Language: Python
- Size: 182 KB
- Stars: 1
- Watchers: 3
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.txt
- License: LICENSE
Awesome Lists containing this project
README
python_shebang Description
==========================
This package provides a command that can be run from /usr/bin/env on the
shebang line of a script that will find an appropriate python interpreter
to run it.Unlike plain /usr/bin/env this script allows specifying the version of python
and python modules that are required.Supported Operating Systems
===========================
This script is designed to operate on Unix operating systems. It is of no
value on Windows which does not use shebang.Dependencies
============
python_shebang is written to be able to run under any python version 2.6 or
higher using only modules in the python standard library.Examples
========Here is a shebang line that will run the script with a python2.6 interpreter
that has both the foo and bar modules:```#!/usr/bin/env python_shebang version:2.6 module:foo module:bar```
This shebang line will run the script with a python 3 interpreter that has
the paramiko module:```#!/usr/bin/env python_shebang version:3 module:paramiko```
Running the command directly will give a python shell that meets the
requirements (the asyncio module was added in python 3.4):```
$ python_shebang module:asyncio
Python 3.4.0 (v3.4.0:04f714765c13, Mar 15 2014, 23:02:41)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
```If a compatible interpreter cannot be found it will generate an exception (the
asyncio module was added in python 3.4)```
$ python_shebang module:asyncio version:3.3
Traceback (most recent call last):
File "/usr/bin/python_shebang", line 173, in
version, modules, python_interpreters=python_interpreters
File "/usr/bin/python_shebang", line 139, in __search_for_interpreters
raise PythonNotFound('No usable python interpreters found')
__main__.PythonNotFound: No usable python interpreters found
```