Giter Club home page Giter Club logo

dephell_discover's Issues

gitignore support

The full list of excluded files:

git ls-files --exclude-standard --deleted --others -i

Example of command call in flit

I want to be able to include package_data without an extension

I'm having an issue with including a couple of files that I explicitly mention in my pyproject.toml but that don't end up in the package_data list of the converted setup.py

After a lot of trial and error, I started looking into how dephell actually identifies the files to be included. It appears that you're making the assumption that files without an extension are to be ignored.

Would you consider adapting this behavior? As far as I know, it's not bad practice to allow for files without an extension to be packaged up.

# skip dirs, python files and files without extension

ERROR IndexError: list index out of range when trying to convert deps

Problem

When trying to execute deps convert cmd on project which contains # coding=utf-8 in some files, I get this error:

❯ dephell deps convert --from=pip --to=pyproject.toml --traceback
WARNING cannot find config file 
ERROR IndexError: list index out of range 
Traceback (most recent call last):
  File "/home/rocky/.local/share/dephell/venvs/dephell/lib/python3.6/site-packages/dephell/cli.py", line 79, in main
    result = task()
  File "/home/rocky/.local/share/dephell/venvs/dephell/lib/python3.6/site-packages/dephell/commands/deps_convert.py", line 78, in __call__
    'project': resolver.graph.metainfo,
  File "/home/rocky/.local/share/dephell/venvs/dephell/lib/python3.6/site-packages/dephell/controllers/_graph.py", line 239, in metainfo
    return RootDependency.get_metainfo(*self._roots)
  File "/home/rocky/.local/share/dephell/venvs/dephell/lib/python3.6/site-packages/dephell/models/root.py", line 130, in get_metainfo
    info = root.package.metainfo
  File "/home/rocky/.local/share/dephell/venvs/dephell/lib/python3.6/site-packages/dephell_discover/_cached_propery.py", line 18, in __get__
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/home/rocky/.local/share/dephell/venvs/dephell/lib/python3.6/site-packages/dephell_discover/_root.py", line 84, in metainfo
    return MetaInfo.parse(paths=paths)
  File "/home/rocky/.local/share/dephell/venvs/dephell/lib/python3.6/site-packages/dephell_discover/_metainfo.py", line 56, in parse
    lines.extend(cls._parse_file(path=subpath))
  File "/home/rocky/.local/share/dephell/venvs/dephell/lib/python3.6/site-packages/dephell_discover/_metainfo.py", line 29, in _parse_file
    line = Line.parse(content=content, row=row, path=path)
  File "/home/rocky/.local/share/dephell/venvs/dephell/lib/python3.6/site-packages/dephell_discover/_line.py", line 46, in parse
    if type(tree.body[0]) is not ast.Assign:  # type: ignore
IndexError: list index out of range

This happens because quick check here doesn't work properly with any lines, which contains =:

def parse(cls, content: str, row: int, path: Path) -> Optional['Line']:
        if '=' not in content:
            return None

In this case, in content arg was this string: '# coding=utf-8\n'.

Proposed solution

Change:

if type(tree.body[0]) is not ast.Assign:
    return None

to:

if not tree.body or type(tree.body[0]) is not ast.Assign:
    return None

tests fail on python 3.8

==> Starting check()...
============================= test session starts ==============================
platform linux -- Python 3.8.0, pytest-5.2.2, py-1.8.0, pluggy-0.13.0
rootdir: /build/python-dephell-discover/src/dephell_discover-0.2.8
collected 27 items

tests/test_metainfo.py FFFFF.                                            [ 22%]
tests/test_root.py .....................                                 [100%]

=================================== FAILURES ===================================
__________________ test_vars[__license__ = "MIT"-license-MIT] __________________

tmp_path = PosixPath('/tmp/pytest-of-builduser/pytest-0/test_vars___license______MIT__0')
content = '__license__ = "MIT"', name = 'license', expected = 'MIT'

    @pytest.mark.parametrize('content, name, expected', [
        ('__license__ = "MIT"', 'license', 'MIT'),
    
        ('__version__ = "0.2.7"', 'version', '0.2.7'),
        ('__version__ = ("0", "2", "7")', 'version', '0.2.7'),
        # ('__version__ = (0, 2, 7)', 'version', '0.2.7'),
    
        ('__author__ = "Gram"', 'authors', ['Gram']),
        ('__authors__ = ["Gram"]', 'authors', ['Gram']),
    
    ])
    def test_vars(tmp_path: Path, content: str, name: str, expected):
        path = tmp_path / 'lol.py'
        path.write_text(content)
        info = MetaInfo.parse(paths=[path])
>       assert getattr(info, name) == expected
E       AssertionError: assert None == 'MIT'
E        +  where None = getattr(MetaInfo(lines=[]), 'license')

tests/test_metainfo.py:23: AssertionError
________________ test_vars[__version__ = "0.2.7"-version-0.2.7] ________________

tmp_path = PosixPath('/tmp/pytest-of-builduser/pytest-0/test_vars___version______0_2_70')
content = '__version__ = "0.2.7"', name = 'version', expected = '0.2.7'

    @pytest.mark.parametrize('content, name, expected', [
        ('__license__ = "MIT"', 'license', 'MIT'),
    
        ('__version__ = "0.2.7"', 'version', '0.2.7'),
        ('__version__ = ("0", "2", "7")', 'version', '0.2.7'),
        # ('__version__ = (0, 2, 7)', 'version', '0.2.7'),
    
        ('__author__ = "Gram"', 'authors', ['Gram']),
        ('__authors__ = ["Gram"]', 'authors', ['Gram']),
    
    ])
    def test_vars(tmp_path: Path, content: str, name: str, expected):
        path = tmp_path / 'lol.py'
        path.write_text(content)
        info = MetaInfo.parse(paths=[path])
>       assert getattr(info, name) == expected
E       AssertionError: assert None == '0.2.7'
E        +  where None = getattr(MetaInfo(lines=[]), 'version')

tests/test_metainfo.py:23: AssertionError
____________ test_vars[__version__ = ("0", "2", "7")-version-0.2.7] ____________

tmp_path = PosixPath('/tmp/pytest-of-builduser/pytest-0/test_vars___version_______0___0')
content = '__version__ = ("0", "2", "7")', name = 'version', expected = '0.2.7'

    @pytest.mark.parametrize('content, name, expected', [
        ('__license__ = "MIT"', 'license', 'MIT'),
    
        ('__version__ = "0.2.7"', 'version', '0.2.7'),
        ('__version__ = ("0", "2", "7")', 'version', '0.2.7'),
        # ('__version__ = (0, 2, 7)', 'version', '0.2.7'),
    
        ('__author__ = "Gram"', 'authors', ['Gram']),
        ('__authors__ = ["Gram"]', 'authors', ['Gram']),
    
    ])
    def test_vars(tmp_path: Path, content: str, name: str, expected):
        path = tmp_path / 'lol.py'
        path.write_text(content)
        info = MetaInfo.parse(paths=[path])
>       assert getattr(info, name) == expected
E       AssertionError: assert None == '0.2.7'
E        +  where None = getattr(MetaInfo(lines=[]), 'version')

tests/test_metainfo.py:23: AssertionError
_______________ test_vars[__author__ = "Gram"-authors-expected3] _______________

tmp_path = PosixPath('/tmp/pytest-of-builduser/pytest-0/test_vars___author______Gram__0')
content = '__author__ = "Gram"', name = 'authors', expected = ['Gram']

    @pytest.mark.parametrize('content, name, expected', [
        ('__license__ = "MIT"', 'license', 'MIT'),
    
        ('__version__ = "0.2.7"', 'version', '0.2.7'),
        ('__version__ = ("0", "2", "7")', 'version', '0.2.7'),
        # ('__version__ = (0, 2, 7)', 'version', '0.2.7'),
    
        ('__author__ = "Gram"', 'authors', ['Gram']),
        ('__authors__ = ["Gram"]', 'authors', ['Gram']),
    
    ])
    def test_vars(tmp_path: Path, content: str, name: str, expected):
        path = tmp_path / 'lol.py'
        path.write_text(content)
        info = MetaInfo.parse(paths=[path])
>       assert getattr(info, name) == expected
E       AssertionError: assert [] == ['Gram']
E         Right contains one more item: 'Gram'
E         Use -v to get the full diff

tests/test_metainfo.py:23: AssertionError
_____________ test_vars[__authors__ = ["Gram"]-authors-expected4] ______________

tmp_path = PosixPath('/tmp/pytest-of-builduser/pytest-0/test_vars___authors_______Gram0')
content = '__authors__ = ["Gram"]', name = 'authors', expected = ['Gram']

    @pytest.mark.parametrize('content, name, expected', [
        ('__license__ = "MIT"', 'license', 'MIT'),
    
        ('__version__ = "0.2.7"', 'version', '0.2.7'),
        ('__version__ = ("0", "2", "7")', 'version', '0.2.7'),
        # ('__version__ = (0, 2, 7)', 'version', '0.2.7'),
    
        ('__author__ = "Gram"', 'authors', ['Gram']),
        ('__authors__ = ["Gram"]', 'authors', ['Gram']),
    
    ])
    def test_vars(tmp_path: Path, content: str, name: str, expected):
        path = tmp_path / 'lol.py'
        path.write_text(content)
        info = MetaInfo.parse(paths=[path])
>       assert getattr(info, name) == expected
E       AssertionError: assert [] == ['Gram']
E         Right contains one more item: 'Gram'
E         Use -v to get the full diff

tests/test_metainfo.py:23: AssertionError
========================= 5 failed, 22 passed in 1.95s =========================

Broken due to use of ast.Str, which doesn't match type checks any more due to https://bugs.python.org/issue32892

Used here:

if type(value) is ast.Str:

if type(element) is not ast.Str:

P.S. Why does this use type(foo) is bar instead of isinstance(foo, bar)?

IndexError: list index out of range when trying to build

$ dephell project build --from pyproject.toml --traceback
WARNING cannot find tool.dephell section in the config (path=pyproject.toml)
INFO dumping... (format=setuppy)
INFO dumping... (format=egginfo)
INFO dumping... (format=sdist)
ERROR IndexError: list index out of range 

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/dephell/cli.py", line 115, in main
    result = task()
  File "/usr/local/lib/python3.7/dist-packages/dephell/commands/project_build.py", line 63, in __call__
    project=resolver.graph.metainfo,
  File "/usr/local/lib/python3.7/dist-packages/dephell/converters/sdist.py", line 127, in dump
    self._write_additional_files(tar=tar, project=project, subdir=subdir)
  File "/usr/local/lib/python3.7/dist-packages/dephell/converters/sdist.py", line 179, in _write_additional_files
    package_size = get_path_size(path=project.package.packages[0].path)
IndexError: list index out of range

experienced this with 3 of 3 projects that I manage with poetry

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.