Jeremy T
Jeremy T

Reputation: 768

Trying to make a development instance for a Python pyramid project

So I have this Python pyramid-based application, and my development workflow has basically just been to upload changed files directly to the production area.

Coming close to launch, and obviously that's not going to work anymore.

I managed to edit the connection strings and development.ini and point the development instance to a secondary database.

Now I just have to figure out how to create another copy of the project somewhere where I can work on things and then make the changes live.

At first, I thought that I could just make a copy of the project directory somewhere else and run it with different arguments pointing to the new location. That didn't work.

Then, I basically set up an entirely new project called myproject-dev. I went through the setup instructions:

I used pcreate, and then setup.py develop, and then I copied over my development.ini from my project and carefully edited the various references to myproject-dev instead of myproject. Then, initialize_myproject-dev_db /var/www/projects/myproject/development.ini

Finally, I get a nice pyramid welcome page that everything is working correctly.

I thought at that point I could just blow out everything in the project directory and copy over the main project files, but then I got that feeling in the pit of my stomach when I noticed that a lot of things weren't working, like static URLs.

Apparently, I'm referencing myproject in includes and also static URLs, and who knows where else.

I don't think this idea is going to work, so I've given up for now.

Can anyone give me an idea of how people go about setting up a development instance for a Python pyramid project?

Upvotes: 3

Views: 187

Answers (2)

Peter Tirrell
Peter Tirrell

Reputation: 3003

Here's how I managed my last Pyramid app:

I had both a development.ini and a production.ini. I actually had a development.local.ini in addition to the other two - one for local development, one for our "test" system, and one for production. I used git for version control, and had a main branch for production deployments. On my prod server I created the virtual environment, etc., then would pull my main branch and run using the production.ini config file. Updates basically involved jumping back into the virtualenv and pulling latest updates from the repo, then restarting the pyramid server.

Upvotes: 1

Mathieu Bridon
Mathieu Bridon

Reputation: 660

The first thing you should do, if it's not the case, is version control your project. I'd recommend using git.

In addition to the benefits of managing the changes made to the application when developing, it will aldo make it easier to share copies between developers... or with the production deployment. Indeed, production can just be a git clone of the project, just like your development instance.

The second thing is you need to install the project in your Python library path. This is how all the imports and includes are going to work.

I'd recommend creating a virtual environment for this, with either virtualenv or pew, so that your app (and its dependencies) are "isolated" from the rest of your system and other apps.

You probably have a setup.py script in your project. If not, create one. Then install your project with pip install . in production, or pip install -e . in development.

Upvotes: 2

Related Questions