-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
buildsystem: add python toolchain #2277
Conversation
I had think about this, too. but i have no knowledges about python. but i see three points:
thanks, |
Thank you for the feedback
Waiting for further comments to update the PR |
a3f841a
to
ab43550
Compare
Seems both package.mk files are missing header? |
ab43550
to
e414491
Compare
@vpeter4 I have refined a bit:
|
2a74de4
to
5bf9844
Compare
This now compresses packages that can be and removes .py and .exe files, to save space. |
scripts/build
Outdated
"python2:host") | ||
echo "Executing (host): python setup.py build" | tr -s " " | ||
export LDSHARED="$CC -shared $LDSHARED" | ||
python setup.py build --build-base .$HOST_NAME |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not python2
instead of python
? Same for down below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To leave room for python3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really sure I follow... I'm referring to the fact you are using the unversioned python
sym-link rather than the versioned python2
sym-link - since this is a python2-specific change using the python2
sym-link seems more logical/appropriate/correct. Also, you could/should use the full $TOOLCHAIN/bin/python2
path and avoid using whatever version is found on $PATH
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe a python as a synonym of python2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for reviewing @MilhouseVH
I fixed to use the full $TOOLCHAIN/bin/python2
path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
echo
lines include python2 now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually meant to include the $TOOLCHAIN/bin/
part too, otherwise the command being echoed is not the same as the command being executed.
Edit: Not sure how others feel about this, maybe it's unnecessary as we don't do this for cmake/ninja/make (although maybe we should - but that's a different issue).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was not aware that these outputs were important :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be, if trying to reproduce or understand a particular failure - having the exact command that failed available in the log can help enormously. That's why these echo statements are there. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I propose to leave this for another pull request: the other echo statements need to be updated and I do not know what level of detail you expect
9f093dd
to
93018b0
Compare
@Raybuntu TUF is back, pinned at the current releases |
To use in an add-on, copy the generated |
The tools.python-tools add-on provides frequently required Python packages such as lxml, pyOpenSSL and setuptools (setuptools is used by many Python packages to validate dependencies). |
cffi is used by many platform specific Python packages and can not be easy_installed (see le_tuf) . It would therefore be profitable to add it to /usr, in order to avoid having to add it to every package/add-on that requires it. This would only add ~600k to the image. How should I add cffi to the image @MilhouseVH? |
I really don't know anything about |
$INSTALL would need to be added as is to the image root. Would adding cffi to Python2 as a PKG_TARGET_DEPENDS achieve this @MilhouseVH? |
If you build |
Thanks. I try building an image that includes cffi. |
f92acbb
to
4340cbf
Compare
scripts/build
Outdated
@@ -213,6 +213,11 @@ if [ "$PKG_IS_KERNEL_PKG" = "yes" ]; then | |||
fi | |||
fi | |||
|
|||
if [ "$PKG_TOOLCHAIN" = "python" ]; then | |||
PKG_DEPENDS_HOST="toolchain distutilscross:host $PKG_DEPENDS_HOST" | |||
PKG_DEPENDS_TARGET="toolchain distutilscross:host Python2 $PKG_DEPENDS_TARGET" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should still be python2 only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to have it working with python3 too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean? build for both Python2 and Python3 at the same time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean your package will depend on Python2 only so if I have a python package that is Python3 for the Target it will depend on Python2 which is wrong.
scripts/build
Outdated
_pythonpath="$_prefix/lib/$PKG_PYTHON_VERSION/site-packages" | ||
mkdir -p "$_pythonpath" | ||
PYTHONPATH="$PYTHONPATH:$_pythonpath" \ | ||
$TOOLCHAIN/bin/python setup.py easy_install \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
easy_install will automatically download dependencies right? So this should be changed to "install"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you really intend to keep checking dependencies manually or at runtime?
By the way, the current make_host/make_install_host automatically downloads, builds and installs dependencies too: the cffi:host of #2132 would build fine without pycparser:host. So you might want to correct that.
I see no added value in keeping the current toolchain, except for problematic Python packages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that too for host installs and I'm considering it a bug actually cause it's a side effect that can lead to weird error's.
Where is PKG_PYTHON_VERSION being set?
For this to work with Pyhon3 aren't you assuming that You should have kept it the way you had it - if you want to build with Python2, use Since you have $PKG_PYTHON_VERSION why not use the appropriate binary? For example:
Or something. But don't use the unversioned |
If this is the case, I will
I will add two toolchains, so we all profit:
What do you say? |
Ah yes, I'd forgotten about that variable! Yes, it indicates the specific python version to be used by the package - conceivably in future this might change to Your proposed changes sound OK, thanks. |
@thoradia I guess we need 2 toolchains. One for python2 and one for python3 packages. I know we don't have python3 in the image right now but it will probably change in the future. |
@Raybuntu
|
Just an aside, but we will almost certainly need to modify the way in which PKG_PYTHON_VERSION is currently being set to avoid hard-coding a specific version in multiple packages (which would all break if/when the Python3 version is bumped, eg. from 3.6 to 3.7). The current solution works because almost everything is using However, whatever we decide should have no impact on this PR as by the time this code is executed PKG_PYTHON_VERSION should be set to a usable value. |
If eggs are a better way to install Python packages then maybe this has merit. This is overkill when considering our only Python package, pycryptodome, but may make more sense when considering all the extra packages required by TUF. This will need much testing (in conjunction with #2288) before proceeding. Is |
Then +1 from my side. |
I lost track of all the different python suggestions that have been floated recently, but I have a simple requirement. We need predicable (reproducible) output from the build system, which I assume requires explicit version control of all packages and no dynamic "get latest" logic which could result (over time) in different things being built. Can someone confirm this is the case? |
Thank you all for your feedback. Food for thoughts (1), from the setuptools doc: Food for thoughts (2): |
466451b
to
119ade8
Compare
I have rebased this:
Example:
|
I'm no python expert but if I understand the docs correctly easy_install can download packages automatically from the 'net. This is something we need to prevent from happening. All external stuff needed to create LE has to be version-controlled via package.mk and downloaded via scripts/get. |
@HiassofT In fact, reviewers here focus on easy_install, but seem completely unaware of the fact that install on host downloads and installs the latest version available. In #2132 for example, cffi will install the lastest version of pycparser, irrespective of the version set in the pycparser package.mk (try PKG_VERSION=2.17 to verify). I am sincerely trying to help, but I am getting nowehere, and you neither. |
@thoradia your work is very appreciated. The auto install on python host is considered a bug. |
@thoradia I'd also like to thank you for your contribution! It's fine for me if you add dependency checks via PKG_PYTON_DEPS but we need to make sure that under no circumstances easy_install will download anything on it's own from the net - that would circumvent the dependency mechanism in LE and will also make it rather hard for us to provide the full source code to LE (which is a requirement of the GPL and is currently done via mirroring all packages we download from the net). If you can configure it so it that downloads are disabled everything's fine from my side. |
f23a9c0
to
1f5faf6
Compare
1f5faf6
to
192f698
Compare
See thoradia@aa6224f |
This adds the python2 toolchain to the amazing buildsystem rework by @InuSasha
This toolchain is not auto-detected, optional and allows to easily build bundled pinned Python packages.
cffi is provided as a sample, see my tree for others. This could be used to build TUF or other Python dependencies.
I hope it will make it this time.