Skip to content

Commit cfd7703

Browse files
jaimergpbollwyvl
andcommitted
Port to Docusaurus
Co-authored-by: Nicholas Bollweg <[email protected]>
1 parent 6cbd394 commit cfd7703

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

docs/maintainer/knowledge_base.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,6 +1364,89 @@ Currently available packages:
13641364
- exceptiongroup
13651365
- importlib-metadata
13661366

1367+
## Python PEP517 Build Isolation {#pep517}
1368+
1369+
[PEP517](https://www.python.org/dev/peps/pep-0517/) paves the way for building python wheels in a well-defined, isolated environment, and is generally a good step forward. However, `conda-build` already performs this function, even distinguishing between the `host` and `build` environments, and supporting additional, heavyweight dependencies like compilers and other build-time language runtimes.
1370+
1371+
### Common PEP517 Problems
1372+
1373+
A number of symptoms of PEP517 build isolation conflicts with `conda-build` manifest in different ways.
1374+
1375+
#### `ModuleNotFoundError` during test
1376+
1377+
When problems occur at the interaction of `pip` and more exotic build tools like e.g. `poetry` and `flit`, the expected output can leave the as-installed package in a bad state, which might leave the following `meta.yaml` excerpt like this...
1378+
1379+
```yaml
1380+
package:
1381+
name: foopkg
1382+
version: 0.1.0
1383+
1384+
build:
1385+
script: {{ PYTHON }} -m pip install . -vv
1386+
1387+
requirements:
1388+
host:
1389+
- poetry-core
1390+
- python
1391+
run:
1392+
- python
1393+
1394+
test:
1395+
requires:
1396+
- pip
1397+
imports:
1398+
- foopkg
1399+
commands:
1400+
- pip check
1401+
```
1402+
1403+
...showing an error like this:
1404+
1405+
```sh
1406+
File "~/conda/feedstock_root/build_artifacts/foopkg_1635435591741/test_tmp/run_test.py", line 2, in <module>
1407+
import foopkg
1408+
ModuleNotFoundError: No module named 'foopkg'
1409+
import: 'foopkg'
1410+
```
1411+
1412+
#### Version `0.0.0` reported
1413+
1414+
Further, some other tools such as `setuptools_scm` might leave the version observed by e.g. `pip check` or `entry_points` at `0.0.0`.
1415+
1416+
### PEP517 Workarounds
1417+
1418+
:::note
1419+
Some workarounds are available for the above problems, but eventually this will have to be fixed in `conda-build` itself
1420+
:::
1421+
1422+
#### Use Deprecated Out-of-Tree Build (preferred)
1423+
1424+
```yaml
1425+
build:
1426+
script: {{ PYTHON }} -m pip install . -vv --use-deprecated=out-of-tree-build
1427+
```
1428+
1429+
This falls back to some previous `pip` behavior, and allows many builds to continue normally
1430+
1431+
:::tip[Hint]
1432+
While this is a deprecated feature which will be removed in the future, it has the advantage of being a <span class="title-ref">well-known string</span> for which it might be possible to write an automated migration once a real fix is available.
1433+
:::
1434+
1435+
#### Delete `pyproject.toml`
1436+
1437+
```yaml
1438+
build:
1439+
script:
1440+
- {{ PYTHON }} -c "__import__('os').unlink('pyproject.toml')"
1441+
- {{ PYTHON }} -m pip install . -vv
1442+
```
1443+
1444+
In the absence of a `pyproject.toml`, installation will fall back on legacy metadata files such as `setup.py` and/or `setup.cfg`.
1445+
1446+
:::warning
1447+
This relies on most PEP517-compliant tools generating these files to include in `.tar.gz` during the build process. It is unknown how long this will be supported, and is likely to introduce other, unknown issues as more build/test tools make use of `pyproject.toml`.
1448+
:::
1449+
13671450
<a id="noarch-builds"></a>
13681451

13691452
## Noarch builds

0 commit comments

Comments
 (0)