Ejemplo n.º 1
0
def test_activate_virtualenv_no_source():
    command = activate_virtualenv(source=False)
    venv = Project().virtualenv_location
    assert command == '{0}/bin/activate'.format(venv)
Ejemplo n.º 2
0
from setuptools import setup, find_packages
from pipenv.project import Project
from pipenv.utils import convert_deps_to_pip

pfile = Project(chdir=False).parsed_pipfile
requires = convert_deps_to_pip(pfile['packages'], r=False)
test_requires = convert_deps_to_pip(pfile['dev-packages'], r=False)

setup(name='voctokey',
      version='0.0.1',
      description='Keyboard control for voctocore',
      classifiers=[
          'Development Status :: 3 - Alpha',
          'License :: OSI Approved :: Apache Software License',
          'Topic :: Utilities',
          "Programming Language :: Python",
          "Programming Language :: Python :: 3",
          "Programming Language :: Python :: 3.3",
          "Programming Language :: Python :: 3.4",
          "Programming Language :: Python :: 3.5",
          "Programming Language :: Python :: 3.6",
      ],
      keywords='keyboard shortcut',
      url='http://github.com/mre/voctokey',
      author='Matthias Endler',
      author_email='*****@*****.**',
      license='Apache',
      packages=find_packages(),
      install_requires=requires,
      tests_require=test_requires,
      entry_points={
Ejemplo n.º 3
0
#!/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('#')]

BUILD_REQUIRED_FILES = ('.VERSION',
                        'LICENSE',
                        'AUTHORS.rst',
                        'CONTRIBUTING.rst',
                        'HISTORY.rst',
                        'README.rst',
                        'USAGE.rst',
                        'Pipfile',
                        'Pipfile.lock',
Ejemplo n.º 4
0
def patched_cli(ctx, working_dir, python):

    if working_dir:
        if not os.path.isdir(working_dir):
            working_dir = os.path.dirname(working_dir)
        os.environ["PIPENV_PIPFILE"] = os.path.join(working_dir, "Pipfile")

    # we need to import environments and modify PIPENV_PIPFILE
    # to ensure that Project is imported with the right value
    from pipenv import environments
    environments.PIPENV_PIPFILE = os.environ.get("PIPENV_PIPFILE")
    from pipenv.project import Project

    if PYENV_INSTALLED:

        workon = None
        venv_name = None

        if python and python.startswith(PYENV_ROOT) and "bin/python" in python:
            workon = os.path.dirname(os.path.dirname(python))
            workon = os.path.join(workon, "envs")

        try:
            venv_name = Project().virtualenv_name
        except AttributeError:
            # AttributeError is raised when pipenv does not find a valid
            # Pipfile and attempts spliting None
            pass

        if not workon and venv_name:
            versions = delegator.run("pyenv versions").out.splitlines(
                keepends=False)
            for v in versions:
                v = v.split()
                v = v[0] if v[0] != "*" else v[1]
                if "/envs/" in v:
                    if v.endswith(venv_name):
                        workon = os.path.join(PYENV_ROOT, "versions",
                                              os.path.dirname(v.strip()))
                        break

        if not workon:
            c = delegator.run("pyenv which python")
            c.block()
            workon = os.path.dirname(os.path.dirname(c.out.strip()))
            workon = os.path.join(workon, "envs")

        os.environ["WORKON_HOME"] = workon
        ctx.call_on_close(venv_symlink(workon, venv_name))

    if python:
        ctx.args = ["--python", python] + ctx.args

    try:
        venv_exists = Project().virtualenv_exists
    except:
        venv_exists = False

    if not ("install" in ctx.args or venv_exists):
        click.echo(
            crayons.red(
                "No virtualenv has been created for this project yet!"),
            err=True,
        )
        ctx.abort()

    ctx.invoke(cli, ctx.args)
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())
Ejemplo n.º 6
0
def get_top_level_dependencies():
    packages = Project().parsed_pipfile.get('packages', {}).keys()
    dev_packages = Project().parsed_pipfile.get('dev-packages', {}).keys()
    return packages, dev_packages
Ejemplo n.º 7
0
def project():
    from pipenv.project import Project
    return Project()
Ejemplo n.º 8
0
def main():

    parser = argparse.ArgumentParser(
        description='Generate requirements*.txt matching Pipfile*')
    parser.add_argument(
        '-o',
        '--output',
        help='Generate only the main requirements.txt to a different file')
    parser.add_argument('-f',
                        '--freeze',
                        action="store_true",
                        help='Generate requirements*.txt with frozen versions')

    args = parser.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")

    # Create pip-compatible dependency list
    def_req = [
        formatPipenvEntryForRequirements(n, i)
        for n, i in pipfile.get("default", {}).items()
    ]
    dev_req = [
        formatPipenvEntryForRequirements(n, i)
        for n, i in pipfile.get("develop", {}).items()
    ]

    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`.",
        "################################################################################",
        ""
    ]

    if def_req:
        if args.output:
            requirement_txt = args.output
        else:
            requirement_txt = "requirements.txt"
        with open(requirement_txt, "w") as f:
            f.write("\n".join(intro + sorted(def_req)) + "\n")
        print("generated: {0}".format(requirement_txt))

    if args.output:
        return

    if dev_req:
        with open("requirements-dev.txt", "w") as f:
            f.write("\n".join(intro + sorted(dev_req)) + "\n")
        print("generated: requirements-dev.txt")
Ejemplo n.º 9
0
        if key in os.environ:
            print(f"  - `{key}`: `{os.environ[key]}`")
    print("")
    print("")
    print("---------------------------")
    print("")
    if project.pipfile_exists:
        print_utf(f"Contents of `Pipfile` ({project.pipfile_location!r}):")
        print("")
        print("```toml")
        with open(project.pipfile_location) as f:
            print(f.read())
        print("```")
        print("")
    if project.lockfile_exists:
        print("")
        print_utf(
            f"Contents of `Pipfile.lock` ({project.lockfile_location!r}):")
        print("")
        print("```json")
        with open(project.lockfile_location) as f:
            print(f.read())
        print("```")
    print("</details>")


if __name__ == "__main__":
    from pipenv.project import Project

    get_pipenv_diagnostics(Project())
Ejemplo n.º 10
0
def requirements():
    pipfile = Project(chdir=False).parsed_pipfile
    return convert_deps_to_pip(pipfile['packages'], r=False)
Ejemplo n.º 11
0
from setuptools import find_packages, setup
from pipenv.project import Project
from pipenv.utils import convert_deps_to_pip

import hutils

with open("README.md", "r", encoding="utf-8") as f:
    description = f.read()

setup(
    name="hutils",
    version=hutils.__version__,
    description="a charming python web util-library",
    long_description=description,
    long_description_content_type="text/markdown",
    author="ZaiHui Dev",
    author_email="*****@*****.**",
    url="https://github.com/zaihui/hutils/",
    license="MIT License",
    install_requires=convert_deps_to_pip(Project(chdir=False).parsed_pipfile["packages"], r=False),
    packages=find_packages(exclude=["tests"]),
    classifiers=[
        "License :: OSI Approved :: MIT License",
        "Programming Language :: Python :: 3",
        "Programming Language :: Python :: 3.5",
        "Programming Language :: Python :: 3.6",
        "Programming Language :: Python :: 3.7",
        "Programming Language :: Python :: 3.8",
    ],
)
Ejemplo n.º 12
0
def test_proper_names_unamanged_virtualenv(PipenvInstance, pypi):
    with PipenvInstance(chdir=True, pypi=pypi) as p:
        c = delegator.run('python -m virtualenv .venv')
        assert c.return_code == 0
        project = Project()
        assert project.proper_names == []