Python as a tool to download stuff for bootstrapping
This one is practical. I am looking at NaCl SDK download page: https://developers.google.com/native-client/sdk/download "you need Python installed", "download SDK update utility" What makes me sad that update utility is a Python script in a zip file - nacl_sdk.zip which includes shell script and a .bat file for launching this Python script. This makes me kind of sad. You have Python installed. Why can't you just crossplatformly do: mkdir nacl cd nacl python -m urllib get http://commondatastorage.googleapis.com/nativeclient-mirror/nacl/nacl_sdk/up... python update_sdk.py
Le 05/07/2012 21:55, anatoly techtonik a écrit :
This one is practical. I am looking at NaCl SDK download page: https://developers.google.com/native-client/sdk/download
"you need Python installed", "download SDK update utility"
What makes me sad that update utility is a Python script in a zip file - nacl_sdk.zip which includes shell script and a .bat file for launching this Python script.
This makes me kind of sad. You have Python installed. Why can't you just crossplatformly do:
mkdir nacl cd nacl python -m urllib get http://commondatastorage.googleapis.com/nativeclient-mirror/nacl/nacl_sdk/up... python update_sdk.py
Hi, "Sadness" drama aside, what’s your point? Is this a proposal to add a command-line API for urlretrieve()? In that case, +1. (For what my vote is worth.) The use cases are limited (just use the Python API) but they do exist, as you showed. Regards, -- Simon Sapin
2012/7/5 anatoly techtonik <techtonik@gmail.com>:
This makes me kind of sad. You have Python installed. Why can't you just crossplatformly do:
mkdir nacl cd nacl python -m urllib get http://commondatastorage.googleapis.com/nativeclient-mirror/nacl/nacl_sdk/up... python update_sdk.py
I'm sure there is already a way with standard python tools. Something along these lines: python -c "from urllib.request import urlretrieve; urlretrieve('URL', 'update_sdk.zip')" python -m update_sdk.zip The second command will work if the zip file has a __main__.py. Do you think we need other tools? -- Amaury Forgeot d'Arc
On 05.07.2012 22:24, Amaury Forgeot d'Arc wrote:
2012/7/5 anatoly techtonik <techtonik@gmail.com>:
This makes me kind of sad. You have Python installed. Why can't you just crossplatformly do:
mkdir nacl cd nacl python -m urllib get http://commondatastorage.googleapis.com/nativeclient-mirror/nacl/nacl_sdk/up... python update_sdk.py
I'm sure there is already a way with standard python tools. Something along these lines:
python -c "from urllib.request import urlretrieve; urlretrieve('URL', 'update_sdk.zip')" python -m update_sdk.zip
The second command will work if the zip file has a __main__.py. Do you think we need other tools?
The "python -m urllib" (don't think "get" is required) interface certainly looks nice and is similar in style with many of the other __main__ stuff we add to stdlib modules. Georg
On Fri, Jul 6, 2012 at 10:30 PM, Georg Brandl <g.brandl@gmx.net> wrote:
On 05.07.2012 22:24, Amaury Forgeot d'Arc wrote:
2012/7/5 anatoly techtonik <techtonik@gmail.com>:
This makes me kind of sad. You have Python installed. Why can't you just crossplatformly do:
mkdir nacl cd nacl python -m urllib get
http://commondatastorage.googleapis.com/nativeclient-mirror/nacl/nacl_sdk/up... python update_sdk.py
I'm sure there is already a way with standard python tools. Something along these lines:
python -c "from urllib.request import urlretrieve; urlretrieve('URL', 'update_sdk.zip')" python -m update_sdk.zip
The second command will work if the zip file has a __main__.py. Do you think we need other tools?
The "python -m urllib" (don't think "get" is required) interface certainly looks nice and is similar in style with many of the other __main__ stuff we add to stdlib modules.
Here is the implementation of urllib.__main__ module for Python 3 with progress bar. I've left 'get' argument to make it extensible in future with other commands, such as `test`. While working on this code I've also found the regression which would be nice to see fixed at the same time. http://bugs.python.org/issue10836
On 10/15/2012 01:13 PM, anatoly techtonik wrote:
On Fri, Jul 6, 2012 at 10:30 PM, Georg Brandl <g.brandl@gmx.net> wrote:
On 05.07.2012 22:24, Amaury Forgeot d'Arc wrote:
2012/7/5 anatoly techtonik <techtonik@gmail.com>:
This makes me kind of sad. You have Python installed. Why can't you just crossplatformly do:
mkdir nacl cd nacl python -m urllib get
http://commondatastorage.googleapis.com/nativeclient-mirror/nacl/nacl_sdk/up... python update_sdk.py
I'm sure there is already a way with standard python tools. Something along these lines:
python -c "from urllib.request import urlretrieve; urlretrieve('URL', 'update_sdk.zip')" python -m update_sdk.zip
The second command will work if the zip file has a __main__.py. Do you think we need other tools?
The "python -m urllib" (don't think "get" is required) interface certainly looks nice and is similar in style with many of the other __main__ stuff we add to stdlib modules.
Here is the implementation of urllib.__main__ module for Python 3 with progress bar. I've left 'get' argument to make it extensible in future with other commands, such as `test`.
Please don't send patches to the mailing list, open a new tracker issue instead. Georg
On Thu, Jul 5, 2012 at 11:24 PM, Amaury Forgeot d'Arc <amauryfa@gmail.com> wrote:
2012/7/5 anatoly techtonik <techtonik@gmail.com>:
This makes me kind of sad. You have Python installed. Why can't you just crossplatformly do:
mkdir nacl cd nacl python -m urllib get http://commondatastorage.googleapis.com/nativeclient-mirror/nacl/nacl_sdk/up... python update_sdk.py
I'm sure there is already a way with standard python tools. Something along these lines:
python -c "from urllib.request import urlretrieve; urlretrieve('URL', 'update_sdk.zip')" python -m update_sdk.zip
The second command will work if the zip file has a __main__.py. Do you think we need other tools?
Wow! Nice, but still a hack. I doubt many people wouls accept magic files messing in the root dir of the package. The only way it will look good is: python -m update_sdk.zip sdk_update[.py] but I don't know if that's supported. -- anatoly t.
2012/7/10 anatoly techtonik <techtonik@gmail.com>:
Wow! Nice, but still a hack. I doubt many people wouls accept magic files messing in the root dir of the package. The only way it will look good is:
python -m update_sdk.zip sdk_update[.py]
but I don't know if that's supported.
-m does work with zip files (with a __main__.py file) and command line arguments are passed. Or did you expect another kind of support? -- Amaury Forgeot d'Arc
On Tue, Jul 10, 2012 at 5:51 PM, Amaury Forgeot d'Arc <amauryfa@gmail.com> wrote:
2012/7/10 anatoly techtonik <techtonik@gmail.com>:
Wow! Nice, but still a hack. I doubt many people wouls accept magic files messing in the root dir of the package. The only way it will look good is:
python -m update_sdk.zip sdk_update[.py]
but I don't know if that's supported.
-m does work with zip files (with a __main__.py file) and command line arguments are passed. Or did you expect another kind of support?
-m doesn't handle zip files - you just execute them directly: python <script> = source files, bytecode files, directories, zip files (requires a top level __main__.py in the latter two cases) python -m <module> = modules, packages (requires a __main__ submodule for the latter case) The switch is only to tell the interpreter whether you're providing a filesystem path (default) or a Python module name (-m switch). Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia
participants (5)
-
Amaury Forgeot d'Arc
-
anatoly techtonik
-
Georg Brandl
-
Nick Coghlan
-
Simon Sapin