Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mapproxy-util is being executed as a python script #424

Closed
CMCDragonkai opened this issue Oct 2, 2019 · 4 comments
Closed

mapproxy-util is being executed as a python script #424

CMCDragonkai opened this issue Oct 2, 2019 · 4 comments

Comments

@CMCDragonkai
Copy link

Hi, we are packaging mapproxy for NixOS: NixOS/nixpkgs#68628. And we have hit some problems.

The main problem is that Nix will wrap executables as shell scripts in order to create an isolated environment. Once we execute mapproxy-util serve-develop mapproxy.yaml we get a syntax error.

»» ~/Projects/mapproxy/mymapproxy
 ♖ ../result/bin/mapproxy-util serve-develop mapproxy.yaml
[2019-10-02 13:22:18,621] mapproxy.config - INFO - reading: /home/cmcdragonkai/Projects/mapproxy/mymapproxy/mapproxy.yaml
[info]  * Running on http://127.0.0.1:8080/ (Press CTRL+C to quit)
[info]  * Restarting with reloader
  File "/nix/store/bfvw32p8c61jajjm7a8z98xbk1n6qiwz-python3.7-MapProxy-1.12.0/bin/mapproxy-util", line 2
    export PATH='/nix/store/kimimvhimclyfzlncpg36zjni3wn70nq-python3-3.7.3/bin:/nix/store/bfvw32p8c61jajjm7a8z98xbk1n6qiwz-python3.7-MapProxy-1.12.0/bin:/nix/store/rpayih9fb4ms2wjvmyn6kp7kmsizim49-python3.7-setuptools-40.8.0/bin:/nix/store/kp0g7z5h4kr6gx71jf9q0a9322p4jr5p-python3.7-numpy-1.16.2/bin:/nix/store/7vgnq00rxw9xh03920apdyj4ibgsmrix-gdal-2.4.0/bin'${PATH:+':'}$PATH
              ^
SyntaxError: invalid syntax

I suspect that this is occurring because mapproxy thinkgs that mapproxy-util is a python script. And from Nix's perspective these are arbitrary executables. So they should just be executed like any other executable without needing to call it again from python.

What we would do in Nixpkgs is to basically hotpatch the package so that it doesn't bother trying to call the script as a python script. This is similar to what we had to do for dvc: https://github.com/NixOS/nixpkgs/pull/54530/files#diff-551883c582fc9bc6f5388f662439af05

What I'd like to know is where your this patch is best applied? Where exactly in the program are you recalling mapproxy-util script like a Python script.

@Rakesh4G
Copy link

Hi all,
This issue seems to be fixed we add the following change in mapproxy/util/ext/serving.py.
replace "args = [sys.executable] + sys.argv" with
"args = sys.argv"

@olt
Copy link
Member

olt commented Nov 28, 2019

This likely will break the reloading on other systems.

@CMCDragonkai
Copy link
Author

CMCDragonkai commented Nov 28, 2019 via email

@CMCDragonkai
Copy link
Author

Looks like this is done for Nixpkgs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants