Bug 2176393 - %pyproject_build_lib does not work with hatchling backend
Summary: %pyproject_build_lib does not work with hatchling backend
Keywords:
Status: CLOSED CANTFIX
Alias: None
Product: Fedora
Classification: Fedora
Component: pyproject-rpm-macros
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Miro Hrončok
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-03-08 10:01 UTC by Elliott Sales de Andrade
Modified: 2023-05-16 17:05 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-05-16 17:05:00 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Elliott Sales de Andrade 2023-03-08 10:01:11 UTC
Description of problem:
I'm trying to update python-jupyter-console to the latest version. They have switched from setuptools to hatch [1].

The docs import the package, so the Fedora package sets PYTHONPATH="%{pyproject_build_lib}". This used to work with setuptools, but with hatch the docs fail to find the import. This is because %{pyproject_build_lib} returns an empty string. 

Version-Release number of selected component (if applicable):
pyproject-srpm-macros 1.6.3-1.fc39


Steps to Reproduce:
1. Modify python-jupyter-console version to 6.6.3 (and drop the patch)
2. Build python-jupyter-console


Actual results:
++ pyproject_build_lib=()
++ '[' -d build/lib.linux-x86_64-cpython-311 ']'
++ '[' -d build/lib.linux-x86_64-3.11 ']'
++ '[' -d build/lib ']'
+++ find /builddir/build/BUILD/jupyter_console-6.6.3/.pyproject-builddir -type d -wholename '/builddir/build/BUILD/jupyter_console-6.6.3/.pyproject-builddir/pip-req-build-*/build/lib.linux-x86_64-3.11'
+++ find /builddir/build/BUILD/jupyter_console-6.6.3/.pyproject-builddir -type d -wholename '/builddir/build/BUILD/jupyter_console-6.6.3/.pyproject-builddir/pip-req-build-*/build/lib'
+++ IFS=:
+++ echo ''
++ echo
+ /usr/bin/make -O -j4 V=1 VERBOSE=1 -C docs html PYTHONPATH=
make: Entering directory '/builddir/build/BUILD/jupyter_console-6.6.3/docs'
python3 autogen_config.py
make: Leaving directory '/builddir/build/BUILD/jupyter_console-6.6.3/docs'
Traceback (most recent call last):
  File "/builddir/build/BUILD/jupyter_console-6.6.3/docs/autogen_config.py", line 4, in <module>
    from jupyter_console.app import ZMQTerminalIPythonApp
ModuleNotFoundError: No module named 'jupyter_console'
make: *** [Makefile:60: config_options.rst] Error 1


Expected results:
Build passes.

Additional info:
[1] https://github.com/jupyter/jupyter_console/compare/v6.5.1...v6.6.3#diff-50c86b7ed8ac2cf95bd48334961bf0530cdc77b5a56f852c5c61b89d735fd711

Comment 1 Miro Hrončok 2023-03-08 10:17:17 UTC
Could you please open a WIP pull request for python-jupyter-console or attach a spec file to this bugzilla so it's easier for me to reproduce the problem?

Have you figured out what value of PYTHONPATH is needed (a.k.a. where are the files), or not yet?

(Setting FutureFeature because the macros are synced across all branches, but I recognize this as a bug.)

Comment 2 Miro Hrončok 2023-03-08 10:23:52 UTC
Here's my WIP PR to reproduce https://src.fedoraproject.org/rpms/python-jupyter-console/pull-request/7

Comment 3 Miro Hrončok 2023-03-08 10:37:36 UTC
Bad news: The files appear nowhere in the build directory. hatchling seems to simply pack them into the wheel from $PWD.

Despite pyproject-rpm-macros being a general build-backend tool, it seems the %{pyproject_build_lib} value is setuptools-specific. We might want to reconsider the name of the macro as well as the location in pyproject-rpm-macros. It was added there when pip defaulted to out-of-tree builds and it needed to include .pyproject-builddir -- this is no longer the case on Fedora 37+.

On Fedora 37, PYTHONPATH=$PWD/build/lib.%{python3_platform}-cpython-%{python3_version_nodots} is good enough for setuptools whether or not pyproject-rpm-macros are used.

I'll start a discussion on python-devel.

A solution for python-jupyter-console is to use PYTHONPATH=$PWD instead of PYTHONPATH="%{pyproject_build_lib}". I pushed it to https://src.fedoraproject.org/rpms/python-jupyter-console/pull-request/7

Comment 6 Miro Hrončok 2023-05-16 17:05:00 UTC
The macro has been deprecated in code and REDAME and it was not documented at https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/


Note You need to log in before you can comment on or make changes to this bug.