How to specify arguments for Python when building script with buildout?
Here's my buildout.cfg:
[buildout]
parts = python
develop = .
[python]
recipe = zc.recipe.egg:scripts
eggs = myproject
And setup.py:
from setuptools import setup, find_packages
setup(
name = 'myproject',
packages = find_packages(),
entry_points = """
[console_scripts]
myscript = myproject:main
""",
)
I get the following shebang with this configuration:
$ pip install .
$ head -n1 /usr/local/bin/myscript
#!/usr/bin/python
And I want this:
#!/usr/bin/python -u
How to do it? I tried adding arguments = -u
and interpreter = python -u
to buildout.cfg
. It didn't work.
You can force unbuffered I/O from within your Python script by re-opening stdin or stdout using os.fdopen on the filenumber:
You can then reassign sys.stdout if you want to use other modules or build-ins that use stdout or stdin:
Also see unbuffered stdout in python (as in python -u) from within the program