But grepping and piping could work I assume? On Tue, Sep 20, 2016 at 2:41 AM Chris Angelico <ros...@gmail.com> wrote:
> On Tue, Sep 20, 2016 at 9:27 AM, Xavier Combelle > <xavier.combe...@gmail.com> wrote: > > I find the idea of tracking the dependencies in the script might be a > > good idea. > > However, magically downloading without warning the user is in my point > > of view for sure a bad idea. > > I would far prefer that pip could scan a script to know the dependencies. > > (A little bit like a requirements.txt but inside the script) > > A special comment or docstring would do the job. for example > > > > """ > > pip_requirements: > > - requests >0.0 > > - asyncio > > """" > > > > to run the script it would be at the first time a two step process > > for example: > > > > python3 -m pip --script-dependencies [--user] my_script.py > > python3 my_script.py > > How about this: > > python3 -m pip install -r requirements.txt > python3 my_script.py > > That already works, but the requirements have to be in a separate text > file, not in the .py file itself. If you want a docstring-based > solution, I'd piggy-back it on requirements.txt, and use the same > format (eg if the docstring starts "pip_requirements:", the rest of it > is a requirements.txt file). Downside: Docstrings can be easily parsed > and read *IF* you can successfully import the module. Which you can't, > if you still need all those dependencies. So there would have to be > some kind of import hook that crafts a dummy package with an infinite > number of dummy subpackages, to allow all forms of import to trivially > succeed - "import X", "import X.Y", "from X.Y import Z", etc. This may > well be more hassle than it's worth. > > ChrisA > _______________________________________________ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ >
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/