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
3.5.1: cannot add module metadata in project tree #491
Comments
If you're writing a PEP 517 frontend, you can use the Otherwise, the
|
+55% of my rpm packages with python modules renders documentation over sphinx. Amongst those packages ~30% needs access to the package metadata to injet things like version, athor or other to rendered documentation. Usually it is not a big problem because whem So what exactly needs to be added in project.toml tto have created metadata directory during the build when |
Can you point me to an example of a package built with Flit where the Sphinx docs rely on a |
@kloczek Please read https://pip.pypa.io/en/latest/reference/build-system/ to understand how setup.py based projects vs pyproject.toml based projects are different. That documentation also goes into how the process for generating metadata for those two styles of build systems is different. You can use the https://github.com/pypa/pep517/ project to write a frontend that can generate metadata as you need. |
I've already pointewd on such example .. So .. does it mean that when |
There is, and @takluyver has mentioned it already:
|
We are not taking about |
It will. |
See also https://www.python.org/dev/peps/pep-0517/#prepare-metadata-for-build-wheel, because I'm sure you will ask a bunch of follow up questions that are already answered in the PEP. :) |
@kloczek Your comment seems to be poorly formatted. I request you to read https://help.github.com/articles/getting-started-with-writing-and-formatting-on-github/ and improve the formatting of your comment by editing it in place, using the pencil icon in the corner. |
So moment .. does it mean that |
Yes? You need to run the PEP 517 hook, as explained already. I'm not going to be answering any more direct questions that are clearly answered in the documentation I've already linked you to. Please do the reading work necessary to understand how to achieve what you're trying to do. If something is unclear, feel free to ask more questions. |
You did, my apologies. It appears that structlog is set up that it expects you to install the Python package first, then build the docs. This is what both the Readthedocs config and the docs task in I tried, out of interest, copying the @pradyunsg I think there was a sensible question to answer here. It's just come as an X Y problem, where X is 'make Sphinx builds using importlib.metadata work' and Y is 'create a |
OK so it woud be really good to implemt calling that hook. [tkloczko@ss-desktop SPECS]$ grep 'python3dist(flit)' *
python-cssselect2.spec:BuildRequires: python3dist(flit)
python-installer.spec:BuildRequires: python3dist(flit)
python-jeepney.spec:BuildRequires: python3dist(flit)
python-sphinxcontrib-github-alt.spec:BuildRequires: python3dist(flit)
python-structlog.spec:BuildRequires: python3dist(flit)
python-threadpoolctl.spec:BuildRequires: python3dist(flit)
python-tomli.spec:BuildRequires: python3dist(flit)
python-tomli-w.spec:BuildRequires: python3dist(flit)
python-typing-extensions.spec:BuildRequires: python3dist(flit)
[tkloczko@ss-desktop SPECS]$ grep 'python3dist(flit)' * -l| xargs grep %py3_build_sphinx_man
python-cssselect2.spec:%py3_build_sphinx_man
python-jeepney.spec:%py3_build_sphinx_man
python-structlog.spec:%py3_build_sphinx_man Looking on above list it will be more than one such case. |
This is not what precisely is expected. In such cases it is expected access to the module metadata .. only. |
BTW [tkloczko@ss-desktop SPECS]$ grep 'python3dist(flit)' * -l| xargs grep echo
python-cssselect2.spec:echo 'from setuptools import setup; setup()' > setup.py
python-jeepney.spec:echo 'from setuptools import setup; setup()' > setup.py
python-structlog.spec:echo 'from setuptools import setup; setup()' > setup.py [tkloczko@ss-desktop SPECS]$ rpm -E %py3_build_sphinx_man
\
PBR_VERSION=%{version} \
SETUPTOOLS_SCM_PRETEND_VERSION=%{version} \
/usr/bin/python3 setup.py build_sphinx -b man --build-dir build/sphinx It would be nice if flit will have its own flit<>sphinx integration (as I wrote more than half my modules provides possibility to render dosumentation in necessay format) |
And .. probably the best would be if pep517 would provide hook to generate documentation :) |
No, it's not a coincidence. That is the metadata that accompanies an installed module. It's described in a specification entitled Recording installed projects. The coincidence is that setuptools also tends to dump metadata in the project tree when you do certain operations.
Writing the I understand that you've developed a whole load of tricks around setuptools, and I'm sorry that we're breaking them. But we've spent a load of time and effort getting away from the idea that everything in packaging must either use setuptools or pretend to be setuptools. We'll help you adapt to that, but we're not interested in arguments that 'you should do this because setuptools does'.
We've been over this topic at some length in other issues. Both Flit and PEP 517 are about packaging - that is, how we get from a source tree to an installable artefact and to an installed Python package (importable libraries, runnable scripts, etc.). From the perspective of people working on Python packaging, building documentation is an entirely separate concern, so we're not about to mix it into packaging tools or standards. At a practical level, it's also not clear to me what 'flit<>sphinx integration' would do. It would be neat in theory if there was one accepted way to build docs regardless of packaging or documentation system, but given that you're already using the Sphinx specific Fedora has already developed tools to put Python packages into rpms using PEP 517 interfaces. Maybe you could reuse some of their work? Two Fedora developers gave a talk about it at PackagingCon, which you can see here: https://www.youtube.com/watch?v=pJlqB-PA96E |
So what is the proper/right solution in such cases when after build other steps may need access to module metadata before actual install?
Using setuptools<>sphinx integration on packaging is VERY useful because it doesn't matter where source of the documentation and conf.py files are I can render documentation using exactly the same command (setup.cfg contains documentation root relative directory) [tkloczko@ss-desktop SPECS]$ grep %py3_build_sphinx_man python-* | wc -l; ls -1 python-*|wc -l
378
738
If may I point that Fedora do not care about generate python modules documentation and/or generate that documentation in unified form. [tkloczko@ss-desktop SPECS.fedora]$ grep '%package.* doc' python-*spec| wc -l
252 BTW pep517 and Fedora. Still %75 of all Fedora modules are not using pep517 [tkloczko@ss-desktop SPECS.fedora]$ grep %py3_build python-* | wc -l; ls -1 python-*|wc -l
2061
2716 (In that case I would ignore fact that most Fedora packagers do not understand that if someone needs to install package X without documentation that documentation do not need to be packages in separated package because on install time it is possible to decide to install that package with or without documentation by use or not In other words .. Fedora it is not the best example to show something in context of package python modules documentation :( |
There isn't. You'll need to install the package in the environment where you're trying to generate the documentation. Here's an example of how that could work, as a sequence of shell commands: pip install . # replace this with whatever you want to do to install structlog
sphinx-build -b html docs/ docs/_build |
Just finished watching that video. [tkloczko@ss-desktop SPECS.fedora]$ grep %check python-*spec -l| wc -l; ls -1 python-*spec |wc -l
1918
2716 [tkloczko@ss-desktop SPECS]$ grep %check python-*spec -l| wc -l; ls -1 python-*spec |wc -l
738
738 I'm strictly using provided test suites so if you will looking on my profile activity recently majority of opened by me tickets is about test suites issues. |
You may choose any of these options:
I understand that that's useful. But it's nothing to do with packaging, and insisting that it is is not getting you anywhere. It's not going to be a feature in Flit. You will get further by accepting that and thinking about what to do instead than If you want to make a little helper tool that looks for a relative path to docs in a specific key of In practice, most packages I've seen call the folder either
That doesn't surprise me: most Python packages still use setuptools, so there's no need to change how they're packaged. It doesn't subtract from the fact that they have the mechanisms to deal with PEP 517 packages, and they appear to be using them for many packages without major problems. I'm going to close this now, because I don't think it's going anywhere. You seem very determined to tell us exactly how we should approach packaging, and you don't seem to pay any attention when we disagree. We went through this at length on issue #429 as well. Engaging in an endless argument is a waste of everyone's time. |
Please look one more time on top of this ticket in which I've already wrote that this does not work (probably because pip do not understand |
100% wrong impression .. please. IMO fact that when Nevertheless seems like delegating generate metadata to the backend modules seems it may be pep517 design issue (correct me if I'm wring) because all backend modules would be sharing here 100% of the code. |
That ticket case was about proposition of handling documentation build by |
It is generating that metadata. Do a If you're looking somewhere else, that's the wrong place to look. Beyond that, I suggest you read PEP 517 and the links that have been shared with you earlier in this thread by the folks involved in designing the mechanisms that give you what you want (instead of dismissing the information being shared with you, to help you understand things). 🤷🏽 |
Please try to do that with [tkloczko@ss-desktop structlog-21.5.0]$ pip install .
Defaulting to user installation because normal site-packages is not writeable
Processing /home/tkloczko/rpmbuild/BUILD/structlog-21.5.0
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: structlog
Building wheel for structlog (pyproject.toml) ... done
Created wheel for structlog: filename=structlog-21.5.0-py3-none-any.whl size=53394 sha256=25248d87e3459092b5c7f59f3e97b743cdc8a5593212af9f6f821bc5a3280d4c
Stored in directory: /home/tkloczko/.cache/pip/wheels/35/89/3a/cd47c49b9d6c16185c5a0f83a41dd101771681f0d2bcadf8f3
Successfully built structlog
Installing collected packages: structlog
Attempting uninstall: structlog
Found existing installation: structlog 21.5.0
Uninstalling structlog-21.5.0:
Successfully uninstalled structlog-21.5.0
Successfully installed structlog-21.5.0
[tkloczko@ss-desktop structlog-21.5.0]$ find . -name \*-info
[tkloczko@ss-desktop structlog-21.5.0]$ |
Without running build_sphinx
Running Sphinx v4.3.2
Configuration error:
There is a programmable error in your configuration file:
Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/sphinx/config.py", line 329, in eval_config_file
exec(code, namespace)
File "/home/tkloczko/rpmbuild/BUILD/structlog-21.5.0/docs/conf.py", line 46, in <module>
release = metadata.version("structlog")
File "/usr/lib64/python3.8/importlib/metadata.py", line 530, in version
return distribution(distribution_name).version
File "/usr/lib64/python3.8/importlib/metadata.py", line 503, in distribution
return Distribution.from_name(distribution_name)
File "/usr/lib64/python3.8/importlib/metadata.py", line 177, in from_name
raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: structlog |
@pradyunsg said "look inside site-packages", which your We've both tried to explain that the generated metadata goes in the installation directory, not the project source tree, and it's found in site-packages when building the docs. I did try this locally with structlog: I installed from a git checkout, saw the |
And I've been trying to explain that metadata *directory but not that directory inside .whl archive produced as part of the build process should be added. That metatadata inside of the .whl are useless for sphinx. Again: about 60% of my all rpm spec files used to package python modules contains sphinx documentation. About 30% of all those modules to build documentation using sphinx needs module metadata to inject things like author, version or other bits to render documentation in exact output format. Really .. please to understand whole workflow of the build process during packaging into for example rpm or Solaris IPS package with rendering documentation as well. |
It is produced in the site-packages directory when you install, not just in the wheel. Building the documentation works with it there. Install the Python package first, then build the docs - or come up with a workaround like installing to a temporary directory and setting PYTHONPATH. We're going round and round in circles here - I'm not telling you anything new, and you're not telling me anything new. You certainly haven't convinced me that anything needs to change in Flit. I'm sorry, but I'm going to lock this issue now - the endless argument is a waste of both of our time, and a source of frustration. When I get time for open source work, I want to do something more productive than this. |
I'm trying ot add .{dist|egg}.info metadata in
structlog
module which is using as build backendflit
and looks like it is not possible to do thatLoks like pip is not able to take
[project]
section from pyproject.toml.How can I do that?
flit
command seems does not offer anything like generate .{dist|egg}.info directory :/The text was updated successfully, but these errors were encountered: