-
Notifications
You must be signed in to change notification settings - Fork 5
Local Installation for Programmers
Software Configuration Management (SCM) SOP for more information.
- Windows development machine preferred
- Git - https://git-scm.com/downloads a. Plus any Git clients.
- Python 3.7.0 - https://www.python.org/downloads/ a. When installing, make sure that pip gets chosen as an additional feature.
- Latest version of Pip. Included with Python installation.
-
Visual Studio 2019 - https://www.visualstudio.com/downloads/
- The free Community Edition is sufficient.
- PostgreSQL v 10 or higher.
- PgAdmin4
These steps use the Windows Command Prompt to set up the Python environments necessary for developing multiple Python projects.
- Add pip to your path if necessary.
- Install necessary packages
- pip install virtualenv
- pip install virtualenvwrapper
- pip install virtualenvwrapper-win
- Add an environment variable WORKON_HOME to specify the path to store environments. By default, this is %USERPROFILE%\Envs
- Create a Food Waste virtual environment with the command mkvirtualenv gemm
- Switch between environments with the command workon {env_name}
A fresh clone of Food Waste should not have any Visual Studio related files, such as .sln, .pyproj, .vs/, etc. If it does, then delete them. You’ll need to set up your local environment anyway.
- Open Visual Studio and select File > New > Project
- In the left pane, select Python and choose ‘From Existing Python Code’
- For the location, enter the file path to the python project (C:/Git/FoodWaste)
- Name the project.
- Submit and click next. Choose manage.py as the startup file and press next.
- On this final page, select both check boxes and change the project type to Django Web Project. Click finish.
- In the solution explorer, right click on Python Environments and select Add Virtual Environment.
- Navigate the location to the virtual environment previously created (look in %USERPROFILE%\Envs). Alternatively, you can just create a new one in the default location through Visual Studio, which is inside the source code. This is okay and will be ignored by git
- In the solution explorer, right click on the new virtual environment and select install from requirements.txt
- Alternatively, you can do this via command line with the following commands
- cd /working/directory
- workon {FoodWaste_env}
- pip install –r requirements.txt
- Alternatively, you can do this via command line with the following commands
- Create a database called FoodWaste and import the latest data from the databases/ directory.
- Download and configure a local_settings.py file. Make sure to configure the proper Database settings.
- Install Git @ https://git-scm.com/downloads
- Additionally, install any GUI based client you’d like to use, such as Git Hub Desktop: https://desktop.github.com/
- Clone the repository to a local location. The Gateway uses C:\Git as the root directory, so the project is C:\Git\FoodWaste
- If the clone fails, you may need to extend the available path length and restart the cloning process:
- From the git hub install, open Git shell (Alternatively, open Powershell.exe and cd to C:\Users\username\Documents\GitHub)
- Type the command: git config –system core.longpaths true
Install postgreSQL @ https://www.postgresql.org/download/windows/
* Note: Make sure pgAdmin 4 is selected and installed.
Command ran for importing a psql data dump:
**psql -U postgres -d gemm -f dumpfilename**
Or if psql isn’t in the path, we cd into the psql installation directory\bin\ (location of psql.exe) and ran
**psql.exe-U postgres –d gemm –f “path\to\filename.sql”**
Install Python 64-bit 3.7.0 https://www.python.org/downloads/release/python-370/
* The installation takes a while to get started.
* When choosing additional features, make sure that pip gets installed as well.
Install VS 2019 @ https://www.visualstudio.com/vs/
* Note: There are SDK .NETFramework issues when using older VS versions.
* Install SDK (.NETFramework 4.5.2)
* Install GitHub Extension for Visual Studio
* **pip install virtualenv**
* **pip install virtualenvwrapper**
* **pip install virtualenvwrapper-win**
* Create a FoodWaste virtual environment with the command **mkvirtualenv FoodWaste**
If the FoodWaste is not yet a VS project, you will need to open it in visual studio to get a proj file. Else, skip these steps
* Open Visual Studio and select File > New > Project
* In the left pane, select Python and choose ‘From Existing Python Code’
* For the location, enter the file path to the python project (C:/Git/Gemm)
* The project name should derive itself from the chosen file location, if not, give it a name.
* Submit and click next. Choose manage.py as the startup file and press next.
* On this final page, select both check boxes and change the project type to Django Web Project. Click finish.
* In the solution explorer on the right, right-click on 'Python Environments' and select 'Add Virtual Environment'.
* For 'Location of the virtual environment', browse to the FoodWaste virtual environment location, usually found in 'C:\Users\%Username%\Envs\'
* Using the checkbox, you can let VS automatically install all required pip packages.
* In the solution explorer, expand Python Environment, right click the FoodWaste environment, and select 'Install from requirements.txt'
- Set up a PostgreSQL server if one is not already installed on the machine.
- Use FoodWaste.backup to import data into your local PostgreSQL.
- In the solution for the FoodWaste Project, edit (or create if not exists) the local_settings.py file, in the same directory as all the other python code (FoodWaste> FoodWaste).
- Change the credentials in DATABASES so that it will work with your local copy.
[sudo yum install postgresql-server]
Installation and updating FoodWaste Web Tool on Fedora Server. Fedora Command Line. The 'dnf' command (equivalent to apt-get)
Update FoodWaste Web Tool from US EPA GitHub server https://github.com/USEPA/FoodWaste From root E4S folder, execute as su:
-
git add [file_names] (if any new files/directories were created)
- git commit -m "Insert Comments Here"
- git remote add origin https://dyoung11@github.com/USEPA/FoodWaste.git
- git push origin master/branch_name (to merge server version with github version)
- git pull origin master/branch_name (to merge github version with server version)
REFERENCE: https://code.visualstudio.com/docs/python/tutorial-django
- Change Directory: cd ~/ExistingData/FoodWaste/FoodWaste
- Create virtual env: python -m pip install django
- In new Terminal Window: source env/bin/activate
- Activate VM: django-admin startproject FoodWaste
- Verify VM: python manage.py runserver
FoodWaste is developed and maintained by Office of Research & Development (ORD), Center for Environmental Solutions & Emergency Response (CESER), Land Remediation & Technology Division (LRTD), Environmental Decision Analytics Branch (EDAB), U.S. Environmental Protection Agency, Cincinnati, OH 45268, under Mozilla Public License Version 2.0. See OMB Memorandum M-16-21 Section 4 & Releasing Open Source Code.