# project from dephell import converters from dephell.controllers import Graph from dephell.models import Requirement from dephell.repositories import WareHouseRepo @pytest.mark.parametrize('converter, path', [ (converters.PIPConverter(lock=False), Path('tests') / 'requirements' / 'attrs-requests.txt'), (converters.PIPConverter(lock=False), Path('tests') / 'requirements' / 'django-deal.txt'), (converters.PIPConverter(lock=False), Path('tests') / 'requirements' / 'scipy-pandas-numpy.txt'), (converters.PIPFileConverter(), Path('tests') / 'requirements' / 'pipfile.toml'), (converters.PIPFileLockConverter(), Path('tests') / 'requirements' / 'pipfile.lock.json'), (converters.PoetryConverter(), Path('tests') / 'requirements' / 'poetry.toml'), (converters.PoetryLockConverter(), Path('tests') / 'requirements' / 'poetry.lock.toml'), (converters.SetupPyConverter(), Path('tests') / 'requirements' / 'setup.py'), (converters.EggInfoConverter(), Path('tests') / 'requirements' / 'egg-info/'), (converters.WheelConverter(), Path('tests') / 'requirements' / 'wheel.whl'), ]) def test_load_dump_load_deps(converter, path): root1 = converter.load(path) reqs1 = Requirement.from_graph(graph=Graph(root1), lock=False) content = converter.dumps(reqs1, project=root1) root2 = converter.loads(content) reqs2 = Requirement.from_graph(graph=Graph(root2), lock=False) map1 = {req.name: req for req in reqs1}
from dephell.repositories import WareHouseRepo @pytest.mark.parametrize('converter, path', [ (converters.PIPConverter(lock=False), Path('tests') / 'requirements' / 'attrs-requests.txt'), (converters.PIPConverter(lock=False), Path('tests') / 'requirements' / 'django-deal.txt'), (converters.PIPConverter(lock=False), Path('tests') / 'requirements' / 'scipy-pandas-numpy.txt'), (converters.PIPFileConverter(), Path('tests') / 'requirements' / 'pipfile.toml'), (converters.PIPFileLockConverter(), Path('tests') / 'requirements' / 'pipfile.lock.json'), (converters.FlitConverter(), Path('tests') / 'requirements' / 'flit.toml'), (converters.PoetryConverter(), Path('tests') / 'requirements' / 'poetry.toml'), (converters.PoetryLockConverter(), Path('tests') / 'requirements' / 'poetry.lock.toml'), (converters.SetupPyConverter(), Path('tests') / 'requirements' / 'setup.py'), (converters.EggInfoConverter(), Path('tests') / 'requirements' / 'egg-info'), (converters.WheelConverter(), Path('tests') / 'requirements' / 'wheel.whl'), ]) def test_load_dump_load_deps(converter, path): root1 = converter.load(path) reqs1 = Requirement.from_graph(graph=Graph(root1), lock=False) content = converter.dumps(reqs1, project=root1)
from dephell.controllers import DependencyMaker, Graph, RepositoriesRegistry from dephell.models import Requirement, RootDependency root_path = Path(__file__).parent.parent / 'requirements' @pytest.mark.allow_hosts() @pytest.mark.parametrize('converter, path', [ (converters.PIPConverter(lock=False), root_path / 'attrs-requests.txt'), (converters.PIPConverter(lock=False), root_path / 'django-deal.txt'), (converters.PIPConverter(lock=False), root_path / 'scipy-pandas-numpy.txt'), (converters.PIPFileConverter(), root_path / 'pipfile.toml'), (converters.PIPFileLockConverter(), root_path / 'pipfile.lock.json'), (converters.FlitConverter(), root_path / 'flit.toml'), (converters.PoetryConverter(), root_path / 'poetry.toml'), (converters.PoetryLockConverter(), root_path / 'poetry.lock.toml'), (converters.SetupPyConverter(), root_path / 'setup.py'), (converters.EggInfoConverter(), root_path / 'egg-info'), (converters.WheelConverter(), root_path / 'wheel.whl'), ]) def test_load_dump_load_deps(converter, path): root1 = converter.load(path) reqs1 = Requirement.from_graph(graph=Graph(root1), lock=False) content = converter.dumps(reqs1, project=root1) root2 = converter.loads(content) reqs2 = Requirement.from_graph(graph=Graph(root2), lock=False) map1 = {req.name: req for req in reqs1} map2 = {req.name: req for req in reqs2}
from dephell.controllers import Graph from dephell.models import Requirement from dephell.repositories import WareHouseRepo @pytest.mark.parametrize('converter, path', [ (converters.PIPConverter(lock=False), './tests/requirements/attrs-requests.txt'), (converters.PIPConverter(lock=False), './tests/requirements/django-deal.txt'), (converters.PIPConverter(lock=False), './tests/requirements/scipy-pandas-numpy.txt'), (converters.PIPFileConverter(), './tests/requirements/pipfile.toml'), (converters.PIPFileLockConverter(), './tests/requirements/pipfile.lock.json'), (converters.PoetryConverter(), './tests/requirements/poetry.toml'), (converters.PoetryLockConverter(), './tests/requirements/poetry.lock.toml'), (converters.SetupPyConverter(), './tests/requirements/setup.py'), (converters.EggInfoConverter(), './tests/requirements/egg-info/'), (converters.WheelConverter(), './tests/requirements/wheel.whl'), ]) def test_load_dump_load_deps(converter, path): root1 = converter.load(path) reqs1 = Requirement.from_graph(graph=Graph(root1), lock=False) content = converter.dumps(reqs1, project=root1) root2 = converter.loads(content) reqs2 = Requirement.from_graph(graph=Graph(root2), lock=False) map1 = {req.name: req for req in reqs1}
""" Замена оригинальной команде `dephell convert deps` тк иногда с ней бывают проблемы и она падает с TypeError """ import pathlib from dephell import converters from dephell.controllers import Graph from dephell.models import Requirement BASEDIR = pathlib.Path(__file__).parent if __name__ == '__main__': pc = converters.PoetryConverter() spc = converters.SetupPyConverter() root = pc.load(BASEDIR.joinpath('pyproject.toml')) if root.readme.markup == 'md': # SetupPyConverter принудительно конвертирует README в rst # чтобы этого не допустить - обманываем его root.readme.markup = 'rst' reqs = Requirement.from_graph(graph=Graph(root), lock=False) content = spc.dumps(reqs, project=root) BASEDIR.joinpath('setup.py').write_text(content) print('setup.py was updated successfully')