As someone who has been coding for 20 years, "magic" is a negative adjective for me. I don't want magic code. I want code that is simple and works in obvious ways. > You can even specify a version number Sorry to be sarcastic here but wow, you mean I can even make sure that my code will not break at an arbitrary point in the future, when my dependency inevitably introduces a breaking change? Fantastic. I understand t…
Magicimport.py: Python code that fetches its dependencies without complaining
11–20 of 49 posts
Re: Magicimport.py: Python code that fetches its dependencies without complaining
#12As someone who has been coding for 20 years, "magic" is a negative adjective for me. I don't want magic code. I want code that is simple and works in obvious ways. > You can even specify a version number Sorry to be sarcastic here but wow, you mean I can even make sure that my code will not break at an arbitrary point in the future, when my dependency inevitably introduces a breaking change? Fantastic. I understand t…
This is a toy/neat experiment that someone made and they explicitly say you should not use it for production. This sort of criticism is inappropriate (or at best, poorly framed). This is Hacker News, and this is a Hack. If I made a bot that drives cars around in GTA would you make a post ridiculing how dangerous my lane detection algorithm would be for a self-driving car in snow? Furthermore, the point OP makes about…
At the end of the day, I think you're saying it's a fun toy and I shouldn't worry, whereas my point was that I wouldn't even want to use it as a toy, and I am afraid it will lead especially less experienced programmers who do use it in production down a path that hurts them in the long run.
Re: Magicimport.py: Python code that fetches its dependencies without complaining
#13Earlier quoted context omitted.
This is a toy/neat experiment that someone made and they explicitly say you should not use it for production. This sort of criticism is inappropriate (or at best, poorly framed). This is Hacker News, and this is a Hack. If I made a bot that drives cars around in GTA would you make a post ridiculing how dangerous my lane detection algorithm would be for a self-driving car in snow? Furthermore, the point OP makes about…
You're basically saying that I am not allowed to give my opinion on this project, because it happens to be critical. I don't know how we can have interesting discussions in this forum if criticism is not allowed. At the end of the day, I think you're saying it's a fun toy and I shouldn't worry, whereas my point was that I wouldn't even want to use it as a toy, and I am afraid it will lead especially less experienced…
Re: Magicimport.py: Python code that fetches its dependencies without complaining
#14Personally I've been really happy with with pyenv[0].You can install multiple different versions of Python side-by-side and it does a great job managing virtualenvs.
pipx[1] is also pretty good for managing virtualenvs to install applications in but IMHO less so for doing actual development. You can use it to seamlessly install venv'd Python apps or spin up apps in ephemeral environments.
[0]: https://github.com/pyenv/pyenv [1]: https://github.com/pipxproject/pipx
Re: Magicimport.py: Python code that fetches its dependencies without complaining
#15Another thing I'd like for small projects is for "obvious" modules to be imported without having to say so. For example if I do glob.glob("*.txt") it's rather obvious that I also wanted to "import glob".
Re: Magicimport.py: Python code that fetches its dependencies without complaining
#16For instance I encountered a python wheel lately that "conveniently" shipped a precompiled .so file. Not only was that a security problem but also did that file not work properly under Ubuntu 18.04.
Re: Magicimport.py: Python code that fetches its dependencies without complaining
#17that said, it is an amusing hack to run the virtualenv'd python in a subprocess and then extract the environment vars and inject them into the already running python process.
some of the code could be cleaned up a bit -- e.g. it could be using https://docs.python.org/3/library/tempfile.html#tempfile.Tem... to just ask for a uniquely named temp dir, some of the subprocess invocations dont appear to have error handling, etc.
for my python hobby project these days i only depend upon packages i can install using apt in debian stable. containers for isolation help too.
Re: Magicimport.py: Python code that fetches its dependencies without complaining
#18Another thing I'd like for small projects is for "obvious" modules to be imported without having to say so. For example if I do glob.glob("*.txt") it's rather obvious that I also wanted to "import glob".
Re: Magicimport.py: Python code that fetches its dependencies without complaining
#19As someone who has been coding for 20 years, "magic" is a negative adjective for me. I don't want magic code. I want code that is simple and works in obvious ways. > You can even specify a version number Sorry to be sarcastic here but wow, you mean I can even make sure that my code will not break at an arbitrary point in the future, when my dependency inevitably introduces a breaking change? Fantastic. I understand t…
This is a toy/neat experiment that someone made and they explicitly say you should not use it for production. This sort of criticism is inappropriate (or at best, poorly framed). This is Hacker News, and this is a Hack. If I made a bot that drives cars around in GTA would you make a post ridiculing how dangerous my lane detection algorithm would be for a self-driving car in snow? Furthermore, the point OP makes about…
Specifically stating to not use in production will not stop people from doing just that!
Requirement files aren't magic, neither are virtual envs. Every slightly professional IDE supports that. No need to create anti-patterns.
Re: Magicimport.py: Python code that fetches its dependencies without complaining
#20Another thing I'd like for small projects is for "obvious" modules to be imported without having to say so. For example if I do glob.glob("*.txt") it's rather obvious that I also wanted to "import glob".