[Nix-dev] Python packages with __future__ imports broken by wrapper?
Jeffrey David Johnson
jefdaj at gmail.com
Thu May 21 18:11:13 CEST 2015
I installed python27Packages.googlecl, and when running `google` it says:
File "/nix/store/1ksk91s0kd1sv2clrkwcvzcmr67smgps-python2.7-googlecl-0.9.14/bin/.google-wrapped", line 45
from __future__ import with_statement
SyntaxError: from __future__ imports must occur at the beginning of the file
Indeed, that file has 44 lines of other stuff first that looks like they were added by a wrapper script:
#!/nix/store/pbi1lgank10fy0xpjckbdpgacqw34dsz-python-2.7.9/bin/python2.7
#
# Copyright (C) 2010 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import sys; sys.argv[0] = 'google'
"""Main function for the Google command line tool, GoogleCL.
This program provides some functionality for a number of Google services from
the command line.
Example usage (omitting the initial "./google"):
# Create a photo album with tags "Vermont" and name "Summer Vacation 2009"
picasa create -n "Summer Vacation 2009" -t Vermont ~/photos/vacation2009/*
# Post photos to an existing album
picasa post -n "Summer Vacation 2008" ~/old_photos/*.jpg
# Download another user's albums whose titles match a regular expression
picasa get --user my.friend.joe --name ".*computer.*" ~/photos/joes_computer
# Delete some posts you accidentally put up
blogger delete -n "Silly post, number [0-9]*"
# Post your latest film endeavor to YouTube
youtube post --category Film --tag "Jane Austen, zombies" ~/final_project.mp4
Some terminology in use:
service: The Google service being accessed (e.g. Picasa, Blogger, YouTube).
task: What the client wants done by the service (e.g. post, get, delete).
"""
from __future__ import with_statement
__author__ = 'tom.h.miller at gmail.com (Tom Miller)'
import glob
import logging
import optparse
I guess we need to move this line below any __future__ statements:
import sys; sys.argv[0] = 'google'
According to https://docs.python.org/2/reference/simple_stmts.html#future
the rest should be OK:
A future statement must appear near the top of the module. The only lines that can appear before a future statement are:
the module docstring (if any),
comments,
blank lines, and
other future statements.
Jeff
More information about the nix-dev
mailing list