switchon@lavalamp.biz
+27(0) 83 419 4851 / +27(0) 21 036 1165
Application & software development
Get A Quote

    • Home
    • Services
      • Application & software development
      • Outsourced software development
      • Project based resourcing
      • Digital marketing & consulting
      • Graphic design & consulting
      • UI / UX design & consulting
      • Recruitment services
      • Lease an expert
    • About
      • How we work
      • NBConsult Group
      • Partners
      • Lightbox Digital
    • Blog
    • Join us
    • Contact

    • Home
    • Services
      • Application & software development
      • Outsourced software development
      • Project based resourcing
      • Digital marketing & consulting
      • Graphic design & consulting
      • UI / UX design & consulting
      • Recruitment services
      • Lease an expert
    • About
      • How we work
      • NBConsult Group
      • Partners
      • Lightbox Digital
    • Blog
    • Join us
    • Contact

    • Home
    • Services
      • Application & software development
      • Outsourced software development
      • Project based resourcing
      • Digital marketing & consulting
      • Graphic design & consulting
      • UI / UX design & consulting
      • Recruitment services
      • Lease an expert
    • About
      • How we work
      • NBConsult Group
      • Partners
      • Lightbox Digital
    • Blog
    • Join us
    • Contact

    • Home
    • Services
      • Application & software development
      • Outsourced software development
      • Project based resourcing
      • Digital marketing & consulting
      • Graphic design & consulting
      • UI / UX design & consulting
      • Recruitment services
      • Lease an expert
    • About
      • How we work
      • NBConsult Group
      • Partners
      • Lightbox Digital
    • Blog
    • Join us
    • Contact
    burntout slump
    7 Tips Developers Can Use To Get Out Of Their “Burnout Slump”
    Dec 13, 2021
    switch branding in your angular project
    Switch Branding In Your Angular Project
    Feb 7, 2022

    Setup A New Python Project Like A Pro (Part 2)

    Categories
    • Git
    • Languages / Tech areas
    • Software Development
    Tags
    • git
    • python
    • software development
    ice cubes
    ice cubes

    In my previous blog post, I talked about how to create virtual environments and how we should use them for each of our projects. This blog post will expand on that slightly, and then begin talking about some basic security aspects that we need to keep aware of.

    When you install a new package while within your virtual environment it will be added to your virtual environment folder. But that’s still within your virtual environment. What happens when you are collaborating on a project within a team using something like Git? Let’s say someone has added a dependency, and it is sitting within their virtual environment, and not yours.

    We have something that is called a requirements.txt file. A file which pip can use to install all the required dependencies or packages from a single command. To install all the required packages from this file you would simply run <code>pip install -r requirements.txt</code>. The file is very basic and just contains the name of the package, along with the version of the package that was installed.

    When you add a new dependency to your project you simply need to add that package and its version to your requirements.txt file. This is all good and well when you’ve only added one new dependency and altering the file is not an issue. What about when you’ve just started a new project, you’re in a state of flow, and you’re installing new packages left right and centre?

    I think we can all agree it would be extremely tedious, after an hour or two of furious coding, to go back through every file you’ve altered or created to look for the packages you’ve used to add to your requirements.txt file. Fortunately, pip has us covered. If you run the command <code>pip freeze > requirements.txt</code> pip will extract all the packages used in your project and add them to the requirements.txt file.

    This means our basic workflow for a collaborative project will look like this. First, we’ll pull the branch we’re working from to our local machine. Then we’ll create a new branch from that version of the source code on which we will do our changes. When we’re on our new branch we can run <code>pip install -r requirements.txt</code> to check that our virtual environment is up to date with what our colleagues have done. We then make our changes or add a new feature to the codebase. When we’re done coding and testing, we can add any new dependencies we’ve used to the requirements.txt file and create a pull request.

    This should illustrate the ease with which we can use pip virtual environments to keep our dependencies project specific, ensuring we don’t just have a whole host of unused dependencies in our main Python environment. I meant to talk about basic security and the use of dotenv files, but we’ll keep that for the next blog post. Happy coding, everyone.

    Contact us


      Related posts:

      getting django to talk to mysql 8Getting Django To Talk To MySQL 8 python packge indexSetup A New Python Project Like A Pro (Part 1: Virtual Environments) laravel livewireLaravel Livewire how to deploy your app/website on herokuHow To Deploy Your App/Website On Heroku
      Share
      2
      Nicholas Driver
      Nicholas Driver
      Nicholas is a chemistry graduate who has worked previously as a project manager, managing director, and caregiver, but not as a chemist. After moving into software engineering in 2018 he has worked on big data, business intelligence, and various full-stack projects in a variety of different languages, platforms and frameworks.

      Leave a Reply Cancel reply

      Your email address will not be published. Required fields are marked *

      Lava Lamp Lab


      Like technology, a lava lamp constantly changes form, producing new conditions with every passing moment



      lava lamp lab facebook   lava lamp lab twitter   lava lamp lab linkedin   lava lamp lab instgram

      Services


      Application & software development

      Outsourced software development

      Project based resourcing

      Digital marketing & consulting

      Graphic design & consulting

      UI / UX design & consulting

      Contact Us


      +27(0) 83 419 4851

      +27(0) 21 036 1165


      switchon@lavalamp.biz


      Unit 4 Monaco Square,
      14 Church Street,
      Durbanville,
      Cape Town, 7550

      NBConsult Group


      nbconsult
      nbconnect msp
      nbclearning
      river broadband
      designer needed
      © 2023 Lava Lamp Lab (Pty) Ltd | All Rights Reserved | Privacy Policy
      Contact us now

        Application & software development

          Outsourced software development

            Project based resourcing

              Digital marketing & consulting

                Graphic design & consulting

                  UI/UX design & consulting

                    Lease an expert

                      Recruitment services

                        We are using cookies to give you the best experience on our website.

                        You can find out more about which cookies we are using or switch them off in settings.

                        Lava Lamp Lab
                        Powered by  GDPR Cookie Compliance
                        Privacy Overview

                        This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

                        Strictly Necessary Cookies

                        Strictly Necessary Cookie should be enabled at all times so that we can save your preferences for cookie settings.

                        If you disable this cookie, we will not be able to save your preferences. This means that every time you visit this website you will need to enable or disable cookies again.

                        3rd Party Cookies

                        This website uses Google Analytics to collect anonymous information such as the number of visitors to the site, and the most popular pages.

                        Keeping this cookie enabled helps us to improve our website.

                        Please enable Strictly Necessary Cookies first so that we can save your preferences!

                        Cookie Policy

                        More information about our Cookie Policy