Skip to content

Include labscript-suite.pth in editable wheels #91

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

Merged
merged 2 commits into from
Dec 20, 2022
Merged

Conversation

chrisjbillington
Copy link
Member

This ensures user directories are added to the Python import path in editable installs that are performed via the new PEP660 mechanism used by default in newer versions of pip and setuptools.

The existing custom develop command is retained for compatibility with older setuptools and pip, which use python setup.py develop to create editable installs. It can be removed once it is safe to assume PEP660 functionality is available and default on all supported pip and setuptools versions sometime in the future.

Fixes #90

This ensures user directories are added to the Python import path in
editable installs that are performed via the new PEP660 mechanism used
by default in newer versions of pip and setuptools.

The existing custom `develop` command is retained for compatibility with
older setuptools and pip, which use `python setup.py develop` to create
editable installs. It can be removed once it is safe to assume PEP660
functionality is available and default on all supported pip and
setuptools versions sometime in the future.
@chrisjbillington
Copy link
Member Author

chrisjbillington commented Dec 19, 2022

Testing appreciated, here's how it looks for me:

(.venv) [bilbo:labscript]$ pip install --no-build-isolation --no-deps -e labscript-utils
Obtaining file:///home/bilbo/venvs/labscript/labscript-utils
  Checking if build backend supports build_editable ... done
  Preparing editable metadata (pyproject.toml) ... done
Building wheels for collected packages: labscript-utils
  Building editable for labscript-utils (pyproject.toml) ... done
  Created wheel for labscript-utils: filename=labscript_utils-3.2.0.dev49+g4fff9ad-0.editable-py3-none-any.whl size=5041 sha256=376f5289ce73f486671a3a205f9a99fdd1d41f0fc3742622b13ef46705c5bc7f
  Stored in directory: /tmp/pip-ephem-wheel-cache-2c7wkd3q/wheels/e4/a4/47/eab5f0b28ef97c422b8019d3e00f1b287143ce4449e1b9619e
Successfully built labscript-utils
Installing collected packages: labscript-utils
Successfully installed labscript-utils-3.2.0.dev49+g4fff9ad
(.venv) [bilbo:labscript]$ pip show -f labscript-utils
Name: labscript-utils
Version: 3.2.0.dev49+g4fff9ad
Summary: Shared utilities for the labscript suite
Home-page: http://labscriptsuite.org
Author: The labscript suite community
Author-email: [email protected]
License: BSD
Location: /home/bilbo/venvs/labscript/.venv/lib/python3.10/site-packages
Requires: h5py, importlib-metadata, numpy, packaging, pyqtgraph, qtutils, scipy, setuptools-scm, zprocess
Required-by: blacs, labscript, labscript-devices, labscript-suite, lyse, runmanager, runviewer
Files:
  ../../../bin/labscript-profile-create
  __editable__.labscript_utils-3.2.0.dev49+g4fff9ad.pth
  __editable___labscript_utils_3_2_0_dev49_g4fff9ad_finder.py
  __pycache__/__editable___labscript_utils_3_2_0_dev49_g4fff9ad_finder.cpython-310.pyc
  labscript-suite.pth
  labscript_utils-3.2.0.dev49+g4fff9ad.dist-info/INSTALLER
  labscript_utils-3.2.0.dev49+g4fff9ad.dist-info/LICENSE.txt
  labscript_utils-3.2.0.dev49+g4fff9ad.dist-info/METADATA
  labscript_utils-3.2.0.dev49+g4fff9ad.dist-info/RECORD
  labscript_utils-3.2.0.dev49+g4fff9ad.dist-info/REQUESTED
  labscript_utils-3.2.0.dev49+g4fff9ad.dist-info/WHEEL
  labscript_utils-3.2.0.dev49+g4fff9ad.dist-info/direct_url.json
  labscript_utils-3.2.0.dev49+g4fff9ad.dist-info/entry_points.txt
  labscript_utils-3.2.0.dev49+g4fff9ad.dist-info/top_level.txt

Crucially, including labscript-suite.pth in the list of files in the package after installation of the wheel.

Copy link
Contributor

@dihm dihm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is both simple and elegant. Thanks for sorting this out. The python build system is a real labyrinth. I've tested with python=3.9.15, setuptools=65.5.0 as well as python=3.8.11, setuptools=58.0.4 and everything seems to be in order.

As for deprecation nonsense, I did not realize desktop-app relied on a flat installs. Agreed generalizing is not that high of a priority. Specifying packages by hand would work, but is tedious. A more general method that appears to work and doesn't modify any structure is

--- a/setup.cfg
+++ b/setup.cfg
@@ -23,7 +23,7 @@ classifiers =
 [options]
 zip_safe = False
 include_package_data = True
-packages = labscript_utils, labscript_profile
+packages = find_namespace:
 python_requires = >=3.6
 install_requires =
   importlib_metadata>=1.0
@@ -36,6 +36,9 @@ install_requires =
   setuptools_scm>=4.1.0
   zprocess>=2.18.0

+[options.packages.find]
+include = labscript_*
+
 [options.extras_require]
 docs =
   PyQt5

I'll leave it to you to include or not, but this is definitely ready to merge.

@chrisjbillington
Copy link
Member Author

desktop-app only relies on flat layouts in the sense that, the changes I made the other day to make it work with editable wheels only implemented the way setuptools does editable wheels for flat layouts. Other than that there's no reliance on flat layouts that I'm aware of. I'll make it work with both when I'm feeling enthusiastic! Gotta fix desktop-app's build on GitHub actions anyway.

Thanks for testing! Just realised I should make the overridden method return the wheel filename, since the base method does, and then I'll merge.

Matching the behaviour of the base method, although nothing seems to be
relying on it.
@chrisjbillington chrisjbillington merged commit 2a8bc1d into master Dec 20, 2022
@chrisjbillington chrisjbillington deleted the pep660-fix branch December 20, 2022 01:34
dihm pushed a commit that referenced this pull request Mar 28, 2023
Include labscript-suite.pth in editable wheels
@dihm dihm mentioned this pull request Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Editable installs with setuptools>63 broken
2 participants