dephell / dephell_discover Goto Github PK
View Code? Open in Web Editor NEWFind project modules and data files (packages and package_data for setup.py).
License: MIT License
Find project modules and data files (packages and package_data for setup.py).
License: MIT License
The full list of excluded files:
git ls-files --exclude-standard --deleted --others -i
Example of command call in flit
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.
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'
.
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
==> 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:
P.S. Why does this use type(foo) is bar
instead of isinstance(foo, bar)
?
$ 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
The last commit on Github was updating the version number in pyproject.toml to 0.2.5 -- where is 0.2.6 from and what does it change?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.