bitbake-setup PyPI Packaging
This is a new series to add PyPI packaging for bitbake-setup. It is based on my development branch here: https://github.com/robwoolley/bitbake/tree/add-pypi-v6
It assumes that the previous linting fixes have been applied but they shouldn't affect the functionality or context.
The main challenge has been to package bitbake-setup independently from the rest of bitbake. This necessitates creating a separate staging directory with pyproject.toml at the root. Details are in the commit messages.
I have tested using these changes to package all of bitbake to make sure that these changes didn't inhibit that from working. That is beyond the scope of work for what I was trying to do.
There are 2 challenges I had to overcome:
1. Ensuring that all primary workflows worked:
(a) Running bitbake and bitbake-setup directly from git
(b) Allowing developers to use pip install -e . to develop in-tree
(c) Enabling pip install in virtual environments and at the system-level
2. Historically, he sys.path modificiations made it easy to refer to the vendorized modules without worrying about system-wide package conflicts. Adding packaging support required that the modules be properly vendorized so they didn't conflict with the upstream packages. Vendorizing the bb module resulted in too much churn as we import bb and its sub-modules across all the files in lib/bb/*
Given that the bb package on PyPI is obscure and hasn't been updated in a very long time, I chose to bundle bb instead of vendorize it.
Here are the detailed testing steps that I used to verify this series before submitting it to bitbake-devel:
$ python3 -m venv venv
$ source venv/bin/activate
$ pip install build
$ BB_SKIP_PYPI_TESTS=no bin/bitbake-selftest -v bb.tests.setup.PyPIPackagingTest
bb.tests.setup.PyPIPackagingTesttest_console_script_help (bb.tests.setup.PyPIPackagingTest)
Verify bitbake-setup --help runs successfully. ... oktest_console_script_list (bb.tests.setup.PyPIPackagingTest)
Verify bitbake-setup list runs successfully. ... oktest_entry_points (bb.tests.setup.PyPIPackagingTest)
Verify console script entry points are correctly defined. ... oktest_imports (bb.tests.setup.PyPIPackagingTest)
Verify all expected modules can be imported from installed package. ... ok test_package_metadata (bb.tests.setup.PyPIPackagingTest)
Verify package metadata is correctly set. ... oktest_vendored_dependencies (bb.tests.setup.PyPIPackagingTest)
Verify vendored dependencies (bs4, ply, progressbar, simplediff) are not bundled in package. ... ok test_version_from_wheel (bb.tests.setup.PyPIPackagingTest)
Verify version is set correctly (not fallback 0.0.0 unless expected). ... ok test_wheel_metadata_file (bb.tests.setup.PyPIPackagingTest)
Verify wheel METADATA file contains required fields. ... ok
----------------------------------------------------------------------
Ran 8 tests in 18.014s
OK
$ contrib/pypi/package-bitbake-setup.py
$ cd packaging_workspace/
$ pip install -e .
$ which bitbake-setup /ala-lpggp31/rwoolley/bitbake-testing/bitbake/venv/bin/bitbake-setup
$ bitbake-setup --version bitbake-setup 2.16.0
$ bitbake-setup list
NOTE: Fetching configuration registry
git://git.openembedded.org/bitbake;protocol=https;branch=master;rev=master
into
/tmp/bitbake-setup-list-v1m6p7s3/.bitbake-setup-cache/configurations
Available configurations:
oe-nodistro-master OpenEmbedded - 'nodistro' basic configuration
oe-nodistro-whinlatter OpenEmbedded - 'nodistro' basic configuration, release 5.3 'whinlatter' (supported until 2026-05-31)
poky-master Poky - The Yocto Project testing distribution configurations and hardware test platforms
poky-whinlatter Poky - The Yocto Project testing distribution configurations and hardware test platforms, release 5.3 'whinlatter' (supported until 2026-05-31)Run 'init' with one of the above configuration identifiers to set up a build.
$ pip uninstall bitbake-setup
$ python3 -m build
$ pip install dist/bitbake_setup-2.16.0-py3-none-any.whl Processing ./dist/bitbake_setup-2.16.0-py3-none-any.whl Installing collected packages: bitbake-setup Successfully installed bitbake-setup-2.16.0
$ cd $(mktemp -d)
$ bitbake-setup init
...
The bitbake configuration files (local.conf, bblayers.conf and more) can be found in
/tmp/tmp.s1MXZQ5XiF/bitbake-builds/poky-whinlatter/build/conf
PATCH 1/6 bitbake: Add checks for importing bb module
The __version__ has been present since bbmake to ensure that the Python script uses the appropriate bb module. This was necessary when bbmake had functional code that had to match the bb module. The code has since been moved into bb/main.py. The skeleton code left in bin/bitbake rarely changes save for bumping the version.
When executed in place, the bitbake script manipulates sys.path to find the bb module in ../lib. This path is inserted to the beginning of sys.path and it cannot be overridden. This path is inserted regardless of whether the bb module is present in the lib directory.
This adds a check for the existence of the lib/bb/__init__.py file before inserting the directory to the beginning of sys.path. This supports bitbake to be executed from inside the git repository.
It deliberately fails in the situation where lib/bb/__init__.py is missing, but the bb package exists inside a site-package directory. This situation was previously possible.
--- bin/bitbake | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-)
bin/bitbake +14 -10
@@ -15,23 +15,27 @@ import sys import warnings warnings.simplefilter("default") -sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(__file__)), - 'lib')) -try: - import bb -except RuntimeError as exc: - sys.exit(str(exc)) +bindir = os.path.abspath(os.path.dirname(__file__)) +libdir = os.path.join(os.path.dirname(bindir), 'lib') +bbfile = os.path.join(libdir, 'bb', '__init__.py') + +if os.path.exists(bbfile): + # Execute bitbake in git repository + try: + sys.path[0:0] = [libdir] + import bb + except ImportError as e: + print(f"Could not import bb from lib: {e}", file=sys.stderr) +else: + print(f"Could not find bb module", file=sys.stderr) + sys.exit(1) from bb import cookerdata from bb.main import bitbake_main, BitBakeConfigParameters, BBMainException bb.utils.check_system_locale() -__version__ = "2.16.0" - if __name__ == "__main__": - if __version__ != bb.__version__: - sys.exit("Bitbake core version and program version mismatch!") try: sys.exit(bitbake_main(BitBakeConfigParameters(sys.argv), cookerdata.CookerConfiguration()))
Signature · 1 line
2.49.0
PATCH 2/6 pypi: Add PyPI packaging for bitbake-setup
In reply to Rob WoolleyWe wish to publish bitbake-setup to PyPI to improve the workflow for new users that are familiar with pip install.
In order to publish bitbake-setup as a standalone package, we must create a staging directory for Python to build the package.
The package-bitbake-setup.py automates the staging of the necessary files. You may supply your desired directory as the first argument, but packaging_workspace in the root of the git repository is chosen by default.
The packaging process and related tests have also been included as part of bitbake-selftest and lib/bb/tests/setup.py. These tests use package-bitbake-setup.py.
The tests include:
* Verify bitbake-setup --help runs successfully.
* Verify bitbake-setup list runs successfully.
* Verify console script entry points are correctly defined.
* Verify all expected modules can be imported from installed package.
* Verify package metadata is correctly set.
* Verify vendored dependencies (bs4, ply, progressbar, simplediff) are not bundled in package.
* Verify version is set correctly (not fallback 0.0.0 unless expected).
* Verify wheel METADATA file contains required fields.
The pyproject.toml, LICENSE, and README.md files are used to create the package and provide information for PyPI.
--- bin/bitbake-selftest | 2 + contrib/pypi/LICENSE | 9 + contrib/pypi/README.md | 42 ++++ contrib/pypi/package-bitbake-setup.py | 79 +++++++ contrib/pypi/pyproject.toml | 92 ++++++++ lib/bb/tests/setup.py | 289 +++++++++++++++++++++++++- 6 files changed, 512 insertions(+), 1 deletion(-) create mode 100644 contrib/pypi/LICENSE create mode 100644 contrib/pypi/README.md create mode 100755 contrib/pypi/package-bitbake-setup.py create mode 100644 contrib/pypi/pyproject.toml
bin/bitbake-selftest +2 -0
@@ -67,6 +67,8 @@ ENV_HELP = """\ Environment variables: BB_SKIP_NETTESTS set to 'yes' in order to skip tests using network connection + BB_SKIP_PYPI_TESTS set to 'no' to run PyPI packaging tests + (default: yes/skip) BB_TMPDIR_NOCLEAN set to 'yes' to preserve test tmp directories """
contrib/pypi/LICENSE new file +9 -0
@@ -0,0 +1,9 @@ +bitbake-setup is licensed under the GNU General Public License version 2.0. See +LICENSE.GPL-2.0-only for further details. + +Individual files contain the following style tags instead of the full license text: + + SPDX-License-Identifier: GPL-2.0-only + +This enables machine processing of license information based on the SPDX +License Identifiers that are here available: http://spdx.org/licenses/
contrib/pypi/README.md new file +42 -0
43 lines not on this page · raw message
contrib/pypi/package-bitbake-setup.py new file +79 -0
79 lines not on this page · raw message
contrib/pypi/pyproject.toml new file +92 -0
92 lines not on this page · raw message
lib/bb/tests/setup.py +288 -1
305 lines not on this page · raw message
Signature · 1 line
2.49.0
PATCH 3/6 pypi: Add packaging documentation for developers
In reply to Rob Woolley--- contrib/pypi/BUILD.md | 50 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 contrib/pypi/BUILD.md
contrib/pypi/BUILD.md new file +50 -0
@@ -0,0 +1,50 @@ +# Development Instructions + +## Requirements + +- Python >= 3.9 +- pip >= 19 (for installation) + +## Testing + +To lint the `bitbake-setup` pypi packaging, run the ruff tool. +```bash +ruff check bin/bitbake-setup contrib/pypi +``` + +The steps to build and test the `bitbake-setup` pypi packaging have been automated with the `bitbake-selftest` tool. This tool automatically creates a Python virtual environment for you. + +Run the bitbake-selftest +```bash +BB_SKIP_PYPI_TESTS=no bin/bitbake-selftest -v bb.tests.setup.PyPIPackagingTest +``` + +## Packaging + +### Create the development sandbox + +To create the development sandbox run: +```bash +contrib/pypi/package-bitbake-setup.py +cd packaging_workshop +``` + +### Building the package + +To install the development tools manually run: +```bash +python3 -m pip install -e '.[dev]' +``` + +To build a wheel (.whl) then use: +```bash +python3 -m build +``` + +This produces a wheel (.whl) file in the dist directory. This may be installed using pip. + +### Installing the package + +```bash +python3 -m pip install dist/bitbake_setup-*-py3-none-any.whl +```
Signature · 1 line
2.49.0
PATCH 4/6 gitignore: Ignore temporary staging directory
In reply to Rob WoolleyThis directory gets created automatically by package-bitbake-setup.py when packaging bitbake-setup for PyPI.
It is a temporary staging directory and should not be added to git.
--- .gitignore | 1 + 1 file changed, 1 insertion(+)
.gitignore +1 -0
@@ -17,3 +17,4 @@ lib/toaster/contrib/tts/backlog.txt lib/toaster/contrib/tts/log/* lib/toaster/contrib/tts/.cache/* lib/bb/tests/runqueue-tests/bitbake-cookerdaemon.log +packaging_workspace/
Signature · 1 line
2.49.0
PATCH 5/6 lib: Vendorize bundled third-party libraries under bb._vendor
In reply to Rob WoolleyMove ply, progressbar, simplediff, and bs4 from lib/ into lib/bb/_vendor/ to avoid conflicts with system-installed versions and to support proper packaging. These libraries contain local modifications from their upstream versions.
- Create lib/bb/_vendor/__init__.py
- Move ply/, progressbar/, simplediff/, bs4/ into bb/_vendor/
- Convert absolute self-references to relative imports within ply (yacc.py) and bs4 (20 import sites across 8 files)
- Update all external import sites to use bb._vendor prefix:
bb/pysh/pyshlex.py, bb/pysh/pyshyacc.py, bb/ui/knotty.py, bb/siggen.py, bb/fetch2/wget.py, toaster/tests/views/test_views.py
---
lib/bb/_vendor/__init__.py | 18 ++++++++++++++++++
lib/{ => bb/_vendor}/bs4/AUTHORS | 0
lib/{ => bb/_vendor}/bs4/CHANGELOG | 0
lib/{ => bb/_vendor}/bs4/LICENSE | 0
lib/{ => bb/_vendor}/bs4/__init__.py | 0
lib/{ => bb/_vendor}/bs4/builder/__init__.py | 2 +-
lib/{ => bb/_vendor}/bs4/builder/_html5lib.py | 12 ++++++------
.../_vendor}/bs4/builder/_htmlparser.py | 6 +++---
lib/{ => bb/_vendor}/bs4/builder/_lxml.py | 6 +++---
lib/{ => bb/_vendor}/bs4/css.py | 2 +-
lib/{ => bb/_vendor}/bs4/dammit.py | 0
lib/{ => bb/_vendor}/bs4/diagnose.py | 9 ++++-----
lib/{ => bb/_vendor}/bs4/element.py | 6 +++---
lib/{ => bb/_vendor}/bs4/formatter.py | 2 +-
lib/{ => bb/_vendor}/ply/__init__.py | 0
lib/{ => bb/_vendor}/ply/lex.py | 0
lib/{ => bb/_vendor}/ply/yacc.py | 6 +-----
lib/{ => bb/_vendor}/progressbar/LICENSE.txt | 0
lib/{ => bb/_vendor}/progressbar/__init__.py | 0
lib/{ => bb/_vendor}/progressbar/compat.py | 0
.../_vendor}/progressbar/progressbar.py | 0
lib/{ => bb/_vendor}/progressbar/widgets.py | 0
lib/{ => bb/_vendor}/simplediff/LICENSE | 0
lib/{ => bb/_vendor}/simplediff/__init__.py | 0
lib/bb/fetch2/wget.py | 4 ++--
lib/bb/pysh/pyshlex.py | 2 +-
lib/bb/pysh/pyshyacc.py | 2 +-
lib/bb/siggen.py | 2 +-
lib/bb/ui/knotty.py | 2 +-
lib/toaster/tests/views/test_views.py | 2 +-
30 files changed, 48 insertions(+), 35 deletions(-)
create mode 100644 lib/bb/_vendor/__init__.py
rename lib/{ => bb/_vendor}/bs4/AUTHORS (100%)
rename lib/{ => bb/_vendor}/bs4/CHANGELOG (100%)
rename lib/{ => bb/_vendor}/bs4/LICENSE (100%)
rename lib/{ => bb/_vendor}/bs4/__init__.py (100%)
rename lib/{ => bb/_vendor}/bs4/builder/__init__.py (99%)
rename lib/{ => bb/_vendor}/bs4/builder/_html5lib.py (98%)
rename lib/{ => bb/_vendor}/bs4/builder/_htmlparser.py (99%)
rename lib/{ => bb/_vendor}/bs4/builder/_lxml.py (99%)
rename lib/{ => bb/_vendor}/bs4/css.py (99%)
rename lib/{ => bb/_vendor}/bs4/dammit.py (100%)
rename lib/{ => bb/_vendor}/bs4/diagnose.py (96%)
rename lib/{ => bb/_vendor}/bs4/element.py (99%)
rename lib/{ => bb/_vendor}/bs4/formatter.py (99%)
rename lib/{ => bb/_vendor}/ply/__init__.py (100%)
rename lib/{ => bb/_vendor}/ply/lex.py (100%)
rename lib/{ => bb/_vendor}/ply/yacc.py (99%)
rename lib/{ => bb/_vendor}/progressbar/LICENSE.txt (100%)
rename lib/{ => bb/_vendor}/progressbar/__init__.py (100%)
rename lib/{ => bb/_vendor}/progressbar/compat.py (100%)
rename lib/{ => bb/_vendor}/progressbar/progressbar.py (100%)
rename lib/{ => bb/_vendor}/progressbar/widgets.py (100%)
rename lib/{ => bb/_vendor}/simplediff/LICENSE (100%)
rename lib/{ => bb/_vendor}/simplediff/__init__.py (100%)lib/bb/_vendor/__init__.py new file +18 -0
@@ -0,0 +1,18 @@ +# +# Copyright BitBake Contributors +# +# SPDX-License-Identifier: GPL-2.0-only +# + +""" +Vendored third-party libraries for BitBake. + +These libraries have been modified from their upstream versions and are +bundled here to avoid conflicts with system-installed packages. + +Vendored packages: + - bs4 (BeautifulSoup4) + - ply + - progressbar + - simplediff +"""
lib/bb/_vendor/bs4/AUTHORS renamed from lib/bs4/AUTHORS +0 -0
lib/bb/_vendor/bs4/CHANGELOG renamed from lib/bs4/CHANGELOG +0 -0
lib/bb/_vendor/bs4/LICENSE renamed from lib/bs4/LICENSE +0 -0
lib/bb/_vendor/bs4/__init__.py renamed from lib/bs4/__init__.py +0 -0
lib/bb/_vendor/bs4/builder/__init__.py renamed from lib/bs4/builder/__init__.py +1 -1
@@ -6,7 +6,7 @@ import itertools import re import warnings import sys -from bs4.element import ( +from ..element import ( CharsetMetaAttributeValue, ContentMetaAttributeValue, RubyParenthesisString,
lib/bb/_vendor/bs4/builder/_html5lib.py renamed from lib/bs4/builder/_html5lib.py +6 -6
@@ -7,14 +7,14 @@ __all__ = [ import warnings import re -from bs4.builder import ( +from . import ( DetectsXMLParsedAsHTML, PERMISSIVE, HTML, HTML_5, HTMLTreeBuilder, ) -from bs4.element import ( +from ..element import ( NamespacedAttribute, nonwhitespace_re, )
@@ -23,7 +23,7 @@ from html5lib.constants import ( namespaces, prefixes, ) -from bs4.element import ( +from ..element import ( Comment, Doctype, NavigableString,
@@ -134,7 +134,7 @@ class TreeBuilderForHtml5lib(treebuilder_base.TreeBuilder): if soup: self.soup = soup else: - from bs4 import BeautifulSoup + from .. import BeautifulSoup # TODO: Why is the parser 'html.parser' here? To avoid an # infinite loop? self.soup = BeautifulSoup(
@@ -180,7 +180,7 @@ class TreeBuilderForHtml5lib(treebuilder_base.TreeBuilder): return TextNode(Comment(data), self.soup) def fragmentClass(self): - from bs4 import BeautifulSoup + from .. import BeautifulSoup # TODO: Why is the parser 'html.parser' here? To avoid an # infinite loop? self.soup = BeautifulSoup("", "html.parser")
@@ -198,7 +198,7 @@ class TreeBuilderForHtml5lib(treebuilder_base.TreeBuilder): return treebuilder_base.TreeBuilder.getFragment(self).element def testSerializer(self, element): - from bs4 import BeautifulSoup + from .. import BeautifulSoup rv = [] doctype_re = re.compile(r'^(.*?)(?: PUBLIC "(.*?)"(?: "(.*?)")?| SYSTEM "(.*?)")?$')
lib/bb/_vendor/bs4/builder/_htmlparser.py renamed from lib/bs4/builder/_htmlparser.py +3 -3
@@ -13,16 +13,16 @@ from html.parser import HTMLParser import sys import warnings -from bs4.element import ( +from ..element import ( CData, Comment, Declaration, Doctype, ProcessingInstruction, ) -from bs4.dammit import EntitySubstitution, UnicodeDammit +from ..dammit import EntitySubstitution, UnicodeDammit -from bs4.builder import ( +from . import ( DetectsXMLParsedAsHTML, ParserRejectedMarkup, HTML,
lib/bb/_vendor/bs4/builder/_lxml.py renamed from lib/bs4/builder/_lxml.py +3 -3
@@ -14,14 +14,14 @@ except ImportError as e: from io import BytesIO from io import StringIO from lxml import etree -from bs4.element import ( +from ..element import ( Comment, Doctype, NamespacedAttribute, ProcessingInstruction, XMLProcessingInstruction, ) -from bs4.builder import ( +from . import ( DetectsXMLParsedAsHTML, FAST, HTML,
@@ -30,7 +30,7 @@ from bs4.builder import ( ParserRejectedMarkup, TreeBuilder, XML) -from bs4.dammit import EncodingDetector +from ..dammit import EncodingDetector LXML = 'lxml'
lib/bb/_vendor/bs4/css.py renamed from lib/bs4/css.py +1 -1
@@ -68,7 +68,7 @@ class CSS(object): result (a common mistake). """ # Import here to avoid circular import - from bs4.element import ResultSet + from .element import ResultSet return ResultSet(None, results) def compile(self, select, namespaces=None, flags=0, **kwargs):
lib/bb/_vendor/bs4/dammit.py renamed from lib/bs4/dammit.py +0 -0
lib/bb/_vendor/bs4/diagnose.py renamed from lib/bs4/diagnose.py +4 -5
@@ -6,9 +6,8 @@ __license__ = "MIT" import cProfile from io import BytesIO from html.parser import HTMLParser -import bs4 -from bs4 import BeautifulSoup, __version__ -from bs4.builder import builder_registry +from . import BeautifulSoup, __version__ +from .builder import builder_registry import os import pstats
@@ -219,8 +218,8 @@ def profile(num_elements=100000, parser="lxml"): filename = filehandle.name data = rdoc(num_elements) - vars = dict(bs4=bs4, data=data, parser=parser) - cProfile.runctx('bs4.BeautifulSoup(data, parser)' , vars, vars, filename) + vars = dict(BeautifulSoup=BeautifulSoup, data=data, parser=parser) + cProfile.runctx('BeautifulSoup(data, parser)' , vars, vars, filename) stats = pstats.Stats(filename) # stats.strip_dirs()
lib/bb/_vendor/bs4/element.py renamed from lib/bs4/element.py +3 -3
@@ -9,8 +9,8 @@ import re import sys import warnings -from bs4.css import CSS -from bs4.formatter import ( +from .css import CSS +from .formatter import ( Formatter, HTMLFormatter, XMLFormatter,
@@ -420,7 +420,7 @@ class PageElement(object): and not isinstance(new_child, NavigableString)): new_child = NavigableString(new_child) - from bs4 import BeautifulSoup + from . import BeautifulSoup if isinstance(new_child, BeautifulSoup): # We don't want to end up with a situation where one BeautifulSoup # object contains another. Insert the children one at a time.
lib/bb/_vendor/bs4/formatter.py renamed from lib/bs4/formatter.py +1 -1
@@ -1,4 +1,4 @@ -from bs4.dammit import EntitySubstitution +from .dammit import EntitySubstitution class Formatter(EntitySubstitution): """Describes a strategy to use when outputting a parse tree to a string.
lib/bb/_vendor/ply/__init__.py renamed from lib/ply/__init__.py +0 -0
lib/bb/_vendor/ply/lex.py renamed from lib/ply/lex.py +0 -0
lib/bb/_vendor/ply/yacc.py renamed from lib/ply/yacc.py +1 -5
@@ -100,12 +100,8 @@ try: except AttributeError: MAXINT = sys.maxsize -# Python 2.x/3.0 compatibility. def load_ply_lex(): - if sys.version_info[0] < 3: - import lex - else: - import ply.lex as lex + from . import lex return lex # This object is a stand-in for a logging object created by the
lib/bb/_vendor/progressbar/LICENSE.txt renamed from lib/progressbar/LICENSE.txt +0 -0
lib/bb/_vendor/progressbar/__init__.py renamed from lib/progressbar/__init__.py +0 -0
lib/bb/_vendor/progressbar/compat.py renamed from lib/progressbar/compat.py +0 -0
lib/bb/_vendor/progressbar/progressbar.py renamed from lib/progressbar/progressbar.py +0 -0
lib/bb/_vendor/progressbar/widgets.py renamed from lib/progressbar/widgets.py +0 -0
lib/bb/_vendor/simplediff/LICENSE renamed from lib/simplediff/LICENSE +0 -0
lib/bb/_vendor/simplediff/__init__.py renamed from lib/simplediff/__init__.py +0 -0
lib/bb/fetch2/wget.py +2 -2
@@ -27,8 +27,8 @@ from bb.fetch2 import FetchMethod from bb.fetch2 import FetchError from bb.fetch2 import logger from bb.fetch2 import runfetchcmd -from bs4 import BeautifulSoup -from bs4 import SoupStrainer +from bb._vendor.bs4 import BeautifulSoup +from bb._vendor.bs4 import SoupStrainer class WgetProgressHandler(bb.progress.LineFilterProgressHandler): """
lib/bb/pysh/pyshlex.py +1 -1
@@ -14,7 +14,7 @@ # that hard to enable pull mode. import re -from ply import lex +from bb._vendor.ply import lex from bb.pysh.sherrors import * class NeedMore(Exception):
lib/bb/pysh/pyshyacc.py +1 -1
@@ -13,7 +13,7 @@ import sys import bb.pysh.pyshlex as pyshlex tokens = pyshlex.tokens -from ply import yacc +from bb._vendor.ply import yacc import bb.pysh.sherrors as sherrors class IORedirect:
lib/bb/siggen.py +1 -1
@@ -12,7 +12,7 @@ import tempfile import pickle import bb.data import difflib -import simplediff +from bb._vendor import simplediff import json import types from contextlib import contextmanager
lib/bb/ui/knotty.py +1 -1
@@ -14,7 +14,7 @@ import io import os import sys import logging -import progressbar +from bb._vendor import progressbar import signal import bb.msg import time
lib/toaster/tests/views/test_views.py +1 -1
@@ -27,7 +27,7 @@ import toastergui from toastergui.tables import SoftwareRecipesTable import json -from bs4 import BeautifulSoup +from bb._vendor.bs4 import BeautifulSoup import string PROJECT_NAME = "test project"
Signature · 1 line
2.49.0
Re: [bitbake-devel] [PATCH 5/6] lib: Vendorize bundled third-party libraries under bb._vendor
Quoted 5 lines · Rob Woolley via lists.openembedded.org
Move ply, progressbar, simplediff, and bs4 from
lib/intolib/bb/_vendor/to avoid conflicts with system-installed versions and to support proper packaging. These libraries contain local modifications from their upstream versions.
I’d like to see the vendoring done with a tool that lets us update the bundled libraries easily in the future, to be honest.
When I wrote picobuild (now redundant as pypa/build can bootstrap itself) I used the same tool that pip uses to vendor its dependencies: https://github.com/pradyunsg/vendoring. So https://gitlab.com/rossburton/picobuild is a minimal example of using vendoring: a few lines of configuration in pyproject.toml and a separate requirements file.
Obviously if we sync from upstream we’ll drop our local changes, so the question then is why do we have forks? Note that vendoring can apply patches when it updates, so if there’s a simple but not-upstreamable change we can carry the patch in-tree.
Ross
Re: [bitbake-devel] [PATCH 5/6] lib: Vendorize bundled third-party libraries under bb._vendor
Hi Ross,
I followed your advice and added support for vendoring:
https://github.com/robwoolley/bitbake/commits/vendoring/ Is this what you had in mind?
I reviewed the patches for the vendored modules:
*beautifulsoup4*
- most patches seemed to be for Python 3 support
- I brought forward 2 patches into vendor/patches:
- lib/bs4: Avoid soupsieve warning
- lib: Remove double imports
*ply*
- patches were all removed
- some had been merged upgrade
- patches related to FIPS issues in the signature function were no longer necessary due to refactoring upstream
- ply is no longer maintained
*simplediff*
- No changes were made, the version remains the same
*progressbar*
- all 6 patches were refreshed
One drawback is that I had to add pyproject.toml for "vendoring sync ." to work. I wonder if this could cause confusion for people that expect it to be a full Python project configuration file and try to use "python3 -m build".
We may want to consider adding a complete pyproject.toml at the top-level.
Here are my testing instructions for anyone who wishes to follow along:
``` git clone -b vendoring https://github.com/robwoolley/bitbake bitbake-vendoring cd bitbake-vendoring bin/bitbake-setup init poky-master # Accept the options # Source the build env: . /ala-lpggp31/rwoolley/bitbake-vendoring/bitbake-builds/poky-master/build/init-build-env cd ../layers/bitbake git remote add robwoolley https://github.com/robwoolley/bitbake git remote update robwoolley git checkout vendoring cd $BUILDDIR bitbake core-image-minimal ```
Regards,
Rob
Quoted 35 lines · Ross Burton via lists.openembedded.org
Quoted 5 lines · Rob Woolley via lists.openembedded.org
Move ply, progressbar, simplediff, and bs4 from
lib/intolib/bb/_vendor/to avoid conflicts with system-installed versions and to support proper packaging. These libraries contain local modifications from their upstream versions.I’d like to see the vendoring done with a tool that lets us update the bundled libraries easily in the future, to be honest.
When I wrote picobuild (now redundant as pypa/build can bootstrap itself) I used the same tool that pip uses to vendor its dependencies:
https://github.com/pradyunsg/vendoring. So
https://gitlab.com/rossburton/picobuild is a minimal example of using
vendoring: a few lines of configuration in pyproject.toml and a separate requirements file.Obviously if we sync from upstream we’ll drop our local changes, so the question then is why do we have forks? Note that vendoring can apply patches when it updates, so if there’s a simple but not-upstreamable change we can carry the patch in-tree.
Ross
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#19419):
https://lists.openembedded.org/g/bitbake-devel/message/19419
Mute This Topic: https://lists.openembedded.org/mt/118597577/556952
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
PATCH 6/6 bb: Move codegen.py inside module
In reply to Rob WoolleyCodegen is used exclusively by bb.codeparser.PythonParser.
Move it inside the bb module to avoid exposing it externally when installing bb as a package.
---
lib/{ => bb}/codegen.py | 0
lib/bb/codeparser.py | 2 +-
2 files changed, 1 insertion(+), 1 deletion(-)
rename lib/{ => bb}/codegen.py (100%)lib/bb/codegen.py renamed from lib/codegen.py +0 -0
lib/bb/codeparser.py +1 -1
@@ -25,9 +25,9 @@ recipe caches don't trigger "Taskhash mismatch" errors. import ast import sys -import codegen import logging import inspect +import bb.codegen import bb.pysh as pysh import bb.utils, bb.data import hashlib
Signature · 1 line
2.49.0
Re: [bitbake-devel] [PATCH 6/6] bb: Move codegen.py inside module
Quoted 11 lines · Rob Woolley via lists.openembedded.org
Codegen is used exclusively by bb.codeparser.PythonParser.
Move it inside the bb module to avoid exposing it externally when installing bb as a package.
Signed-off-by Rob Woolley <[email protected]>---
lib/{ =>bb}/codegen.py| 0
lib/bb/codeparser.py | 2 +-2 files changed, 1 insertion(+), 1 deletion(-)rename lib/{ =>
bb}/codegen.py(100%)
Some good news is we removed codegen.py entirely so this part of the series is no longer needed.
Cheers,
Richard