Skip to content

Commit f91aaf3

Browse files
authored
Add pep517 section
1 parent e2947bf commit f91aaf3

File tree

1 file changed

+112
-2
lines changed

1 file changed

+112
-2
lines changed

src/maintainer/knowledge_base.rst

Lines changed: 112 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,115 @@ Currently available packages:
916916
| typing | | python >=3 |
917917
+-------------+-------------------+--------------+
918918

919+
.. _knowledge:pep517:
920+
921+
Python PEP517 Build Isolation
922+
-----------------------------
923+
924+
`PEP517 <https://www.python.org/dev/peps/pep-0517/>`_ paves the way for building
925+
python wheels in a well-defined, isolated environment, and is generally a good step
926+
forward. However, ``conda-build`` already performs this function, even distinguishing
927+
between the ``host`` and ``build`` environments, and supporting additional,
928+
heavyweight dependencies like compilers and other build-time language runtimes.
929+
930+
931+
Common PEP517 Problems
932+
^^^^^^^^^^^^^^^^^^^^^^
933+
934+
A number of symptoms of PEP517 build isolation conflicts with ``conda-build``
935+
manifest in different ways.
936+
937+
``ModuleNotFoundError`` during test
938+
"""""""""""""""""""""""""""""""""""
939+
940+
When problems occur at the interacton of ``pip`` and more exotic build tools like
941+
e.g. ``poetry`` and ``flit``, the expected output can leave the as-installed package in
942+
a bad state, which might leave the following ``meta.yaml`` excerpt like this:
943+
944+
.. code-block:: yaml
945+
946+
package:
947+
name: foopkg
948+
version: 0.1.0
949+
950+
build:
951+
script: {{ PYTHON }} -m pip install . -vv
952+
953+
requirements:
954+
host:
955+
- poetry-core
956+
- python
957+
run:
958+
- python
959+
960+
test:
961+
requires:
962+
- pip
963+
imports:
964+
- foopkg
965+
commands:
966+
- pip check
967+
968+
To show an error like this
969+
970+
.. code-block:: sh
971+
972+
File "~/conda/feedstock_root/build_artifacts/foopkg_1635435591741/test_tmp/run_test.py", line 2, in <module>
973+
import foopkg
974+
ModuleNotFoundError: No module named 'foopkg'
975+
import: 'foopkg'
976+
977+
Version ``0.0.0`` reported
978+
""""""""""""""""""""""""""
979+
980+
Further, some other tools such as ``setuptools_scm`` might leave the version
981+
observed by e.g. ``pip check`` or ``entry_points`` at ``0.0.0``.
982+
983+
984+
PEP517 Workarounds
985+
^^^^^^^^^^^^^^^^^^
986+
987+
.. note::
988+
989+
Some workarounds are available for the above problems, but eventually this will
990+
have to be fixed in ``conda-build`` itself
991+
992+
Use Deprecated Out-of-Tree Build (preferred)
993+
""""""""""""""""""""""""""""""""""""""""""""
994+
995+
.. code-block:: yaml
996+
997+
build:
998+
script: {{ PYTHON }} -m pip install . -vv --use-deprecated=out-of-tree-build
999+
1000+
This falls back to some previous ``pip`` behavior, and allows many builds to continue
1001+
normally
1002+
1003+
.. hint::
1004+
1005+
While this is a deprecated feature which will be removed in the future, it has
1006+
the advantage of being a `well-known string` for which it might be possible to
1007+
write an automated migration once a real fix is available.
1008+
1009+
Delete ``pyproject.toml``
1010+
"""""""""""""""""""""""""
1011+
1012+
.. code-block:: yaml
1013+
1014+
build:
1015+
script:
1016+
- {{ PYTHON }} -c "__import__('os').unlink('pyproject.toml')"
1017+
- {{ PYTHON }} -m pip install . -vv
1018+
1019+
In the absence of a ``pyproject.toml``, installation will fall back on legacy
1020+
metadata files such as ``setup.py`` and/or ``setup.cfg``.
1021+
1022+
.. warning::
1023+
1024+
This relies on most PEP517-compliant tools generating these files to include in
1025+
``.tar.gz`` during the build process. It is unknown how long this will be
1026+
supported, and is likely to introduce other, unknown issues as more build/test
1027+
tools make use of ``pyproject.toml``.
9191028

9201029
Noarch builds
9211030
=============
@@ -1431,13 +1540,13 @@ Installing a pre-release build
14311540
Use the following command, but replace ``PACKAGE_NAME`` with the package you want
14321541
to install and replace ``LABEL`` with ``rc`` or ``dev``:
14331542

1434-
.. code-block:: yaml
1543+
.. code-block:: sh
14351544
14361545
conda install -c conda-forge/label/PACKAGE_NAME_LABEL -c conda-forge PACKAGE_NAME
14371546
14381547
For example, let's install matplotlib from the ``rc`` label:
14391548

1440-
.. code-block:: yaml
1549+
.. code-block:: sh
14411550
14421551
conda install -c conda-forge/label/matplotlib_rc -c conda-forge matplotlib
14431552
@@ -1464,3 +1573,4 @@ The tl;dr here is that conda sorts as follows:
14641573
So make sure that you **tag** your package in such a way that the package name
14651574
that conda-build spits out will sort the package uploaded with an ``rc`` label
14661575
higher than the package uploaded with the ``dev`` label.
1576+

0 commit comments

Comments
 (0)