ramses-tech / ramses

RAML + Elasticsearch / Postgres / Mongodb / Your Data Store™ + Pyramid = RESTful API
http://ramses.tech
Apache License 2.0
303 stars 29 forks source link

Confusion on virtualenv directory vs project location #114

Closed mloskot closed 8 years ago

mloskot commented 8 years ago

First, I'm just introducing myself to ramses and nefertari, so I might be making some obvious mistakes here.

The latest docs outline the following list of steps to kickstart new project:

$ virtualenv my_project
$ source my_project/bin/activate
$ pip install nefertari
$ pcreate -s nefertari_starter my_project
$ cd my_project

The issue is, pcreate generates project files in the same directory where the Python virtual environment resides. The leads to rather messy content of my_project:

(my_project) vagrant my_project $ ls -la
total 60
drwxr-xr-x 7 vagrant vagrant 4096 Jun 26 12:15 .
drwxr-xr-x 4 vagrant vagrant 4096 Jun 26 12:16 ..
-rw-r--r-- 1 vagrant vagrant  704 Jun 26 12:15 api.raml
drwxr-xr-x 2 vagrant vagrant 4096 Jun 26 12:15 bin
drwxr-xr-x 2 vagrant vagrant 4096 Jun 26 12:09 include
-rw-r--r-- 1 vagrant vagrant  706 Jun 26 12:15 items.json
drwxr-xr-x 3 vagrant vagrant 4096 Jun 26 12:09 lib
lrwxrwxrwx 1 vagrant vagrant    3 Jun 26 12:09 lib64 -> lib
-rw-r--r-- 1 vagrant vagrant 1479 Jun 26 12:15 local.ini
drwxr-xr-x 4 vagrant vagrant 4096 Jun 26 12:15 my_project
drwxr-xr-x 2 vagrant vagrant 4096 Jun 26 12:15 my_project.egg-info
-rw-r--r-- 1 vagrant vagrant   60 Jun 26 12:10 pip-selfcheck.json
-rw-r--r-- 1 vagrant vagrant   69 Jun 26 12:09 pyvenv.cfg
-rw-r--r-- 1 vagrant vagrant   93 Jun 26 12:15 README.md
-rw-r--r-- 1 vagrant vagrant   68 Jun 26 12:15 requirements.txt
-rw-r--r-- 1 vagrant vagrant  716 Jun 26 12:15 setup.py

According to the plain Pyramid project creation guide, the project content is outside of the virtual environment (see directory tree. Here, the virtual environment is completely separate, placed in export VENV=~/env.

Although I understand users are free to arrange the virtual environment and the project content freely, for newbies like myself, wouldn't it be better if the docs are more explicit about separating the two?

$ mkdir my_project 
$ cd my_project
$ pyvenv venv
$ source venv/bin/activate
$ pip install ramses
$ pcreate -s ramses_starter .
(venv) vagrant my_project $ ls -la
total 44
drwxr-xr-x 5 vagrant vagrant 4096 Jun 26 12:18 .
drwxr-xr-x 4 vagrant vagrant 4096 Jun 26 12:16 ..
-rw-r--r-- 1 vagrant vagrant  707 Jun 26 12:18 api.raml
-rw-r--r-- 1 vagrant vagrant  706 Jun 26 12:18 items.json
-rw-r--r-- 1 vagrant vagrant 1492 Jun 26 12:18 local.ini
drwxr-xr-x 4 vagrant vagrant 4096 Jun 26 12:18 my_project
drwxr-xr-x 2 vagrant vagrant 4096 Jun 26 12:18 my_project.egg-info
-rw-r--r-- 1 vagrant vagrant   93 Jun 26 12:18 README.md
-rw-r--r-- 1 vagrant vagrant   68 Jun 26 12:18 requirements.txt
-rw-r--r-- 1 vagrant vagrant  719 Jun 26 12:18 setup.py
drwxr-xr-x 5 vagrant vagrant 4096 Jun 26 12:17 venv

In other words, the Htchhiker's guide to Python way.

Finally, what is the actual best practice recommended by the Ramses team?

jstoiko commented 8 years ago

You're right. We should probably fix this in the docs. Feel free to submit a PR.

There is also a ramses cli that we've been working on that abstracts "everything" in docker containers: https://github.com/ramses-tech/debian-ramses and https://github.com/ramses-tech/homebrew-ramses

That's still experimental. But feel free to try it out.

mloskot commented 8 years ago

@jstoiko No problem, I've just crafted a tiny PR.

The ramses CLI sounds great. Though, currently, I'm familiar with 'classic' mode of VMs and Vagrant is my friend for old school local development environment. I may become familiar with Docker one day, then I'll check it out.

jstoiko commented 8 years ago

Looks great. Thank you @mloskot