Skip to content

Commit 5025b1b

Browse files
Merge pull request #58 from philipstarkey/philipstarkey/issue43
Fixes .pth file has no effect in editable install
2 parents f77525f + ed76901 commit 5025b1b

File tree

3 files changed

+19
-22
lines changed

3 files changed

+19
-22
lines changed

labscript-suite.pth

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
import labscript_profile; labscript_profile.add_userlib_and_pythonlib()
2-
import labscript_profile; labscript_profile.add_development_directories()
1+
import sys; exec("try: import labscript_profile; labscript_profile.add_userlib_and_pythonlib()\nexcept ModuleNotFoundError: pass")

labscript_profile/__init__.py

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import site
12
import sys
23
import os
34
from configparser import ConfigParser, NoSectionError, NoOptionError
@@ -56,22 +57,4 @@ def add_userlib_and_pythonlib():
5657
except (NoSectionError, NoOptionError):
5758
paths = []
5859
for path in paths:
59-
if os.path.exists(path):
60-
sys.path.append(path)
61-
62-
63-
def add_development_directories():
64-
"""Prepend directories in <LABSCRIPT_SUITE_PROFILE>/dev to the search path, if they
65-
are listed in the file <LABSCRIPT_SUITE_PROFILE>/dev/enabled (if that file
66-
exists)."""
67-
if LABSCRIPT_SUITE_PROFILE is None:
68-
return
69-
dev_dir = LABSCRIPT_SUITE_PROFILE / 'dev'
70-
enabled_file = dev_dir / 'enabled'
71-
if not os.path.exists(enabled_file):
72-
return
73-
with open(enabled_file) as f:
74-
for line in f:
75-
repository = dev_dir / line.strip()
76-
if os.path.isdir(repository):
77-
sys.path.insert(0, repository)
60+
site.addsitedir(path)

setup.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
11
import os
22
from setuptools import setup
3+
from setuptools.command.develop import develop
4+
from distutils import log
5+
6+
7+
class develop_command(develop):
8+
"""Custom develop command which installs the .pth file to site-packages for editable
9+
installs."""
10+
def run(self):
11+
path = os.path.join(self.install_dir, 'labscript-suite.pth')
12+
super().run()
13+
if not self.uninstall:
14+
log.info(f'Copying labscript-suite.pth to {path}')
15+
if not self.dry_run:
16+
self.copy_file('labscript-suite.pth', path)
17+
318

419
VERSION_SCHEME = {
520
"version_scheme": os.getenv("SCM_VERSION_SCHEME", "guess-next-dev"),
621
"local_scheme": os.getenv("SCM_LOCAL_SCHEME", "node-and-date"),
722
}
823

9-
setup(use_scm_version=VERSION_SCHEME)
24+
setup(use_scm_version=VERSION_SCHEME, cmdclass={'develop': develop_command})

0 commit comments

Comments
 (0)