Why is virtualenv, fabric, and pip the three major artifacts of pythoneer?

Source: Internet
Author: User
Tags virtualenv
Php Chinese network (www.php.cn) provides the most comprehensive basic tutorial on programming technology, introducing HTML, CSS, Javascript, Python, Java, Ruby, C, PHP, basic knowledge of MySQL and other programming languages. At the same time, this site also provides a large number of online instances, through which you can better learn programming... Reply: These three are very convenient for Python project deployment.
1. virtualenv is used to establish a virtual python environment, a python environment dedicated to the project. It is very useful to use virtualenv to maintain a clean environment.
2. pip is used to solve the project dependency problem. Write the third library of all dependencies of the project in a requirements.txt and use pip for batch installation. Generally, it works with virtualenv to install all packages in the virtualenv environment.
3. fabric is used to automate remote project deployment, which is very convenient. You can execute a series of shell commands and programs locally and remotely as needed. For example, update code from the code library, execute the data migration script, restart the service process, and complete automatic deployment. The module dependency mechanisms provided by easy_install and setuptools are also easy to use. in my opinion, pip is not very popular.
Virtualenv is similar to the more powerful zc. buildout supports generating environments through configuration files. it is okay to change the python version. it is not a problem to automatically download an apache file and compile and support python through the buildout plug-in. function, zc. buildout is stronger. what about ansible... The word "artifact" is the "pseudoexpression Flag" in the programming world, which I don't agree with. compared with virtualenv and pip, buildout is really a good thing, whether it is the cleanliness of the virtual python environment, ease of use, customization/control of the installation package, or support for batch deployment are far more than the former. it can be said that virtualenv + pip is still in the manual age, while buildout has entered the mechanical age.

As for fabric, it is indeed a good tool to deploy and manage code in batches with a simple fabfile. you can also choose not to use its fab command and perform in-depth development based on its api, the only weakness is that ssh is slightly more dependent.

In addition, I recommend another good tool, supervisor. where is the source? I do not agree with the recommendation of the following three artifacts: sqlalchemy, twisted, and gevent, which are used in the course of python this semester. Fabric has never been used. pip facilitates the installation and management of python packages. virtualenv provides a clean virtual environment.
Pip and virtualenv are both very useful. for the course I learned, these two must be used, otherwise, there is basically no way to reference the python package and those jobs that involve environment switching. But I don't know if they are artifacts.
Thanks for your answers. I recently tried the python tools mentioned above. I have been familiar with python this semester and think it is really a good thing. I personally think it is much better than java. fabric is not used now. let's talk about virtualenv and pip first.

Similar to maven in java (only dependency management and no build function are available), pip can directly reference other projects without having to include others' code in the project. Requirements.txt is also very important. you only need pip install-r requirements.txt.

Virtualenv allows you to create an independent Python environment, and use a separate environment for individual applications. In this way, you only need to create a new virtualenv when deploying the application, and then pip install-r requirements.txt. you only need to delete virtuenv when revoking the application. This avoids a lot of installation in the global environment, which is difficult to manage and may conflict with each other. (Of course, virtual machines and containers can also achieve this effect, but the cost is too high)


Update

Fabric is to automate and unify some frequently executed operations and scripts. This reduces the probability of human error.
Of course, it seems that ansible is more popular now. Only virtualenv is used, which can simulate your own library environment for each Python application.
It is suitable for batch deployment and does not need to be considered for conflict with other application environments.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.