← 返回文章流

What's the problem about Python packaging?

I have been using Python as my primary programming language for 4 years. It is elegant, easy coding and reading. I didn't notice the discomfort until I came to know about Node.js. All you need to do to install all the dependencies is a single command npm install. If you want to install another library to your project, just install it with npm, and append --save to save it in the config file, usually package.json. There is no trouble of polluting the environment of other projects, because the install root is totally isolated unless you add --global explicitly. Now when I looked into the python packaging system again I found many inconvenience and messes, as many other articles indicates^1. The pip and setuptools requires a setup.py in the project root, which is similar with package.json. It defines the requirements of installation together with project information. However, pip always install the library and all dependencies in your current python root without the help of other tools. virtualenv and its followers setup an isolated virtual environment which is done by altering the python root when activated. The problem is solved, right? I don't think so, when it comes to deployment. I have been developing and running some web applications written in python web framework, Flask and Django. The deployment is quite complicated and easy to fail. Dynamic languages require an almost same runtime environment installed on the target machine. Same dependencies, same 3rd party libs, etc. Any change of requirement version may cause a failure in deployment. Go language, which I learned recently, is another polar. It brings me brand new experiences of deployment and let me scream: "That is the way!". With statically compiled binary, all things to do in deployment is just a copy command, and it can work on any machine. But I don't like the way Go package organizes -- every modularized file locates under the same directory, which makes the hierarchy unclear. This is what I need Python learn from node.js and go. Fortunately, Kenneth Reitz developed a superb library for Python packaging: Pipenv. It is the most modern packaging tools in my opinion, which brings me almost the same experience as npm. Life is short, throw away pip, easy-install from now on and use Pipenv!

来自 Frost's Blog作者主页
在原博客阅读全文 (新标签页打开)

以上内容来自博客订阅源,版权归原作者。关注作者后可以在 关注列表 第一时间查看作者文章。

一起聊聊 0

尊重不同观点

还没有评论。欢迎分享第一个想法。

RSS SUBSCRIPTIONS

选择 RSS 订阅

把博客汇的文章添加到你常用的阅读器。

关注文章 RSS 订阅本订阅需要登录后使用