question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Missing documentation on how to install in production enviroment

See original GitHub issue

I’m wondering there is no documentation on how to use pipenv in production deployment. My current setup for deploying something to production is like the following:

  1. Pushing a new version of my package (as wheel) to my internal PyPi server (running pypiserver)
  2. Setting correct variables like PIP_INDEX_URL to my internal PyPi server on the target server
  3. Running pip install -U my-package on the target server
  4. Restart webserver

Having the list of requirements parsed from a requirements.txt into install_requires in my setup.py. The requirements.txt file is included by MANIFEST.in.

Now I’m courios if it is enough to include Pipfile and Pipfile.lock into my package and run pipenv install on the target production server? Does pipenv automatically use the environment variables like PIP_INDEX_URL? Or is pip install -U my-package still the preferred way? I know that there is pipenv lock -r, but I would like to abandon requirements.txt completely 😃

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
techalchemycommented, Apr 27, 2018

@floqqi sorry you had a bad experience, myself and lots of others use pipenv in production and need the functionality so while I am sorry, I’m also interested in productive comments 😃 hope you have a nice day

@exhuma the difference between setup.py and requirements.txt isn’t anything to do with whether one set of dependencies is concrete or not. Requirements.txt are used for two purposes kind of:

  • Developing libraries and sharing with others what is needed to also develop those;
  • Tracking the exact stuff needed to create an environment for application deployments.

The purpose of setup.py files is for distribution — they are how your application gets installed into other peoples environments, so not your application plus all of the extra stuff you decided to put into your environment, just your application, what’s needed to support it.

Now this is important because production is a pretty good use case for pipenv since you are trying to just recreate your development environment, roughly speaking. First you want to convert your requirements.txt to Pipenv. Then you can run pipenv graph and find your top level dependencies — this is basically what you want in your Pipfile. In your Pipfile you want to then start ‘unpinning’ those packages by changing from package = “==x.y” to package = “*”. Only do this for packages you actually don’t mind upgrading when possible. If there are any specific packages from requirements.txt where keeping their version is important you can pin those here too.

Next you can just pipenv install — this creates the local copy of everything. If you want to include whatever your setup.py says, you can pipenv install -e .. This creates a Pipfile.lock which has pinned versions of every package in your environment. Every time you run pipenv install it updates this file.

When you are ready to deploy, you’ll want to include your Pipfile and Pipfile.lock and copy them with the rest of your project into production. Then, depending on your process, if you use docker and you don’t want a virtualenv to be created you will need to pipenv install —system —deploy but if you don’t use docker or you do want to have virtualenv creation and management, you can just pipenv install —deploy

Note that the —deploy flag simply says to fail if the lockfile and the Pipfile are not in sync, rather than attempting to sync them.

1reaction
kennethreitzcommented, Oct 2, 2017

Pipfiles replace requirements.txt usage. They don’t replace setup.py.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Basic production environment - BMC Documentation
The BMC Atrium Orchestrator Development Studio component is installed on a separate Windows desktop computer. In this configuration, the single ...
Read more >
Installation Instructions for production environments - SQUAD
Installation using the Python package manager pip¶. Make sure you have the pip Python package manager installed on your Python 3 environment, and...
Read more >
sharp-missing-in-production - Next.js
For a production environment using next start , it is strongly ... Install sharp by running one of the following commands in your...
Read more >
Managing Production and Sandbox Environments - Business ...
Use the Business Central administration center to manage your tenant environments, both sandbox and production environments.
Read more >
Production Environments - Galaxy Documentation
The basic installation instructions are suitable for development by a single user, but when setting up Galaxy for a multi-user production environment, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found