I'm trying to package 'migen':
http://www.contrib.andrew.cmu.edu/~somlo/python-migen-rpm/python-migen.spec
The sources come with a ./doc directory that uses sphinx-build to generate documentation, and a ./doc/conf.py file which imports the package being built, in order to automatically paste various code and doc bits from the module into the resulting documentation (see: https://github.com/m-labs/migen/blob/master/doc/conf.py, https://github.com/m-labs/migen/blob/master/doc/conf.py#L60, and https://github.com/m-labs/migen/blob/master/doc/conf.py#L259).
Trouble is, I can't "BuildRequires:" the package I'm currently in the process of building, so the
%make_build -C doc latexpdf man
line under "%build" results in an error:
make: Entering directory '/builddir/build/BUILD/migen-afe4405becdbc76539f0195c319367187012b05e/doc' sphinx-build -b man -d _build/doctrees . _build/man Running Sphinx v1.7.5 make: Leaving directory '/builddir/build/BUILD/migen-afe4405becdbc76539f0195c319367187012b05e/doc'
Configuration error: There is a programable error in your configuration file:
Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/sphinx/config.py", line 161, in __init__ execfile_(filename, config) File "/usr/lib/python3.6/site-packages/sphinx/util/pycompat.py", line 150, in execfile_ exec_(code, _globals) File "conf.py", line 62, in <module> migen_version = pkg_resources.require("migen")[0].version File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 888, in require needed = self.resolve(parse_requirements(requirements)) File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 774, in resolve raise DistributionNotFound(req, requirers) pkg_resources.DistributionNotFound: The 'migen' distribution was not found and is required by the application
make: *** [Makefile:112: man] Error 2
I've tried everything I can think of before running make on the doc directory:
- adding "%{_builddir}/%{?buildsubdir}" to PYTHONPATH (contains the 'migen' module directory in the sources)
- moving the call to make to %install and adding "%{buildroot}%{python3_sitelib}" to PYTHONPATH (where the 'migen' module is installed by %py3_install)
- inserting "sys.path.insert(...)" and/or "sys.path.append(...)" statements (using sed) into doc/conf.py before running make during either %build or %install
... and nothing seems to help. Any clues as to what I may be missing much appreciated!
Thanks, --Gabriel
On 15. 02. 19 17:57, Gabriel L. Somlo wrote:
I'm trying to package 'migen':
http://www.contrib.andrew.cmu.edu/~somlo/python-migen-rpm/python-migen.spec
The sources come with a ./doc directory that uses sphinx-build to generate documentation, and a ./doc/conf.py file which imports the package being built, in order to automatically paste various code and doc bits from the module into the resulting documentation ... make: Entering directory '/builddir/build/BUILD/migen-afe4405becdbc76539f0195c319367187012b05e/doc' sphinx-build -b man -d _build/doctrees . _build/man Running Sphinx v1.7.5 make: Leaving directory '/builddir/build/BUILD/migen-afe4405becdbc76539f0195c319367187012b05e/doc'
Configuration error: There is a programable error in your configuration file:
Traceback (most recent call last): ... pkg_resources.DistributionNotFound: The 'migen' distribution was not found and is required by the application
This is tricky. It doesn't import it (that is easily tricked with PYTHONPATH), but uses pkg_resources to fetch data about installed packages.
I believe the easiest way is to sed conf.py to replace
pkg_resources.require("migen")[0].version
with the version.
Another hacky solution:
Crate a --system-site-packages venv, install the package to that venv, build docs from that venv, destroy the venv.
A less hacky theoretical solution:
Build docs after %py3_install. Explain pkg_resources that you package is installed in a custom dir. I'm however not aware of a way to do so.
On Fri, Feb 15, 2019 at 06:19:10PM +0100, Miro Hrončok wrote:
On 15. 02. 19 17:57, Gabriel L. Somlo wrote:
I'm trying to package 'migen':
http://www.contrib.andrew.cmu.edu/~somlo/python-migen-rpm/python-migen.spec
The sources come with a ./doc directory that uses sphinx-build to generate documentation, and a ./doc/conf.py file which imports the package being built, in order to automatically paste various code and doc bits from the module into the resulting documentation ... make: Entering directory '/builddir/build/BUILD/migen-afe4405becdbc76539f0195c319367187012b05e/doc' sphinx-build -b man -d _build/doctrees . _build/man Running Sphinx v1.7.5 make: Leaving directory '/builddir/build/BUILD/migen-afe4405becdbc76539f0195c319367187012b05e/doc'
Configuration error: There is a programable error in your configuration file:
Traceback (most recent call last): ... pkg_resources.DistributionNotFound: The 'migen' distribution was not found and is required by the application
This is tricky. It doesn't import it (that is easily tricked with PYTHONPATH), but uses pkg_resources to fetch data about installed packages.
I believe the easiest way is to sed conf.py to replace
pkg_resources.require("migen")[0].version
Argh, upstream is doing the typical overengineered crap. Do they realize that they are embedding the identifier of the _previously_ installed version in the docs?
Also, using make to call sphinx-build is so python-2.
The following diff works for me: diff --git python-migen.spec python-migen.spec index 9ad29027c8..8dc929a214 100644 --- python-migen.spec +++ python-migen.spec @@ -35,9 +35,12 @@ A Python toolbox for building complex digital hardware. %prep %autosetup -n %{srcname}-%{commit0}
+sed -r -i 's/(migen_version = ).*/\1"%{version}-%{release}"/' doc/conf.py + %build %py3_build -%make_build -C doc latexpdf man +PYTHONPATH=. sphinx-build-3 -b latex doc/ _build/doc/ +PYTHONPATH=. sphinx-build-3 -b man doc/ _build/doc/
%install %py3_install
Zbyszek
On 15. 02. 19 18:32, Zbigniew Jędrzejewski-Szmek wrote:
On Fri, Feb 15, 2019 at 06:19:10PM +0100, Miro Hrončok wrote:
On 15. 02. 19 17:57, Gabriel L. Somlo wrote:
I'm trying to package 'migen':
http://www.contrib.andrew.cmu.edu/~somlo/python-migen-rpm/python-migen.spec
The sources come with a ./doc directory that uses sphinx-build to generate documentation, and a ./doc/conf.py file which imports the package being built, in order to automatically paste various code and doc bits from the module into the resulting documentation ... make: Entering directory '/builddir/build/BUILD/migen-afe4405becdbc76539f0195c319367187012b05e/doc' sphinx-build -b man -d _build/doctrees . _build/man Running Sphinx v1.7.5 make: Leaving directory '/builddir/build/BUILD/migen-afe4405becdbc76539f0195c319367187012b05e/doc'
Configuration error: There is a programable error in your configuration file:
Traceback (most recent call last): ... pkg_resources.DistributionNotFound: The 'migen' distribution was not found and is required by the application
This is tricky. It doesn't import it (that is easily tricked with PYTHONPATH), but uses pkg_resources to fetch data about installed packages.
I believe the easiest way is to sed conf.py to replace
pkg_resources.require("migen")[0].version
Argh, upstream is doing the typical overengineered crap. Do they realize that they are embedding the identifier of the _previously_ installed version in the docs?
This is overengineered, but the second part of what you said is not really always true - it depends. IMHO it's completely OK for upstream to build the docs like this:
pip install -e. make -C docs html
Zbyszek, Miro,
Thanks much for your help. I ended up calling sphinx-build-3 directly as per Zbyszek's example.
In retrospect, what tripped me up was that
pkg_resources.require("migen")[0].version
is *not* helped by setting PYTHONPATH, but the "import migen" line further down *is*. I had originally sed-replaced the version, but after I noticed the subsequent "import" I decided to just try setting PYTHONPATH to cover them *both*, which just kept on stubbornly refusing to work as the *only* workaround... :)
Thanks again, --Gabriel
On Fri, Feb 15, 2019 at 05:32:42PM +0000, Zbigniew Jędrzejewski-Szmek wrote:
On Fri, Feb 15, 2019 at 06:19:10PM +0100, Miro Hrončok wrote:
On 15. 02. 19 17:57, Gabriel L. Somlo wrote:
[...]
The following diff works for me: diff --git python-migen.spec python-migen.spec index 9ad29027c8..8dc929a214 100644 --- python-migen.spec +++ python-migen.spec @@ -35,9 +35,12 @@ A Python toolbox for building complex digital hardware. %prep %autosetup -n %{srcname}-%{commit0}
+sed -r -i 's/(migen_version = ).*/\1"%{version}-%{release}"/' doc/conf.py
%build %py3_build -%make_build -C doc latexpdf man +PYTHONPATH=. sphinx-build-3 -b latex doc/ _build/doc/ +PYTHONPATH=. sphinx-build-3 -b man doc/ _build/doc/
%install %py3_install
Zbyszek
python-devel@lists.fedoraproject.org