Defining Django App Dependencies: Difference between revisions
| Line 26: | Line 26: | ||
=== Deploying local packages === | === Deploying local packages === | ||
Upload the package distribution with `scp` (works on Mac terminal and Windows Powershell) | |||
<syntaxhighlight lang="bash"> | |||
$ scp -i ~/.ssh/app_aws.pem /path/to/package/dist/package-0.1.zip eb_user@ec2-x.x.x.x.us-west-2.compute.amazonaws.com:package-0.1.zip | |||
</syntaxhighlight> | |||
Replacing | |||
* `~/.ssh/app_aws.pem` with path to `.pem` file containing key for the AWS app user. | |||
* `/path/to/package/dist/package-0.1.zip` with the path of the actual python package. | |||
* `ec2-x.x.x.x.us-west-2.compute.amazonaws.com` with actual Public DNS of the app, from '''AWS Management Console''' > '''Services''' > '''EC2''' > '''Intances''' > '''Instances''' > ''instance-name'' > '''Public DNS''' | |||
* `:package-0.1.zip` with the name given to the file on the server (required) | |||
Then from the Django project directory: | |||
<syntaxhighlight lang="bash"> | |||
$ pip install ../package-0.1.zip | |||
</syntaxhighlight> | |||
== Installing dependences == | == Installing dependences == | ||
Revision as of 21:04, 8 February 2016
Overview
There are two files that control app dependencies: setup.py and requirements.txt.
setup.py is a list of "abstract" dependencies without a specification as to their source.
requirements.txt is more specific about source and version number.[1]
Packaging dependencies
In the project's root directory:
$ pip freeze > requirements.txt
Creating this file in Windows, even after changing the line endings to Unix-style line endings, caused an error when running pip install on the the production Linux server (in codec.py).
pip freeze will list everything installed via pip in an environment. Some of these thing will not be requirements of the web app, and should be removed from requirements.txt.
Do not include psycopg2. PostgreSQL gets installed outside this process.
Lines can be commented out in requirements.txt with the pound (#) character.
Deploying local packages
Upload the package distribution with scp (works on Mac terminal and Windows Powershell)
$ scp -i ~/.ssh/app_aws.pem /path/to/package/dist/package-0.1.zip eb_user@ec2-x.x.x.x.us-west-2.compute.amazonaws.com:package-0.1.zip
Replacing
~/.ssh/app_aws.pemwith path to.pemfile containing key for the AWS app user./path/to/package/dist/package-0.1.zipwith the path of the actual python package.ec2-x.x.x.x.us-west-2.compute.amazonaws.comwith actual Public DNS of the app, from AWS Management Console > Services > EC2 > Intances > Instances > instance-name > Public DNS:package-0.1.zipwith the name given to the file on the server (required)
Then from the Django project directory:
$ pip install ../package-0.1.zip
Installing dependences
$ pip install -r requirements.txt
Notes
See also
- install_requires vs Requirements files - Python Packaging User Guide
References
- ↑ setup.py vs requirements.txt Donald Stufft