How to use the pipenv.project.Project function in pipenv

To help you get started, we’ve selected a few pipenv examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pypa / pipenv / tests / test_project.py View on Github external
def test_proper_names(self):
        proj = pipenv.project.Project()
        assert proj.virtualenv_location in proj.proper_names_location
        assert isinstance(proj.proper_names, list)
github pypa / pipenv / tests / test_project.py View on Github external
def test_parsed_pipfile(self):
        proj = pipenv.project.Project()

        # Create test space.
        delegator.run('mkdir test_pipfile')
        with open('test_pipfile/Pipfile', 'w') as f:
            f.write('[[source]]\nurl = \'https://pypi.python.org/simple\'\n'
                    'verify_ssl = true\n\n\n[packages]\n'
                    'requests = { extras = [\'socks\'] }')

        proj._pipfile_location = 'test_pipfile/Pipfile'
        pfile = proj.parsed_pipfile

        # Cleanup test space.
        delegator.run('rm -fr test_pipfile')

        # Confirm source added correctly.
        assert 'source' in pfile
github pypa / pipenv / tests / test_project.py View on Github external
def test_internal_pipfile(self):
        proj = pipenv.project.Project()

        # Create test space.
        delegator.run('mkdir test_internal_pipfile')
        with open('test_internal_pipfile/Pipfile', 'w') as f:
            f.write('[[source]]\nurl = \'https://pypi.python.org/simple\'\n'
                    'verify_ssl = true\n\n\n[packages]\n'
                    'Requests = { extras = [\'socks\'] }\nFlask_Auth = \'*\'\n\n\n'
                    '[dev-packages]\nclick = \'*\'\nDjango = {git = '
                    '"https://github.com/django/django.git", ref="1.10"}\n')

        proj._pipfile_location = 'test_internal_pipfile/Pipfile'

        p = proj._pipfile

        # Test package names are normalized as expected.
        assert list(p['packages'].keys()) == ['requests', 'flask-auth']
github pypa / pipenv / tests / integration / test_project.py View on Github external
def test_run_in_virtualenv(PipenvInstance):
    with PipenvInstance(chdir=True) as p:
        c = p.pipenv('run pip freeze')
        assert c.return_code == 0
        assert 'Creating a virtualenv' in c.err
        project = Project()
        c = p.pipenv("run pip install click")
        assert c.return_code == 0
        c = p.pipenv("install six")
        assert c.return_code == 0
        c = p.pipenv('run python -c "import click;print(click.__file__)"')
        assert c.return_code == 0
        assert c.out.strip().startswith(str(project.virtualenv_location))
        c = p.pipenv("clean --dry-run")
        assert c.return_code == 0
        assert "click" in c.out
github costastf / locationsharinglib / _CI / bin / create_requirements.py View on Github external
def get_top_level_dependencies(package_type):
    validate_package_type(package_type)
    _type = 'packages' if package_type == 'default' else 'dev-packages'
    return list(Project().parsed_pipfile.get(_type, {}).keys())
github MD-Studio / MDStudio / components / lie_schema / setup.py View on Github external
def pipenv_requires():
    from pipenv.project import Project
    from pipenv.utils import convert_deps_to_pip

    pfile = Project(chdir=True).parsed_pipfile
    return convert_deps_to_pip(pfile['packages'], r = False)
github costastf / toonapilib / setup.py View on Github external
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from setuptools import setup, find_packages
try:
    from pipenv.project import Project
    from pipenv.utils import convert_deps_to_pip

    pfile = Project().parsed_pipfile
    requirements = convert_deps_to_pip(pfile['packages'], r=False)
    test_requirements = convert_deps_to_pip(pfile['dev-packages'], r=False)
except ImportError:
    # get the requirements from the requirements.txt
    requirements = [line.strip()
                    for line in open('requirements.txt').readlines()
                    if line.strip() and not line.startswith('#')]
    # get the test requirements from the test_requirements.txt
    test_requirements = [line.strip()
                         for line in
                         open('dev-requirements.txt').readlines()
                         if line.strip() and not line.startswith('#')]

readme = open('README.rst').read()
history = open('HISTORY.rst').read().replace('.. :changelog:', '')
version = open('.VERSION').read()
github streamlit / streamlit / lib / setup.py View on Github external
import platform
import setuptools
import subprocess

from pipenv.project import Project
from pipenv.utils import convert_deps_to_pip
from sys import version_info

pipfile = Project(chdir=False).parsed_pipfile

# Combine [packages] with either [python3] or [python2]
packages = pipfile["packages"].copy()
if version_info.major == 2:
    packages.update(pipfile["python2"])
else:
    packages.update(pipfile["python3"])
requirements = convert_deps_to_pip(packages, r=False)


# Check whether xcode tools are available before making watchdog a
# dependency (only if the current system is a Mac).
if platform.system() == "Darwin":
    has_xcode = subprocess.call(["xcode-select", "--version"], shell=False) == 0
    has_gcc = subprocess.call(["gcc", "--version"], shell=False) == 0
github costastf / toonapilib / _CI / library / core_library.py View on Github external
def get_top_level_dependencies():
    pip_packages = Project().parsed_pipfile.get('packages', {}).items()
    packages = [Package(name_, version_) for name_, version_ in pip_packages]
    pip_dev_packages = Project().parsed_pipfile.get('dev-packages', {}).items()
    dev_packages = [Package(name_, version_) for name_, version_ in pip_dev_packages]
    LOGGER.debug(f"Packages in Pipfile: {packages}")
    LOGGER.debug(f"Development packages in Pipfile: {dev_packages}")
    return packages, dev_packages
github gsemet / pipenv-to-requirements / pipenv_to_requirements / __init__.py View on Github external
def main():
    args = parse_args()
    if args.freeze:
        pipfile = Project().lockfile_content
    else:
        # pylint: disable=protected-access
        pipfile = Project()._lockfile
        # pylint: enable=protected-access

    def_req = parse_pip_file(pipfile, 'default')
    dev_req = parse_pip_file(pipfile, "develop")

    intro = [
        "################################################################################",
        "# This requirements file has been automatically generated from `Pipfile` with",
        '# `pipenv-to-requirements`', '#', '#',
        '# This has been done to maintain backward compatibility with tools and services',
        '# that do not support `Pipfile` yet.', '#',
        "# Do NOT edit it directly, use `pipenv install [-d]` to modify `Pipfile` and",
        "# `Pipfile.lock` and then regenerate `requirements*.txt`.",
        "################################################################################", ""
    ]