def test_load_config_file(tmp_path): config_path = tmp_path / "foo.yml" with open(str(config_path), "w") as f: f.write(".+:\n" ' version_template: "1.0.0"\n' " map:\n" " attrs: attr\n" " depends:\n" " - python-foobar\n") args = ["--config", str(config_path)] parser = parse_args(args) settings = load(parser.config) assert settings.get_ctx("foo").map["attrs"] == "attr" assert settings.get_ctx("foo").depends[0] == "python-foobar"
def test_load_config_file(tmp_path): config_path = tmp_path / 'foo.yml' with open(str(config_path), 'w') as f: f.write('.+:\n' ' version_template: "1.0.0"\n' ' map:\n' ' attrs: attr\n' ' depends:\n' ' - python-foobar\n') args = ['--config', str(config_path)] parser = parse_args(args) settings = load(parser.config) assert settings.get_ctx('foo').map['attrs'] == 'attr' assert settings.get_ctx('foo').depends[0] == 'python-foobar'
def debianize(args): """ Convert wheels found in args.search_paths in debian source packages """ # load config file if args.config: settings = load(args.config) elif Path('wheel2deb.yml').is_file(): settings = load('wheel2deb.yml') else: settings = Settings() # config file takes precedence over command line arguments settings.default_ctx.update(vars(args)) if not args.output.exists(): args.output.mkdir() # list all python wheels in search paths files = [] for path in [Path(path) for path in args.search_paths]: files.extend(path.glob('*.whl')) files = sorted(files, key=lambda x: x.name) filenames = list(map(lambda x: x.name, files)) if not args.include: args.include = filenames # remove excluded wheels if args.exclude: args.include = \ list(filter(lambda x: x not in args.exclude, args.include)) # fail if some input wheel was not found in search paths missing = list(filter(lambda x: x not in filenames, args.include)) if missing: logger.critical('File(s) not found: %s', ', '.join(missing)) exit(1) logger.task('Unpacking %s wheels', len(files)) wheels = [] for file in files: wheel = Wheel(file, EXTRACT_PATH / file.name[:-4]) ctx = settings.get_ctx(wheel.filename) if not wheel.cpython_supported: # ignore wheels that are not cpython compatible logger.warning('%s does not support cpython', wheel.filename) continue if not wheel.version_supported(ctx.python_version): # ignore wheels that are not compatible specified python version logger.warning('%s does not support python %s', wheel.filename, ctx.python_version) continue logger.info('%s', wheel.filename) wheels.append(wheel) packages = [] for wheel in wheels: if wheel.filename in args.include: logger.task('Debianizing wheel %s', wheel) ctx = settings.get_ctx(wheel.filename) package = SourcePackage(ctx, wheel, args.output, extras=wheels) package.create() packages.append(package)