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
Fix gdal installing Python modules for default interpreter #2423
Conversation
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.
While you don't seem to actually make anything worse, the ebuild is of terrible quality and I can't approve this as-is.
As far as I can see, this is yet another terrible example of Gentoo developers overhacking simple things. Do you wish to work on it more to bring some sanity, or should I just open a bug for the current maintainer to resolve it?
PYTHON_COMPAT=( python2_7 python3_{3,4} ) | ||
DISTUTILS_OPTIONAL=1 | ||
|
||
inherit autotools eutils libtool perl-module distutils-r1 python-r1 toolchain-funcs java-pkg-opt-2 |
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 ebuild is not using distutils-r1 at all… (I know you haven't touched it but it's a major problem and since you are already touching Python stuffs, it would be nice to have this fixed)
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.
Disregard this. We'll make it used.
REQUIRED_USE=" | ||
spatialite? ( sqlite ) | ||
mdb? ( java ) | ||
" |
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.
python? ( ${PYTHON_REQUIRED_USE} )
missing
Good news is that the package's build system is so terrible, we don't have to care much about it and fixing it won't take much time. I'll provide proper instructions in an hour so. |
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.
Here's a quick summary of changes needed to be done, looking at the build system. Long story short, don't use configure at all, use make to generate swig files (once for all impls), then let distutils-r1 do the rest.
sed -i \ | ||
-e "s:setup.py install:setup.py install --root=\$(DESTDIR):" \ | ||
-e "s:--prefix=\$(DESTDIR):--prefix=:" \ | ||
"${S}"/swig/python/GNUmakefile || die |
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.
Kill this sed.
} | ||
if use python; then | ||
python_foreach_impl prepare_python | ||
fi |
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.
Kill the whole Python part here.
myopts+=" --with-python" | ||
else | ||
myopts+=" --without-python" | ||
fi |
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.
Kill this whole thing…
--without-oci \ | ||
--without-pcraster \ | ||
--without-podofo \ | ||
--without-sde \ |
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.
…and just put --without-python
here. The configure doesn't really care about that switch, only to determine some random useless magic wrt Python and setuptools that actually does more harm than good.
GDALmake.opt || die "sed LIBS failed" | ||
fi | ||
|
||
if [[ -n $use_python ]]; then |
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 belongs in src_prepare
, and you can do it unconditioanlly, it doesn't seem to require anything specific from Python or harm non-Python builds.
|
||
compile_python() { | ||
rm -f swig/python/*_wrap.cpp || die | ||
emake -C swig/python generate |
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.
Now, this (the swig part) you can do like for perl -- it's enough to do it once for all impls.
compile_python() { | ||
rm -f swig/python/*_wrap.cpp || die | ||
emake -C swig/python generate | ||
emake -C swig/python build |
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.
The build part do via distutils-r1. Kill the whole foreach thing, and just do sth like:
if use python; then
cd "${S}"/swig/perl || die
distutils-r1_src_compile
fi
(note: looking at other code, maintainer may prefer pushd/popd, don't forget to ||die)
use doc && dohtml html/* | ||
|
||
install_python() { | ||
emake -C swig/python DESTDIR="${D}" 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.
Again, kill the custom thing and just call distutils-r1 phase function, without foreach.
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.
Needed a pushd, setup.py is not copied to build directory.
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.
-c "${S}/swig/python"
? But please make sure that this all works when you uninstall the original package and build it as fresh install (i.e. doesn't accidentally use installed stuff instead of build).
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.
The pushd is because distutils-r1_src_compile works OK for the first Python target but then fails for the second:
x86_64-pc-linux-gnu-g++ -pthread -shared -Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu -march=ivybridge -ftree-vectorize -O2 -pipe -fPIC -Wall build/temp.linux-x86_64-3.5/extensions/gdal_array_wrap.o -L../../.libs -L../../ -L/usr/lib64 -L/var/tmp/portage/sci-libs/gdal-2.0.2-r1/work/gdal-2.0.2/lib -lpython3.5m -lgdal -o build/lib.linux-x86_64-3.5/osgeo/_gdal_array.cpython-35m-x86_64-linux-gnu.so
make: Leaving directory '/var/tmp/portage/sci-libs/gdal-2.0.2-r1/work/gdal-2.0.2/swig/python'
* python2_7: running distutils-r1_run_phase distutils-r1_python_compile
/usr/bin/python2.7 setup.py build
/usr/bin/python2.7: can't open file 'setup.py': [Errno 2] No such file or directory
* ERROR: sci-libs/gdal-2.0.2-r1::newer failed (compile phase):
(and as it shows I am actually testing with Python 3.5)
Your're right about it using installed stuff. It was failing to find gdal-config and falling back silently to the one in /usr/bin.
I don't think the fallback is a great idea, and have filed:
OSGeo/gdal#159
I've moved the default in src_compile() to make sure the gdal-config is built in time.
|
||
install_python() { | ||
emake -C swig/python DESTDIR="${D}" install | ||
python_optimize |
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 shouldn't be necessary when distutils-r1 installs stuff.
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.
swig/python/GNUmakefile's install has
for f in $(SCRIPTS) ; do $(INSTALL) ./scripts/$$f $(DESTDIR)$(INST_BIN) ; done
where SCRIPTS =
ls ./scripts``
which means replacing make install with distutils-r1 causes a failure of:
python_replicate_script "${ED}"/usr/bin/*py
But make install isn't desirable, it installs "man" pages (*.dox files) in /usr/bin/
(suggested fix upstream OSGeo/gdal#157)
and of course is run for each Python target.
So... I've added dobin swig/python/scripts/*.py
.
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.
Doesn't setup.py install the necessary scripts? If it would, the replication wouldn't be necessary in the first place.
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.
Unfortunately not.
PYTHON_COMPAT=( python2_7 python3_{3,4} ) | ||
DISTUTILS_OPTIONAL=1 | ||
|
||
inherit autotools eutils libtool perl-module distutils-r1 python-r1 toolchain-funcs java-pkg-opt-2 |
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.
Oh, and kill python-r1 then ;-).
48d8df5
to
7f639dc
Compare
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.
Thanks for your work so far. Just a few little requests to finish this.
|
||
eautoreconf | ||
|
||
prepare_python() { |
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 function is not used at all.
if use python; then | ||
rm -f "${S}"swig/python/*_wrap.cpp || die | ||
emake -C "${S}"/swig/python generate | ||
emake -C "${S}"/swig/python build |
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 only calls setup.py, which distutils-r1 does later in the ebuild. Remove it.
newdoc swig/python/README.txt README-python.txt | ||
insinto /usr/share/${PN}/samples | ||
doins swig/python/samples/* | ||
dobin swig/python/scripts/*.py |
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 see that upstream does that in Makefile indeed. Then I suggest you define, before distutils-r1_src_install
call:
python_install() {
distutils-r1_python_install
python_doscript scripts/*.py
}
python_install
gets called for each impl by distutils-r1_src_install, and distutils-r1_python_install is the default impl that calls setup.py 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.
I believe all the comments are addressed now.
popd > /dev/null | ||
fi | ||
|
||
if use python; then |
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.
As a side note, I think it'd be more readable to combine the two if python
blocks.
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.
LGTM modulo pushd||die, popd||die.
if use python; then | ||
rm -f "${S}"swig/python/*_wrap.cpp || die | ||
emake -C "${S}"/swig/python generate | ||
pushd "${S}"/swig/python > /dev/null |
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.
All pushd & popd need || die
. Feel free to also fix those you haven't added, possibly in a separate commit.
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.
die's added. Not sure about a separate commit as it is a new file anyway - would do the old ones after adding the new stuff?
Added a fix for jasper slot change. Happy to remove if necessary. Found when emerging my own qgis ebuild after stable jasper was upgraded from 1.900.1-r9 to :1.900.6
|
@cjmayo sorry, I had to do an emergency revbump, in order to fix the broken ABI. I added |
No problems (thanks to Git). Renamed to r2 based on r1. |
Also adds byte-compilation for Python modules Gentoo-Bug: 536528 Package-Manager: portage-2.3.0
Renamed to r3 based on r2. |
Pull Request assignment Areas affected: ebuilds sci-libs/gdal: @gentoo/sci-geosciences |
Re-assigned it correctly. Also @gentoo/python, feel free to merge this if the maintainer doesn't respond since it's mostly a Python-related change (note: diff to be sure). |
gdal with USE="python" is installing Python modules for the default interpreter even if that version of Python is not selected in PYTHON_TARGETS because
--with-python
is set in first call of gdal_src_configure from src_configure (before theif use python
).Therefore control Python installation with
$use_python
.Also a commit to byte-compile Python modules.
@Whissi