Laszlo,

PIP vs Submodules:
The issue with submodule and not using python packages (pip is really just a 
super convenient helper to install that consistently) is that it requires the 
paradigm of file system python path management.  Think of this as edk1 vs edk2 
public includes (if you remember back that far), basically you just figure out 
the path from yourself to the file you want and add that.  It gives you no 
ability to apply consistent ways to access modules and in the end means you 
just have a folder with python scripts/modules in it.  It causes major pain for 
downstream consumers when/if there is ever refactoring (and we know there needs 
to be refactoring).  It leads to others not being able to extend or leverage 
these modules without introducing significant fragility.

What Pip does is gives you a way to consistently install and access the python 
modules.  You can pip install from a local copy of the git repo or you can pip 
install a "release" using something like pypi.  Either way it doesn't change 
how consuming code accesses the python modules.  This is the value of pip in 
this case.   

If there is a strong desire from the developer community to have a workflow 
that avoids pip I believe a little documentation could handle that.  Pip is 
just a helper.  Python packages can be built from the source and installed.  I 
see no reason to recommend this as it requires numerous more commands but if 
avoiding pip is your goal, it is possible.

More value for python package management (PIP):
As we start looking at refactoring and potentially moving tools from C to 
python we can take advantage of package management to lower our maintenance 
burden.  For example Brotli has a pypi release and thus we wouldn't need to 
carry that code.  https://pypi.org/project/Brotli/


VERSION / DEPENDENCY: 
To minimize the dependency challenges and "bisectability" I would suggest we 
leverage the versioning capabilities within pip and repo tagging.  With 
versioning you have lots of options as you can lock to a specific version which 
requires an update each time or you can use some sort of floating version 
within the tuple of version (xx.yy.zz).  It also needs to be discussed if a 
release would be generated for every change in the python or only on an 
important change.  These two tools can make this pretty flexible.

In your scenario of DEC or INF syntax change.  My first pass on workflow would 
be. 
1. Create the issue for basetools
2. Update basetools python
3. Write the unit test that shows it works as expected
4. Check in and make a release
5. Update edk2 pip-requirements.txt to require at least this new version.  This 
gives you the tracking necessary to align with the tools.
6. Use this new feature in the edk2 fw code. 


TOOLS DEVELOPER WORKFLOWS:
You mentioned you wanted to make sure a developer could modify source locally 
and test against local code.  This is covered by workflow C.  It is very easy 
to manage and is one of the reasons we are proposing this change.


Thanks
Sean


-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Laszlo Ersek via 
groups.io
Sent: Monday, April 20, 2020 5:49 AM
To: Matthew Carlson <mac...@microsoft.com>
Cc: devel@edk2.groups.io; ray...@intel.com; Ard Biesheuvel (ARM address) 
<ard.biesheu...@arm.com>
Subject: [EXTERNAL] Re: [edk2-devel] FW: Discussion: Basetools a separate repo

On 04/17/20 03:40, Ni, Ray wrote:

> From: Matthew Carlson 
> <mac...@microsoft.com<mailto:mac...@microsoft.com>>
> Sent: Wednesday, April 15, 2020 4:42 AM
> To: Ni, Ray <ray...@intel.com<mailto:ray...@intel.com>>; Sean Brogan 
> <sean.bro...@microsoft.com<mailto:sean.bro...@microsoft.com>>
> Subject: Discussion: Basetools a separate repo
> 
> Hello Ray,
> 
> I sent this to the discuss list on tianocore, but I think I'm moderated.
> 
> ----
> 
> I'm looking to discuss the movement of the basetools folder in edk2 to a 
> separate repo and treated as a separate python project.

BaseTools used to live in a separate repo (with periodic syncs into edk2), and 
it was an endless source of misery for edk2.

Introducing new basetools features (or fixing critical bugs in existing 
features), and putting those features to actual use in edk2 content, should be 
interleaved in a single shared git history.

Note: this applies at the module (INF) and package (DEC) level too, not just at 
the platform (DSC / FDF) level.

For example, whenever new syntax is added to DEC or INF, universal edk2 modules 
in MdePkg or MdeModulePkg have to delay their utilization of that syntax until 
BaseTools actually implements the syntax (and important bugs related to parsing 
the syntax are fixed as well). Right now this happens naturally, due to the 
shared history.

If we wanted to separate BaseTools out again, the bare minimum would be a git 
submodule (not pip). Even that way, bisectability would take a big hit. And 
that problem -- lack of bisectability -- used to be the most painful issue with 
the original out-of-tree BaseTools too. (You'd get a multi-thousand line code 
drop with each sync, things would break, and you'd have no way of 
programmatically / mechanically narrowing down the
issue.)

I understand that strict CI may help prevent such issues, and that's good. But 
(a) it's still no substitute for git-bisect, and (b) a user should *really* not 
have to install pip whatever in order to locally build edk2 proper.

I can see myself somehow stomaching this change if it is proposed as a git 
submodule. (I'm not trying to prevent "pip"; I'm trying to prevent "pip" from 
being the primary, or exclusive, interface to consuming
basetools.) With a git submodule:

- only git tools are needed for a local source tree setup, for an upstream user;

- at least *some* historical accuracy is preserved between the two projects (as 
the superproject, i.e. edk2, will still record *some* basetools states via the 
submodule reference);

- an upstream user will still be given the chance to hack on both basetools and 
specific INF/DEC files at the same time (e.g. for bug reproduction or 
feature/bugfix testing).

With BaseTools being consumed via a git submodule in edk2, I'd insist on very 
frequent submodule advances in edk2 superproject -- practically every time 
"master" were moved in the basetools subproject (after every BaseTools merge), 
the submodule ref would have to be bumped in edk2.
That's the only way we'd get a halfway functional substitute for git-bisect.

Thanks
Laszlo



> Why a separate repo?
> The recent efforts in expanding the role of CI in the platform and core code 
> of EDK2 will pay big dividends in the future, leading to higher quality code 
> and easier integrations for everyone. Having basetools as it's own repo would 
> simplify adding a similar CI/linting process and unit-tests to the basetools 
> python code, leading to higher quality code.
> 
> A second major benefit is it would allow others that write tools for UEFI and 
> Edk2 to leverage this vast resource of python code using standard python 
> package inclusion.  It would allow those tools to be decoupled from edk2 
> source and provide a consistent and managed user experience.  The python 
> project would be published as a Pip module for those that want to leverage 
> the basetools modules the same way they leverage the existing python 
> ecosystem. Packing basetools as a pip module, would reach the most developers 
> and provide the most flexibility and versatility. There are numerous way this 
> could be used; Pip is just one method suggested here.  Other ways to leverage 
> this are described below.
> 
> Why a pip module?
> The investment into basetools is sizable and it has some amazing 
> functionality that's difficult to reproduce. For example, the DSC, FDF, INF, 
> and DEC parsers handle an incredible amount of edge cases. If I wanted to 
> write a tool that could do a CI validation check or build a UEFI capsule, 
> currently I would need to clone all of EDK2 to get basetools. If it was in a 
> separate repo and available as a wheel, as a developer, I could include it 
> via pip and have that dependency managed with virtual environment or just in 
> the global cache. In addition, other tools that currently are difficult to 
> build would become possible with access to the Basetools functionality.
> 
> However, there have been some concerns expressed about having a global 
> basetools and the impact this has on developers with multiple workspaces 
> (potentially at different versions).  There are several tools and strategies 
> to consider for managing this dependency.  Some outlined below.
> 
> How will this change your workflow?
> If this moved there would have to be a change for all platforms using edk2 
> and we have been evaluating options.  These could become requirements a 
> developer must do before building edk2 or with minimal effort could be added 
> to the edksetup or build scripts.  These can also be more easily isolated if 
> python virtual environments are used.
> 
> For those just consuming released versions of basetools python code:
> Option A: leverage Python package management and install a released version 
> from Pypi into a per project virtual environment.
> Option B: leverage pip to install from the git repo at known 
> tag/release (pip_requirements)
> 
> For those wanting to do active development of basetools within an edk2 
> project:
> Option C: Clone the python package source and install the package locally 
> (pip install -e ./).  All changes made in the local package are reflected 
> into your python site packages.
> 
> 
> We have a demo of what this would look like: 
> https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgith
> ub.com%2Fmatthewfcarlson%2Fedk2-pytool-base%2F&amp;data=02%7C01%7Csean
> .brogan%40microsoft.com%7Cd02dc272480b4a2cbe9108d7e529465f%7C72f988bf8
> 6f141af91ab2d7cd011db47%7C1%7C0%7C637229837751621927&amp;sdata=GV6hzSt
> b2dCypWlIhKCEiwfiVlni3Qu06Te3BnVvB90%3D&amp;reserved=0<https://nam06.s
> afelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmatthe
> wfcarlson%2Fedk2-pytool-base%2F&amp;data=02%7C01%7Csean.brogan%40micro
> soft.com%7Cd02dc272480b4a2cbe9108d7e529465f%7C72f988bf86f141af91ab2d7c
> d011db47%7C1%7C0%7C637229837751621927&amp;sdata=GV6hzStb2dCypWlIhKCEiw
> fiVlni3Qu06Te3BnVvB90%3D&amp;reserved=0>
> And the EDK2 that leverages it 
> https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgith
> ub.com%2Fmatthewfcarlson%2Fedk2%2Ftree%2Ffeature%2Fpip-basetools&amp;d
> ata=02%7C01%7Csean.brogan%40microsoft.com%7Cd02dc272480b4a2cbe9108d7e5
> 29465f%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637229837751621927
> &amp;sdata=kQloOPT46%2F3ryp7AgYpkiYqSjPm7Yl40oOHPkjNtm9E%3D&amp;reserv
> ed=0<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2
> Fgithub.com%2Fmatthewfcarlson%2Fedk2%2Ftree%2Ffeature%2Fpip-basetools&
> amp;data=02%7C01%7Csean.brogan%40microsoft.com%7Cd02dc272480b4a2cbe910
> 8d7e529465f%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C6372298377516
> 21927&amp;sdata=kQloOPT46%2F3ryp7AgYpkiYqSjPm7Yl40oOHPkjNtm9E%3D&amp;r
> eserved=0>
> 
> What happens next?
> Right now, we're gathering feedback and seeing if anyone has an concerns or 
> platforms that this would not work for. We'd love to hear what you have to 
> say. Baring any serious concerns, we'd move forward with:
> 
>   1.  Create new GitHub repo on tianocore for the basetools project
>   2.  Develop the testing, PR, and release process
>   3.  Release the initial version to pypi
>   4.  Delete the source folder in edk2 repo and replace with readme and 
> method to get pip version installed
>   5.  Continually improve basetools and add more testing
> 
> What's the long-term plan?
> The current tentative long term plan is to merge some or all of basetools in 
> with the existing edk2-pytool-library repo. This is still an active 
> conversation, and we'd like to hear your thoughts.
> 
> Matthew Carlson
> Core UEFI
> Microsoft
> 
> 
> 
> 
> 
> 





-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#57649): https://edk2.groups.io/g/devel/message/57649
Mute This Topic: https://groups.io/mt/73069134/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to