[Flask] slightly OT: packaging/moving flask app with virtualenv

Alex Hall ahall at autodist.com
Wed May 4 10:49:11 EDT 2016


I've been doing some reading and tests on this. I've gotten things to work
locally inside a virtual environment, including the all-important database
communication, so we're looking good there. The docs say, though, that
environments can't be moved between platforms; making this extra fun is
that I'm developing on Windows and wanting to serve files from Debian. I
suppose my next step is to get an environment set up on the Debian server
and make sure it works from there. Once it does, Nginx and UWSGI will be
brought into the mix.

As I understand it, I'd want to copy my entire project directory from my
Windows machine over to the server, probably in /var/www/mySite. I'd then
cd into /var/www, run virtualenv mySite, activate the new environment,
install my packages, and I should be set? Again, this isn't touching
serving for now, just getting my project to run. Fortunately, it doesn't
use hard-coded paths, output files, or anything else. I use {{url_for()}}
for all my links and script/style includes, and I never rely on
Windows-only libraries. This should be reasonably easy, assuming I have the
general process correct.

On Wed, May 4, 2016 at 10:07 AM, Corey Boyle <coreybrett at gmail.com> wrote:

> Virtualenv works by temporarily changing the active PATH so that your
> scripts see an alternate (and isolated) Python interpreter and
> libraries instead of seeing the globally installed ones.
>
> So... I don't think it would ever be to late to start using a virtualenv.
> Perhaps the only thing that could be effected is the paths of your
> import statements.
>
> Basically, you need to setup a virtualenv on the server, that matches
> the virtualenv on your dev box, and tell Apache to use it when
> executing your Python scripts. (I've never used Apache with Python, so
> I can't help with that part.)
>
> I also like using virtualenvwrapper, but I'm not sure if that would
> help or hurt you at this point.
>
> On debian...
> apt install python-virtualenv
> apt install virtualenvwrapper
>
> What OS are you using for development?
>
> On Wed, May 4, 2016 at 9:06 AM, Alex Hall <ahall at autodist.com> wrote:
> > Hey list,
> > At the urging of several members here, I'll give virtualenv a shot while
> I'm
> > installing and moving everything. Currently, I have my Flask app working.
> > It's small--just a couple pages with a bunch of JS--but does need Pyodbc
> and
> > WTF to work. Is there a way I can take my existing app, put it into a
> > virtual environment, and toss the whole thing on my Debian server? I've
> > installed virtualenv on the server already, as well as UWSGI. Is this
> > doable, or should I upload the entire directory and somehow put it into a
> > virtual environment on the server? Am I too late--that is, can this only
> be
> > done when you start a new project?
> >
> > --
> > Alex Hall
> > Automatic Distributors, IT department
> > ahall at autodist.com
> >
> > _______________________________________________
> > Flask mailing list
> > Flask at python.org
> > https://mail.python.org/mailman/listinfo/flask
> >
>



-- 
Alex Hall
Automatic Distributors, IT department
ahall at autodist.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20160504/bb6bfe11/attachment.html>


More information about the Flask mailing list