DEV Community

Sandeep
Sandeep

Posted on • Edited on

Fall in Love with Your Environment Setup part-1

A Python developer’s guide to the optimal setup for collaboration, production readiness and time saving

Image description

What exactly do I mean by “environment setup”?

I mean having all the tools you need to efficiently perform the following 5 tasks:

  1. Version control your code
  2. Run scripts from command line
  3. Edit and debug your code
  4. Manage the Python version you use to run your code
  5. Manage the Python package versions you use to run your code

Why is environment setup important?

Having a good setup is crucial for a number of reasons:

1. Team Collaboration

Image description
When multiple people are working on the same code base, it is hard to collaborate if environment setup is not uniform among all team members. Code that works on one team member’s machine may break when another team member tries running it on their machine if they are using different versions of python or python packages.

2. Production Readiness

The problem extends beyond team collaboration to production. If the production environment is different from the machine you’ve been developing on, code may break once deployed. In programming, it is crucial to control as many external variables as possible so that production behavior is as predictable as possible.

3. Time Saving

Image description
When you are first getting started on a new project or testing someone else’s code, you can waste a lot of time preparing your machine to run their code if environment setup is not straightforward.
And time wasted is not limited to the beginning of a project — if setup is not standardized, developers will continue to lose time troubleshooting version incompatibility errors that could have easily been avoided.

I hear you, but what do I need to do?

Environment setup can be confusing and complicated. I have struggled through the process many times myself.
The variety of options available for accomplishing the 5 key tasks of environment setup (see the What exactly do I mean by “environment setup”? Section above) can be overwhelming.
To save you time, effort and frustration, I have listed the tools I have found most helpful (as well as their key features) below. I have tested these tools across operating systems to ensure optimal setup, no matter your OS. Read on for all things needed to create a great environment setup on your machine, and reference the python-dev-setup repo for install instructions/tips!

1. Version Control Your Code

Recommend: Git

Git is the powerful software behind GitHub and Bitbucket. It is helpful for more than just basic version control, it is also key to:
Team collaboration — You can make/test changes to the code on your local machine before pushing them to the team-shared remote code base. Additionally, you can create branches off the master branch so that your development work doesn’t impact the rest of the team or the code in production. Lastly, you can easily merge other team member’s branches into your own branch or the master branch when development is complete.

Release Management — The branching system is also key for release management. Depending on project requirements, different enhancements may have different timelines for when they should be deployed to production. By isolating new features in separate branches, you can easily deploy each feature independently.

To get started using Git:

Install Git — Mac, Linux, Windows
Configure SSH Auth so that you don’t need to enter your username/ password every time you pull/push to your GitHub/Bitbucket repo — Mac/Linux, Windows
Reference this list of useful git commands
Download the archive_branch.sh script and add it to the root of your project to automate the tedious process of archiving an inactive git branch.

That's all for the day, will continue in the next post comment below if you have questions to ask.

To know about me https://linktr.ee/sandeepk27

Top comments (0)