Skip to content

Commit 4fff9ad

Browse files
Include labscript-suite.pth in editable wheels
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.
1 parent f1ef4eb commit 4fff9ad

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

setup.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,24 @@
33
from setuptools.command.develop import develop
44
import logging
55

6+
# Setupstools >=64
7+
try:
8+
from setuptools.command.editable_wheel import editable_wheel
9+
except ImportError:
10+
editable_wheel_command = None
11+
else:
12+
from wheel.wheelfile import WheelFile
613

14+
class editable_wheel_command(editable_wheel):
15+
"""Custom editable_wheel command which installs the .pth file to the
16+
wheel file for editable installs."""
17+
def _create_wheel_file(self, bdist_wheel):
18+
wheel_path = super()._create_wheel_file(bdist_wheel)
19+
with WheelFile(wheel_path, 'a') as wheel:
20+
wheel.write("labscript-suite.pth")
21+
22+
23+
# Setuptools <= 63:
724
class develop_command(develop):
825
"""Custom develop command which installs the .pth file to site-packages for editable
926
installs."""
@@ -21,4 +38,10 @@ def run(self):
2138
"local_scheme": os.getenv("SCM_LOCAL_SCHEME", "node-and-date"),
2239
}
2340

24-
setup(use_scm_version=VERSION_SCHEME, cmdclass={'develop': develop_command})
41+
setup(
42+
use_scm_version=VERSION_SCHEME,
43+
cmdclass={
44+
'develop': develop_command,
45+
'editable_wheel': editable_wheel_command,
46+
},
47+
)

0 commit comments

Comments
 (0)