From: "David Nyström" <david.c.nystrom@gmail.com>
To: openembedded-core@lists.openembedded.org
Subject: [RFC][PATCH] Lets face it, adding python dependencies is really a painful manual process, due to setuptools/distutils, ignoring anything other than python dependencies.
Date: Wed, 30 Jan 2013 11:53:53 +0100 [thread overview]
Message-ID: <1359543233-9663-1-git-send-email-david.nystrom@enea.com> (raw)
Sending this as an RFC, since I believe that alot of this work can be
automated, or at least semi-automated. Perhaps I'm way out of line here,
please let me know if there are any existing tools in this area.
Ponder this:
1. Write you top level python recipe.
2. Instantiate tool X(?bitbake?), instantiating the hacked python installer.
3. hacked installer created template recipes for all dependencies of
correct version dependencies. (All you need to extract is the URL).
4. Do manual verification on output of licenses, non-python dependencies et.c.
5. Include generated recipes in build.
6. Build normally
This patch refines the python package parsing capabilities of create-recipe.
Signed-off-by: David Nyström <david.nystrom@enea.com>
---
scripts/create-recipe | 64 +++++++++++++++++++++++++++++++++----------------
1 file changed, 43 insertions(+), 21 deletions(-)
diff --git a/scripts/create-recipe b/scripts/create-recipe
index a556e39..779ba03 100755
--- a/scripts/create-recipe
+++ b/scripts/create-recipe
@@ -37,10 +37,12 @@ use File::Basename qw(basename dirname);
my $name = "";
my $predef_version = "TO BE FILLED IN";
my $version = $predef_version;
+my $pversion = $predef_version;
my $description = "";
my $summary = "";
my $url = "";
-my $homepage;
+my $homepage = "";
+my @depends;
my @rdepends;
my $configure = "";
my $localename = "";
@@ -59,6 +61,7 @@ my $builder = "";
my $oscmode = 0;
+my $python = 0;
my @banned_pkgconfig;
my %failed_commands;
@@ -1539,7 +1542,7 @@ sub guess_name_from_url {
}
my $tarfile = $spliturl[0];
- if ($tarfile =~ /(.*?)\-([0-9\.\-\~]+.*?)\.tar/) {
+ if ($tarfile =~ /(.*?)\-([0-9\.\-\~]+)[-\.].*?\.tar/) {
$name = $1;
$version = $2;
$version =~ s/\-/\_/g;
@@ -1678,11 +1681,19 @@ sub write_yaml
sub write_bbfile
{
+ if ($python == 1) {
+ $name = lc("python-" . $name);
+ }
open(BBFILE, ">${name}_$version.bb");
+
print BBFILE "SUMMARY = \"$summary\"\n";
print BBFILE "DESCRIPTION = \"$description\"\n";
print BBFILE "HOMEPAGE = \"$homepage\"\n";
+ if ($python == 1) {
+ print BBFILE "SRCNAME = \"$summary\"\n";
+ }
+
print BBFILE "LICENSE = \"@license\"\n";
print BBFILE "LIC_FILES_CHKSUM = \"";
foreach (keys %lic_files) {
@@ -1705,20 +1716,30 @@ sub write_bbfile
print BBFILE "RDEPENDS_\$\{PN\} += \"@rdepends\"\n";
}
- print BBFILE 'PR = "r0"' . "\n\n";
+ print BBFILE 'PR = "r0"' . "\n";
+ if ($python == 1) {
+ print BBFILE "PV = \"$pversion\"\n\n";
+ }
+
print BBFILE "SRC_URI = \"";
foreach (@sources) {
print BBFILE "$_ \\\n";
}
+
print BBFILE "\"\n\n";
+
print BBFILE "SRC_URI[md5sum] = \"$md5sum\"\n";
print BBFILE "SRC_URI[sha256sum] = \"$sha256sum\"\n\n";
+ if ($python == 1) {
+ print BBFILE "S = \"\${WORKDIR}/\${SRCNAME}-\${PV}\"\n";
+ }
if (@inherits) {
print BBFILE "inherit ";
foreach (@inherits) {
print BBFILE "$_ ";
}
+ print BBFILE "\n";
}
close(BBFILE);
@@ -1830,34 +1851,34 @@ $fulldir = $dir;
if ( -e "$dir/setup.py" ) {
$python = 1;
- push(@inherits, "distutils");
-
- system("cd $dir ; python setup.py build sdist &> /dev/null");
+ $tmp_stools = `grep -r setuptools $dir/setup.py`;
+ if (length($tmp_stools) > 2) {
+ push(@inherits, "setuptools");
+ } else {
+ push(@inherits, "distutils");
+ }
- $templic = `sed '/^License: */!d; s///;q' $dir/*.egg-info/PKG-INFO`;
+ $templic = `cd $dir; python setup.py --license;`;
chomp($templic);
push(@license, $templic);
- $summary = `sed '/^Name: */!d; s///;q' $dir/*.egg-info/PKG-INFO`;
+ $summary = `cd $dir; python setup.py --name`;
chomp($summary);
- $description = `sed '/^Summary: */!d; s///;q' $dir/*.egg-info/PKG-INFO`;
+ $description = `cd $dir; python setup.py --description`;
chomp($description);
- $homepage = `sed '/^Home-page: */!d; s///;q' $dir/*.egg-info/PKG-INFO`;
+ $homepage = `cd $dir; python setup.py --url`;
chomp($homepage);
- $findoutput = `find $dir/*.egg-info/ -name "requires.txt" 2>/dev/null`;
+ $pversion = `cd $dir; python setup.py -V`;
+ chomp($pversion);
+# $findoutput = `cd $dir; python setup.py --requires`;
+# if (length($findoutput) < 3) {
+ $findoutput = `find $dir/*.egg-info/ -name "requires.txt" 2>/dev/null`;
+# }
@findlist = split(/\n/, $findoutput);
- foreach (@findlist) {
- # Adding dependency do buildreqs should be removed when
- # distutils is unbroken, i.e. blocks setup.py install from
- # downloading and installing dependencies.
- push(@buildreqs, `sed 's/[^a-zA-Z]//g' $dir/*.egg-info/requires.txt`);
- chomp(@buildreqs);
- foreach $item (@buildreqs) {
- $item = "python-" . $item
- }
+ foreach (@findlist) {
push(@rdepends, `sed 's/[^a-zA-Z]//g' $dir/*.egg-info/requires.txt`);
chomp(@rdepends);
foreach $item (@rdepends) {
- $item = "python-" . $item
+ $item = lc("python-" . $item);
}
}
}
@@ -1911,6 +1932,7 @@ if (length($configure) > 2) {
}
+
@files = <$dir/configure>;
foreach (@files) {
process_configure("$_");
--
1.7.9.5
reply other threads:[~2013-01-30 11:09 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1359543233-9663-1-git-send-email-david.nystrom@enea.com \
--to=david.c.nystrom@gmail.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox