Give Pipenv different sources or git urls for Production and Development

Viewed 582

We are using Pipenv and Pipfiles for managing our Python package requirements. We use a private GitLab server to manage our code, including as a source for packages, eg via:

ourpkg = {ref = "master", git = "ssh://git@gitlab.company:/ourpkg.git"}

However, the code is deployed to a separate Prod environment which has internet access (and so can pull down pypi packges), but cannot access our gitlab server.

Our first proposed solution was to mirror the package repos on the Prod environment. However, while Pipenv allows environment variables in a package index source it doesn't allow them in git urls in packages, so we can't define a different base URL in each environment that way.

Our second proposed solution was to host the packages on a private package index, use that as a source on the Prod environment. Then specify prod links under [packages], and the gitlab git urls under [dev-packages].

[[source]]
url = "https://pypi.prodenvironment/
name = "prodindex"

[packages]
ourpkg = {version = "*", index = "prodindex"}

[dev-packages]
ourpkg = {ref = "master", git = "ssh://git@gitlab.company:/ourpkg.git"}

However, this fails on installing in dev as the [packages] requirements take precedence over [dev-packages], and Pipenv does not allow deploy-only requirements.

How can we specify a git repo source for a package in dev, and a different (index or git repo) source for a package in production?

0 Answers
Related