def test_matched_by_file(self):
        filename = 'tests/fixture/sample_blacklist.txt'
        self.assertTrue(requirements.matched_by_file('any_version', 1.1, filename))
        self.assertFalse(requirements.matched_by_file('not_mentioned', 0.3, filename))

        self.assertTrue(requirements.matched_by_file('version_1_0', 1.0, filename))
        self.assertFalse(requirements.matched_by_file('version_1_0', 0.9, filename))

        self.assertTrue(requirements.matched_by_file('at_least_0_5', 1.0, filename))
        self.assertTrue(requirements.matched_by_file('at_least_0_5', 0.5, filename))
        self.assertFalse(requirements.matched_by_file('at_least_0_5', 0.4, filename))

        self.assertTrue(requirements.matched_by_file('below_2_0', 1.0, filename))
        self.assertFalse(requirements.matched_by_file('below_2_0', 2.0, filename))
Beispiel #2
0
 def _should_package_be_build(self, package, version):
     if self._devpi_client.package_version_exists(package, version):
         self._log_skip('Skipping %s %s as is already available on the index.', package, version)
         return False
     elif self._pure_index_client and self._pure_index_client.package_version_exists(package, version):
         self._log_skip('Skipping %s %s as is already available on the pure index.', package, version)
         return False
     elif self._blacklist and requirements.matched_by_file(package, version, self._blacklist):
         self._log_skip('Skipping %s %s as it is matched by the blacklist.', package, version)
         return False
     return True
Beispiel #3
0
    def _should_package_be_build(self, package, version):
        spec = "{}=={}".format(package, version)

        if self._blacklist and requirements.matched_by_file(package, version, self._blacklist):
            self._log_skip('Skipping %s %s as it is matched by the blacklist.', package, version)
            return False
        elif wheeler.has_compatible_wheel(self._devpi_client.list(spec)):
            self._log_skip('Skipping %s %s as is already available on the index.', package, version)
            return False
        elif self._pure_index_client and wheeler.has_compatible_wheel(self._pure_index_client.list(spec)):
            self._log_skip('Skipping %s %s as is already available on the pure index.', package, version)
            return False
        return True
    def test_matched_by_file(self):
        filename = 'tests/fixture/sample_blacklist.txt'
        self.assertTrue(
            requirements.matched_by_file('any_version', 1.1, filename))
        self.assertFalse(
            requirements.matched_by_file('not_mentioned', 0.3, filename))

        self.assertTrue(
            requirements.matched_by_file('version_1_0', 1.0, filename))
        self.assertFalse(
            requirements.matched_by_file('version_1_0', 0.9, filename))

        self.assertTrue(
            requirements.matched_by_file('at_least_0_5', 1.0, filename))
        self.assertTrue(
            requirements.matched_by_file('at_least_0_5', 0.5, filename))
        self.assertFalse(
            requirements.matched_by_file('at_least_0_5', 0.4, filename))

        self.assertTrue(
            requirements.matched_by_file('below_2_0', 1.0, filename))
        self.assertFalse(
            requirements.matched_by_file('below_2_0', 2.0, filename))
Beispiel #5
0
 def _should_package_be_build(self, package, version):
     if self._devpi_client.package_version_exists(package, version):
         self._log_skip(
             'Skipping %s %s as is already available on the index.',
             package, version)
         return False
     elif self._pure_index_client and self._pure_index_client.package_version_exists(
             package, version):
         self._log_skip(
             'Skipping %s %s as is already available on the pure index.',
             package, version)
         return False
     elif self._blacklist and requirements.matched_by_file(
             package, version, self._blacklist):
         self._log_skip('Skipping %s %s as it is matched by the blacklist.',
                        package, version)
         return False
     return True
Beispiel #6
0
    def _should_package_be_build(self, package, version):
        spec = "{}=={}".format(package, version)

        if self._blacklist and requirements.matched_by_file(
                package, version, self._blacklist):
            self._log_skip('Skipping %s %s as it is matched by the blacklist.',
                           package, version)
            return False
        elif wheeler.has_compatible_wheel(self._devpi_client.list(spec)):
            self._log_skip(
                'Skipping %s %s as is already available on the index.',
                package, version)
            return False
        elif self._pure_index_client and wheeler.has_compatible_wheel(
                self._pure_index_client.list(spec)):
            self._log_skip(
                'Skipping %s %s as is already available on the pure index.',
                package, version)
            return False
        return True
Beispiel #7
0
def main(args=None):
    parser = argparse.ArgumentParser(description='Create wheels for all given project versions and upload them to the given index.')
    parser.add_argument('requirements', help='requirements.txt style file specifying which project versions to package.')
    parser.add_argument('index', help='The index to upload the packaged software to.')
    parser.add_argument('user', help='The user to log in as.')
    parser.add_argument('password', help='Password of the user.')
    parser.add_argument('--blacklist', help='Packages matched by this requirements.txt style file will never be build.')

    args = parser.parse_args(args=args)

    with wheeler.Builder() as builder, devpi.Client(args.index, args.user, args.password) as devpi_client:
        for package, version in requirements.read(args.requirements):

            if devpi_client.package_version_exists(package, version):
                logger.debug('Skipping %s %s as is already available on the index.', package, version)
            elif args.blacklist and requirements.matched_by_file(package, version, args.blacklist):
                logger.info('Skipping %s %s as it is matched by the blacklist.', package, version)
            else:
                logger.info('Building %s %s', package, version)
                try:
                    wheel_file = builder(package, version)
                    devpi_client.upload(wheel_file)
                except wheeler.BuildError as e:
                    logger.exception(e)