Commit graph

24 commits

Author SHA1 Message Date
Vladimír Čunát
862900e42e mass-replace deprecated usage of find -perm (Fixes #9044)
sed 's|-perm +0|-perm /0|g'
It's a mass-rebuild due to usage in stdenv's default setup hooks.
2015-07-30 10:30:17 +02:00
aszlig
b028c14256
python-wrapper: Fix variable name for sed expr.
Regression introduced by 5f55788531.

The commit not only changes documentation, but also changed a few
variable names. One of them is $i which now is $f and it contains the
name of the file to wrap.

This was accidentally found by @Profpatsch (thanks!) who found himself
getting the basename of the last patch file to end up in sys.argv[0].
The reason for this is that $i is used in the for loop of the generic
patchPhase and thus is reused later when the Python file is to be
wrapped.

I have also added a small comment noting about this, to be sure that
this won't accidentally occur the next time someone changes variable
names.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
2015-07-07 18:25:10 +02:00
Allen Nelson
6bb2e47abf using makeWrapperArgs instead of setEnvVars 2015-05-24 10:21:33 -05:00
Allen Nelson
06ff4af597 Adding documentation to wrap.sh, added ability to retain any desired environment variables. 2015-05-24 10:21:33 -05:00
Allen Nelson
5f55788531 adding docs to python wrap.sh 2015-05-24 04:55:24 -05:00
aszlig
311aa5d8d9
python-wrapper: Handle strings at the beginning.
This should fix #7366 for now, but using the (IMHO) pragmatic approach
of extending the sed expression to recognize strings.

However, this approach is obviously not parsing the full AST, nor does
it wrap Python itself (as pointed out by @spwhitt in #7366) but tries to
match Python strings as best as possible without getting TOO unreadable.

We also use a little bit of Nix to help generating the SED expression,
because doing the whole quote matching block over and over again would
be quite repetitious and error-prone to change. The reason why I'm using
imap here is that we need to have unique labels to avoid jumping into
the wrong branch.

So the new expression is not only able to match continous regions of
triple-quoted strings, but also regions with only one quote character
(even with escaped inner quotes) and empty strings.

However, what it doesn't correctly recognize is something like this:

"string1" "string2" "multi
line
string"

Which is very unlikely that we'll find something like this in the wild.
Of course, we could handle it as well, but it would mean that we need to
substitute the current line into hold space until we're finished parsing
the strings, branch off to another label where we match multiline
strings of all sorts and swap hold/pattern space and finally print the
result. So to summarize: The SED expression would be 3 to 4 times bigger
than now and we gain very little from that.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
2015-04-14 07:13:15 +02:00
Domen Kožar
0fd3db4ba1 fix #6548 2015-03-07 22:31:40 +01:00
Michael Raskin
76f4eb5f93 Revert "python-wrapper: fix wrapped argv[0] w/o sed, maybe"
This reverts commit a6dd9bd0cb.
2014-09-02 20:45:41 +04:00
tv@shackspace.de
a6dd9bd0cb python-wrapper: fix wrapped argv[0] w/o sed, maybe 2014-09-02 01:31:49 +04:00
aszlig
21a2f99dd3
python-wrapper: Fix handling of line breaks.
Not really critical for anything we have in <nixpkgs> I guess, but
skipping lines three times really was a workaround and we're better off
just appending the lines ending with backslash to the pattern space so
we can accumulate all the crap until the last line of crap (crap, that
is "broken lines").

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
2014-07-29 06:53:17 +02:00
aszlig
ff15c31c37
python-wrapper: Fix handling __future__ imports.
The bazaar package is still broken even with 5f01cc7, because __future__
imports need to be the first imports before anything else. So this time
I'm going to make the sed expression with explicit branching so we can
properly match all the occasions we want to skip and insert the line
modifying sys.argv[0] only _once_ and leave the command block after
that one substitution. So no ugly swaps between hold and pattern space.

The label which is resonsible for not escaping the command block is "r"
and we jump to it as long as we need to skip something from the start of
the file.

While at it, I'm not only skipping every line with __future__ in it but
also backslashes at the end of the line, so for example:

```python
from __future__ import shiny_feature1, \
                       shiny_feature2, \
                       shiny_feature3
```

... will now be properly skipped as well.

Tested against bazaar and nixops.

Thanks to @edolstra for reporting this.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
2014-07-29 06:40:39 +02:00
aszlig
5f01cc70d3
python-wrapper: Fix fixup for wrapped argv[0].
Fixes issues introduced by 24ef871e6a.

The problem here is that "import sys; sys.argv[0] = ..." is just
appended after the first "#!", which in turn breaks things such as
encoding specifications. A second problem - although not very common -
is when there's another #! within the script.

This should take care of both cases.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
2014-07-28 04:18:21 +02:00
Christian Theune
24ef871e6a python: fix argv[0] for wrapped console_scripts.
Previously programs would see '.<program>-wrapped' as their program name. This is a workaround
but should be reasonably safe and reliable.
2014-07-27 13:23:15 +02:00
Domen Kozar
649e7d6fdb python wrap.sh: wrap pypy and python shebangs 2014-03-07 16:50:46 +01:00
Domen Kozar
fedd018d93 fix pypy and pypyPackages 2014-03-07 14:34:06 +01:00
Domen Kozar
7458f29dc9 don't wrap scripts in EGG-INFO/scripts since they are called from python 2013-07-29 19:31:58 +02:00
Eelco Dolstra
5bb548d2e4 Merge remote-tracking branch 'origin/master' into stdenv-updates 2013-01-17 14:19:14 +01:00
Florian Friesdorf
24d48d9170 don't put propagated recursivePthLoader into pth file, #257 2013-01-11 18:04:27 +01:00
Eelco Dolstra
ab3eeabfed Rename buildNativeInputs -> nativeBuildInputs
Likewise for propagatedBuildNativeInputs, etc.  "buildNativeInputs"
sounds like an imperative rather than a noun phrase.
2012-12-28 19:20:09 +01:00
Florian Friesdorf
f8d3671629 fix pth files 2012-07-22 02:08:00 +02:00
Florian Friesdorf
a40da09b44 python: create pth files for python build inputs (propagate/native or not) 2012-07-21 01:55:50 +02:00
Eelco Dolstra
353d450867 * wrapPythonPrograms: don't hard-code the Python library prefix.
svn path=/nixpkgs/branches/modular-python/; revision=26594
2011-03-29 15:19:59 +00:00
Eelco Dolstra
968496e69b * wrapPythonPrograms: rewrite the common "#! .../env python" idiom to
"#! .../python".

svn path=/nixpkgs/branches/modular-python/; revision=26583
2011-03-28 17:19:27 +00:00
Eelco Dolstra
47adaa80e3 * Move the wrapPythonPrograms function into a separate setup hook
(wrapPython).

svn path=/nixpkgs/branches/modular-python/; revision=26580
2011-03-28 16:33:33 +00:00