Pip freeze does not show repository paths for requirements file

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-30 08:12:38
Jarus

A simple but working workaround would be to install the package with the -e flag like pip install -e git+https://bitbucket.org/DataGreed/django-paramfield.git#egg=django-paramfield.

Then pip freeze shows the full source path of the package. It's not the best way it should be fixed in pip but it's working. The trade off -e (editing flag) is that pip clones the git/hg repo into /path/to/venv/src/packagename and run python setup.py deploy instead of clone it into a temp dir and run python setup.py install and remove the temp dir after the setup of the package.

lazy1

Here's a script that will do that:

#!/usr/bin/env python

from subprocess import check_output
from pkg_resources import get_distribution

def download_url(package):
    dist = get_distribution(package)
    for line in dist._get_metadata('PKG-INFO'):
        if line.startswith('Download-URL:'):
            return line.split(':', 1)[1]


def main(argv=None):
    import sys
    from argparse import ArgumentParser

    argv = argv or sys.argv

    parser = ArgumentParser(
        description='show download urls for installed packages')
    parser.parse_args(argv[1:])

    for package in check_output(['pip', 'freeze']).splitlines():
        print('{}: {}'.format(package, download_url(package) or 'UNKNOWN'))


if __name__ == '__main__':
    main()

This is an old question but I have just worked through this same issue and the resolution Simply add the path to the repo (git in my case) to the requirements fie instead of the package name

i.e.

...
celery==3.0.19
# chunkdata isn't available on PyPi
https://github.com/aaronmccall/chunkdata/zipball/master
distribute==0.6.34
... 

Worked like a charm deplying on heroku

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!