Skip to content

Commit d64de03

Browse files
authored
Merge pull request #835 from mprpic/add-source-hook-helper-docs
Add source hook helper docs and other docs fixes
2 parents 64ec201 + 6e19fd4 commit d64de03

File tree

6 files changed

+103
-71
lines changed

6 files changed

+103
-71
lines changed

docs/conf.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
1616

1717
project = "Fromager"
18-
copyright = "2024, Fromager Authors"
18+
copyright = "%Y, Fromager Authors"
1919
author = "Fromager Authors"
2020
release = metadata.version("fromager")
2121

@@ -30,14 +30,19 @@
3030
"sphinx.ext.intersphinx",
3131
]
3232

33+
# Enable MyST extensions to support reStructuredText directives in Markdown
34+
myst_enable_extensions = [
35+
"colon_fence",
36+
]
37+
3338
# Recognized suffixes
3439
source_suffix = {
3540
".rst": "restructuredtext",
3641
".md": "markdown",
3742
}
3843

3944
templates_path = ["_templates"]
40-
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "example"]
45+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
4146

4247
language = "English"
4348

@@ -67,7 +72,7 @@
6772

6873

6974
class FromagerHookDocumenter(FunctionDocumenter):
70-
"""Documenter for 'autofromagehook' directive"""
75+
"""Documenter for 'autofromagerhook' directive"""
7176

7277
objtype = "fromagerhook"
7378

@@ -79,7 +84,7 @@ def format_name(self):
7984

8085

8186
class PyFromagerHook(PyFunction):
82-
""":py:fromagehook"""
87+
""":py:fromagerhook"""
8388

8489
def handle_signature(self, sig: str, signode: desc_signature) -> tuple[str, str]:
8590
# hack to remove module prefix from output

docs/customization.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,15 +154,17 @@ bootstrap requirements, such as:
154154
my-package @ git+https://github.com/example/repo.git@v1.2.3
155155
```
156156

157-
For example requirements with git URLs, see:
157+
Example requirements file with Git URLs:
158158

159-
.. literalinclude:: example/requirements-git-example.txt
160-
:caption: requirements-git-example.txt
159+
```{literalinclude} example/requirements-git-example.txt
160+
:caption: requirements-git-example.txt
161+
```
161162

162-
For a complete package configuration example, see:
163+
A complete package configuration example:
163164

164-
.. literalinclude:: example/git-submodules-example.yaml
165-
:caption: git-submodules-example.yaml
165+
```{literalinclude} example/git-submodules-example.yaml
166+
:caption: git-submodules-example.yaml
167+
```
166168

167169
### Build directory
168170

docs/example/skip-constraints-example.md

Lines changed: 0 additions & 58 deletions
This file was deleted.

docs/hooks.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,17 @@ Source hooks
240240

241241
The return value is the ``Path`` to the newly created source distribution.
242242

243+
Source helper functions
244+
~~~~~~~~~~~~~~~~~~~~~~~
245+
246+
The following helper functions are available in the ``fromager.sources`` module
247+
for use in custom source hooks:
248+
249+
.. autofunction:: fromager.sources.ensure_pkg_info
250+
251+
.. autofunction:: fromager.sources.pep517_build_sdist
252+
253+
.. autofunction:: fromager.sources.unpack_source
243254

244255
Wheel hooks
245256
-----------

docs/how-tos/multiple-versions.rst

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,74 @@ Important Considerations
5757
The graph and build-sequence files can already handle multiple conflicting
5858
versions, so this change simply allows bypassing the final constraints
5959
validation step that ensures pip-compatibility.
60+
61+
Complete Example
62+
----------------
63+
64+
This example demonstrates a complete walkthrough of using the ``--skip-constraints``
65+
option to build wheel collections containing conflicting package versions.
66+
67+
Use Case
68+
~~~~~~~~
69+
70+
Suppose you need to build a package index that contains multiple versions of the
71+
same package for different downstream consumers. For example, you might want to
72+
include both Django 3.2 and Django 4.0 in your collection.
73+
74+
Requirements Files
75+
~~~~~~~~~~~~~~~~~~
76+
77+
Create a requirements file with conflicting versions:
78+
79+
**requirements-conflicting.txt**
80+
81+
.. code-block:: text
82+
83+
django==3.2.0
84+
django==4.0.0
85+
requests==2.28.0
86+
87+
Normally, this would fail with a conflict error because both Django versions
88+
cannot be installed together.
89+
90+
Running with --skip-constraints
91+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
92+
93+
.. code-block:: bash
94+
95+
fromager bootstrap --skip-constraints \
96+
--sdists-repo ./sdists-repo \
97+
--wheels-repo ./wheels-repo \
98+
--work-dir ./work-dir \
99+
-r requirements-conflicting.txt
100+
101+
Expected Behavior
102+
~~~~~~~~~~~~~~~~~
103+
104+
1. **Success**: Both Django versions will be built successfully
105+
2. **Output Files**:
106+
107+
- ``build-order.json`` - Contains build order for all packages
108+
- ``graph.json`` - Contains dependency resolution graph
109+
- No ``constraints.txt`` file is generated
110+
111+
3. **Wheel Repository**: Contains wheels for both Django versions and their respective dependencies
112+
113+
Verification
114+
~~~~~~~~~~~~
115+
116+
Check that both versions were built:
117+
118+
.. code-block:: bash
119+
120+
find wheels-repo/downloads/ -name "Django-*.whl"
121+
# Expected output:
122+
# wheels-repo/downloads/Django-3.2.0-py3-none-any.whl
123+
# wheels-repo/downloads/Django-4.0.0-py3-none-any.whl
124+
125+
Verify no constraints file was created:
126+
127+
.. code-block:: bash
128+
129+
ls work-dir/constraints.txt
130+
# Expected: file does not exist

src/fromager/sources.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ def unpack_source(
354354
version: Version,
355355
source_filename: pathlib.Path,
356356
) -> tuple[pathlib.Path, bool]:
357+
"""Extracts a downloaded source archive (.tar.gz or .zip file) into a standardized directory."""
357358
# sdist names are less standardized and the names of the directories they
358359
# contain are also not very standard. Force the names into a predictable
359360
# form based on the override module name for the requirement.
@@ -704,13 +705,13 @@ def ensure_pkg_info(
704705
sdist_root_dir: pathlib.Path,
705706
build_dir: pathlib.Path | None = None,
706707
) -> bool:
707-
"""Ensure that sdist has a PKG-INFO file
708+
"""Ensure that sdist has a PKG-INFO file.
708709
709-
Returns True if PKG-INFO was presence, False if file was missing. The
710+
Returns True if PKG-INFO is present, False if file is missing. The
710711
function also updates build_dir if package has a non-standard build
711712
directory. Every sdist must have a PKG-INFO file in the first directory.
712713
The additional PKG-INFO file in build_dir is required for projects
713-
with non-standard layout and setuptools-scm.
714+
with a non-standard layout and projects using setuptools-scm.
714715
"""
715716
had_pkg_info = True
716717
directories = [sdist_root_dir]

0 commit comments

Comments
 (0)