From 217e87a3a8dda1ffae95adcfe564f0e434e4b6e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jelmer=20Vernoo=C4=B3?= Date: Mon, 1 Mar 2021 01:42:44 +0000 Subject: [PATCH] Split out binaries. --- ognibuild/__init__.py | 6 +---- ognibuild/buildsystem.py | 12 ++++++---- ognibuild/outputs.py | 47 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 9 deletions(-) create mode 100644 ognibuild/outputs.py diff --git a/ognibuild/__init__.py b/ognibuild/__init__.py index 762114c..cc0310e 100644 --- a/ognibuild/__init__.py +++ b/ognibuild/__init__.py @@ -64,12 +64,8 @@ class UpstreamRequirement(object): class UpstreamOutput(object): - def __init__(self, family, name): + def __init__(self, family): self.family = family - self.name = name - - def __repr__(self): - return "%s(%r, %r)" % (type(self).__name__, self.family, self.name) def get_declared_dependencies(self): raise NotImplementedError(self.get_declared_dependencies) diff --git a/ognibuild/buildsystem.py b/ognibuild/buildsystem.py index 75a024b..0211613 100644 --- a/ognibuild/buildsystem.py +++ b/ognibuild/buildsystem.py @@ -23,7 +23,11 @@ import re from typing import Optional import warnings -from . import shebang_binary, UpstreamOutput, UnidentifiedError +from . import shebang_binary, UnidentifiedError +from .outputs import ( + BinaryOutput, + PythonPackageOutput, + ) from .requirements import ( BinaryRequirement, PythonPackageRequirement, @@ -202,12 +206,12 @@ class SetupPy(BuildSystem): if self.result is None: raise NotImplementedError for script in self.result.scripts or []: - yield UpstreamOutput("binary", os.path.basename(script)) + yield BinaryOutput(os.path.basename(script)) entry_points = getattr(self.result, 'entry_points', None) or {} for script in entry_points.get("console_scripts", []): - yield UpstreamOutput("binary", script.split("=")[0]) + yield BinaryOutput(script.split("=")[0]) for package in self.result.packages or []: - yield UpstreamOutput("python3", package) + yield PythonPackageOutput(package, python_version="cpython3") class PyProject(BuildSystem): diff --git a/ognibuild/outputs.py b/ognibuild/outputs.py new file mode 100644 index 0000000..bcb305b --- /dev/null +++ b/ognibuild/outputs.py @@ -0,0 +1,47 @@ +#!/usr/bin/python +# Copyright (C) 2019-2020 Jelmer Vernooij +# encoding: utf-8 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +from . import UpstreamOutput + + +class BinaryOutput(UpstreamOutput): + + def __init__(self, name): + super(BinaryOutput, self).__init__('binary') + self.name = name + + def __repr__(self): + return "%s(%r)" % (type(self).__name__, self.name) + + def __str__(self): + return "binary: %s" % self.name + + +class PythonPackageOutput(UpstreamOutput): + + def __init__(self, name, python_version=None): + super(PythonPackageOutput, self).__init__('python-package') + self.name = name + self.python_version = python_version + + def __str__(self): + return "python package: %s" % self.name + + def __repr__(self): + return "%s(%r, python_version=%r)" % ( + type(self).__name__, self.name, self.python_version)