Should I move windows project folder into WSL? - django

I'm trying to set up a work environment on a new machine and I am a bit confused how best to procede.
I've set up a new windows machine and have WSL2 set-up; I plan on using that with VS Code for my development environment.
I have a previous django project that I want to continue working on stored in a folder in a thumb drive.
Do I move the [windows] project folder into the linux folder system and everything is magically ready to go?
Will my previous virtual environment in the existing folder still work or do I need to start a new one?
Is it better to just start a new folder via linux terminal and pull the project from github?
I haven't installed pip, python, or django on the windows OR linux side just yet either.
Any other things to look out for while setting this up would be really appreciated. I'm trying to avoid headaches later by getting it all set-up correctly now!

I would pull it from github, and make sure you have the correct settings for line endings, since they are different between windows and linux. Just let git manage these though:
https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings
Some other suggestions:
Use a version manager in linux to manage your python versions - something like pyenv or asdf. It will make life easier.
Make sure to always create a virtual environment for everything and don't pip install anything in your main python. (I use direnv for virtual env management)
The single exception to the previous suggestion is pipx, which I do install in the main python and then use to install things like cli tools, black, isort, pip-tools etc.
Configure VScode to use the pipx installed versions of black, flake8 etc. for linting purposes.
If you're using Docker, enable the WSL integration for your WSL flavour (probably Ubuntu). Note that docker desktop needs starting before your WSL session.

Related

What's the proper way to use different pipenv environments for a Django project on different computer systems?

Hopefully this isn't too stupid of a question, concerning the use of pipenv for the same Django project on different computer systems. The scenario is that I'm using pipenv with a test Django project on one laptop, everything works fine, using VS Code and it's using the proper pipenv environment for the Python environment within VS Code.
The project however is within Dropbox so when I'm using a different laptop, which I do sometimes, one is my work laptop the other is my personal one at home, I can work on the same project wherever I left off. So you can probably deduce the issue I'm having.
I'm using pipenv environment A on my work laptop for the Django project. But when I open the project in VS Code on my personal laptop at home I have to keep specifying the proper pipenv environment to use, which obviously is different than the one on my work laptop.
Maybe I shouldn't be working this way and should just work on one laptop for the project, but I imagine others have done the same with similar setups before.
Is there a "proper" way to do this, using different pipenv environments on different machines for the same Django project? Should I copy over the pipenv environment to each machine as well? Or am I missing something really simple here?
First, use version control. (git is the defacto standard these days and there are plenty of services to choose from)
For using pipenv, you want to keep your Pipfile and Pipfile.lock in your repository (these are the only files you should be copying related to your environment from system to system).
The local environment is then built on each machine where it is needed by using pipenv sync or pipenv sync --dev (to install dev specific requirements).
So the related virtualenv will be created on each system in which you are developing your project.

Set python workspace environment to Debian VM when on OSX in VS Code

I am experimenting with setting up Visual Studio Code as my Django IDE, however I'm having difficulty configuring my python workspace environment correctly, such that I can get intellisense for 3rd party modules (like Django) working.
My desktop is Mac OSX, but I run my actual Django environment in a Debian instance inside of virtual box, running on my Mac. I also run Debian in production. I use an NFS share my django project files and virtualenv files between Debian and OSX.
I tried following these instructions for configuring my interpreter, however if I set a custom path like:
/Users/myusername/.virtualenv/myenv/bin/python2.7
It won't work, because that's a debian binaries, not Mac OSX.
In PyCharm I believe there is a way to specify remote interpreters, even on different architectures. There's no way to do something like this in VS Code, right?
Pretty sure what I want is currently impossible. The good news is it's being worked on.
link to issue #123 RFE: Support Remote Interpreter in pythonVSCode repo

Foundation 5 SCSS installation and Prepros

I installed ruby, Git and Node.js. Then instruction says "Bash", what exactly is Bash? I am using windows and I am newbie for thoese 3 apps they listed.
Is it windows default cmd.exe? ruby.exe or git?
If I manage it to work and created foundation project folder. How to make the foundation5 work with Prepros?
Bash is a Unix Shell, which basically allows you to type commands on your computer to execute tasks.
When you install Git on Windows, you also get a version of Git Bash, which you can use for Git commands.
Your best bet is to use something like Cygwin which replicates unix functionality on a Windows machine. Once you have installed Cygwin, you may need to set up your PATH environment variable so that when you execute git or ruby commands, they know where to look.
There is some help here on setting up environment variables.

How apps installed at pip really works?

I'm new at django and i was looking for a wysiwyg and i fuond tinymce.
I installed at pip command line and i expect that create a folder at my folder project like a new app. It dont created no one folder but i did the next steps and for my surprise the app works fine at my project.
I want to know how this app really works at my project, in case im gonne deploy this project and how to deploy the app installed at pip or something like that.
My englhish is not good but i hope that was clear.
The applications, or libraries rather are copied directly inside one of the folders inside your python directory called Lib/site-packages. This exact location depends on your operating system you can find usually find your newly installed packages under
For Windows
C:/PythonXX/Lib/site-packages/
For Linux
/usr/local/lib/pythonX.Y/site-packages
When you run a python script, Python will automatically include these folders as available resources, and when you add for example import X to your code, it will check to see if X is listed.
You have more information on the topic available here.

Best practices of using virtual environment for web development with Django?

This is a Django and Python and maybe just a general web development question.
what's the difference between using virtualenv vs vagrant vs virtual box and etc... ?
I'm kinda confused as to when to use which one :/ I've been using virtual env this whole time and creating new virtual environments for different projects....
Is this the right way to do it?
One virtualenv per project?
I'm not really sure when and where vagrant comes into play...Am I supposed to set up vagrant and then use virtualenv?
This is probably a silly question but...if I were to be working on this project with other people. Would they too have to set up a virtual env? Just to collaborate?
Wouldn't it make more sense that we all work on our local machines and then push it into the main branch? I'm just kinda confused .... I feel like I'm doing it all wrong...
Thanks for the replies everybody!
Virtualenv sets up a local sandbox for you to install Python modules into.
Vagrant is an automation tool for creating Virtual Machines.
VirtualBox is a free, open source environment for running virtual machines, like those created by Vagrant.
Virtualenv is really about all you'll need to do sandboxed development on your local machine. We use Vagrant at my work to automate the creation of VMs. This way new developers coming on to a project have basically zero configuration to do in order to start working.
If you're collaborating with other devs, they don't need to do any of the above to work on your Django project, but if there's a lot of configuration involved that can't be done with pip and a requirements.txt, then you might look at Vagrant to ease some of that automation.
But you are correct in your assumption that you can all just work on a local branch and push back to the repo. Everything else is just icing.
Virtualenv is a python construct that holds a specific set of packages, separate from your system packages. The version of Python and its packages that came with your OS or that you installed separately is a "system package".
Virtualbox is totally different -- it's a VM, an entire operating system in a box.
I'm not familiar with Vagrant.
All you need is virtualenv. Create a new virtualenv for each project (they're very lightweight!) You need to do this because the whole point of virtualenv is to isolate the exact packages and versions of those packages you need for your project. Then activate the virtualenv and use pip install to install the packages you need, presumably starting with Django itself.
Once you have all the packages you need, use pip freeze > requirements.txt to create a file called requirements.txt that records all of the packages you've decided to use.
When other people collaborate on your project, they can start a virtualenv, pull your code into it, and run pip install -r requirements.txt to replicate your environment. They can even modify requirements.txt, push that back to you via your version control system, and you can run pip install -r requirements.txt yourself to modify your environment to match their changes.
This is all essential because without virtualenv, the problem of, for instance, having one project on your computer that requires Django 1.4 and one that requires Django 1.5 becomes very complicated.
Virtualenv is not an entire operating system in a box, just a python environment, so even if you are using it, you are still working on your local machine.
We use virtualenv and a Ubuntu virtual machine. Here's why:
virtualenv allows us to have isolated Python environments on a given operating system instance
Using Ubuntu dekstop in a virtual machine for our Python development mimics what it will look like when deployed on the server which is also Ubuntu. This means that we understand precisely the external OS package dependencies and configuration. You don't get this easily when you use OSX or Windows for development and Linux for deployment.
One important point is that a virtual machine is portable. You can take a snapshot and deploy it elsewhere easily. With Vagrant and Ansible combination you can automate a remote deployment.