Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
settings.DEFAULT_PYTHON_VERSION)),
('spam', '2', 'python2dist(spam)'),
('SPAM', '2', 'python2dist(spam)'),
('Spam$SPam', '2', 'python2dist(spam-spam)'),
('spam', '3', 'python3dist(spam)'),
('spam.spam', '3', 'python3dist(spam.spam)'),
])
def test_rpm_name(self, input, py_ver, expected):
if py_ver:
assert self.anc.rpm_name(input, py_ver) == expected
else:
assert self.anc.rpm_name(input) == expected
('pyspam', settings.DEFAULT_PYTHON_VERSION, 'pyspam'),
('python-foo', '26', 'python26-foo'),
('python-foo', '3', 'python-foo'),
('python2-foo', None, 'python-foo'),
('python2-foo', '3', 'python-foo'),
('python26-foo', '3', 'python-foo'),
('python26-foo', None, 'python-foo'),
('python-foo', '25', 'python25-foo'),
('python2-devel', 3, 'python3-devel'),
('python2-devel', None, 'python2-devel'),
('python2dist(spam)', 3, 'python3dist(spam)'),
('python2dist(spam)', 2, 'python2dist(spam)'),
])
def test_rpm_versioned_name(self, name, version, expected):
assert NameConvertor.rpm_versioned_name(name, version) == expected
def setup_method(self, method):
self.temp_dir = tempfile.mkdtemp()
self.venv = VirtualEnv(name=None, version=None,
temp_dir=self.temp_dir,
name_convertor=NameConvertor(DEFAULT_DISTRO),
base_python_version=DEFAULT_PYTHON_VERSION)
'default: "{0}").'.format(settings.DEFAULT_PYTHON_VERSION),
default=None,
metavar='BASE_PYTHON')
@click.option('-p',
help='Additional Python versions to include in the specfile '
'(e.g -p2 for python2 subpackage). Can be specified multiple '
'times. Specify additional version or use -b explicitly to '
'disable default.',
default=[],
multiple=True, metavar='PYTHON_VERSIONS')
@click.option('-s',
help='Spec file ~/rpmbuild/SPECS/python-package_name.spec will '
'be created (default: prints spec file to stdout).',
is_flag=True)
@click.option('--srpm',
help='When used pyp2rpm will produce srpm instead of printing '
'specfile into stdout.',
def __init__(self, name, version, temp_dir, name_convertor,
base_python_version):
self.name = name
self.version = version
self.temp_dir = temp_dir
self.name_convertor = name_convertor
if not base_python_version:
base_python_version = DEFAULT_PYTHON_VERSION
python_version = 'python' + base_python_version
self.env = VirtualEnvironment(temp_dir + '/venv',
python=python_version)
try:
self.env.open_or_create()
except (ve.VirtualenvCreationException,
ve.VirtualenvReadonlyException):
raise VirtualenvFailException('Failed to create virtualenv')
self.dirs_before_install = DirsContent()
self.dirs_after_install = DirsContent()
self.dirs_before_install.fill(temp_dir + '/venv/')
self.data = {}
def rpm_name(self, name, python_version=settings.DEFAULT_PYTHON_VERSION,
pkg_name=False):
if pkg_name:
return super(AutoProvidesNameConvertor, self).rpm_name(
name, python_version)
canonical_name = safe_name(name).lower()
return "python{0}dist({1})".format(python_version, canonical_name)
def __init__(self, package=None, version=None, prerelease=False,
save_dir=None,
template=settings.DEFAULT_TEMPLATE,
distro=settings.DEFAULT_DISTRO,
base_python_version=settings.DEFAULT_PYTHON_VERSION,
python_versions=[],
rpm_name=None, proxy=None, venv=True, autonc=False):
self.package = package
self.version = version
self.prerelease = prerelease
self.save_dir = save_dir
self.base_python_version = base_python_version
self.python_versions = list(python_versions)
self.template = template
self.distro = distro
if not self.template.endswith('.spec'):
self.template = '{0}.spec'.format(self.template)
self.rpm_name = rpm_name
self.proxy = proxy
self.venv = venv
self.autonc = autonc
def python_bin_for_python_version(name, version, default_string='__python2'):
if version == settings.DEFAULT_PYTHON_VERSION:
return name
else:
return name.replace(default_string, '__python{0}'.format(version))