专栏首页Frost's BlogWhat's the problem about Python packaging?

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 indicates1. 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!

  1. https://medium.com/@alonisser/things-i-wish-pip-learned-from-npm-f712fa26f5bc

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

我来说两句

0 条评论
登录 后参与评论

相关文章

  • A deeper look into Pipenv and Poetry

    It is 8 months passed since I posted the article comparing Pipenv with Poetry, w...

    岂不美哉Frost
  • 给你的 Git commit 加上绿勾

    今天无事翻看了几个Python开发者的Github,却发现大多数人的Git commit列表都是白茫茫一片。

    岂不美哉Frost
  • 在博客与笔记中使用Markdown

    这些我都不是特别满意,于是便萌生了干脆建一个个人博客的想法。通过多方考查,得到一个比较好的解决方案:Hexo + Github page。Github page...

    岂不美哉Frost
  • C++/CLI(二)Mono C++/CLI Native调用和P/Invoke调用

    本文根据Mono C++原文档翻译,这篇文章的目的,就是想说CLR程序在VS下面生成的DLL不能给Unity调用,因为Mono的Native调用的编码和MS C...

    Pulsar-V
  • Codeforces Round #408 (Div. 2)(A.水,B,模拟)

    A. Buying A House time limit per test:2 seconds memory limit per test:256 megaby...

    Angel_Kitty
  • 如何把一个ABAP视图添加到SAP GUI的收藏夹里

    The idea comes from Sougata Chatterjee’s anwser in this thread:

    Jerry Wang
  • 用.NET Framework 2.0创建 Form设计器[翻译]

        这两天赶鸭子上驾,学习Form设计器,下面这篇在Msdn Magazine的文章可谓是经典,这两天学习了感觉还是做个翻译出来,更能够加强理解。对各位同...

    张善友
  • GPIOs and Go

    Recently, I decided that I needed a small heads up display for import things I k...

    李海彬
  • Control is important! model predictive control mpc.pytorch lib

    Optimal control is a widespread field that involve finding an optimal sequence o...

    用户1908973
  • Hack the box: Bastion

    In conclusion, Bastion is not a medium box. But it would be easier to solve this...

    madneal

扫码关注云+社区

领取腾讯云代金券