Skip to content

Commit d8aae7c

Browse files
committed
Add editable strategy based on a link tree
- Add implementation of editable strategy based on a link tree - This is the `strict` implementation. - Only files are linked, not directories. - This approach makes it possible to use harlinks when softlinks are not available (e.g. Windows) - It also guarantees files that would not be part of the final wheel are not available in the editable install. - Add non-editable files to the produced wheel wheel (e.g. `headers`, `scripts`, `data`)
2 parents ceaa554 + 9c527cd commit d8aae7c

File tree

5 files changed

+456
-89
lines changed

5 files changed

+456
-89
lines changed

setuptools/command/build_ext.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import itertools
44
from importlib.machinery import EXTENSION_SUFFIXES
55
from distutils.command.build_ext import build_ext as _du_build_ext
6-
from distutils.file_util import copy_file
76
from distutils.ccompiler import new_compiler
87
from distutils.sysconfig import customize_compiler, get_config_var
98
from distutils.errors import DistutilsError
@@ -96,10 +95,7 @@ def copy_extensions_to_source(self):
9695
# Always copy, even if source is older than destination, to ensure
9796
# that the right extensions for the current Python/platform are
9897
# used.
99-
copy_file(
100-
src_filename, dest_filename, verbose=self.verbose,
101-
dry_run=self.dry_run
102-
)
98+
build_py.copy_file(src_filename, dest_filename)
10399
if ext._needs_stub:
104100
self.write_stub(package_dir or os.curdir, ext, True)
105101

setuptools/command/build_py.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ def finalize_options(self):
3636
if 'data_files' in self.__dict__:
3737
del self.__dict__['data_files']
3838
self.__updated_files = []
39+
self.use_links = None
40+
41+
def copy_file(self, infile, outfile, preserve_mode=1, preserve_times=1,
42+
link=None, level=1):
43+
# Overwrite base class to allow using links
44+
link = getattr(self, "use_links", None) if link is None else link
45+
if link:
46+
infile = str(Path(infile).resolve())
47+
outfile = str(Path(outfile).resolve())
48+
return super().copy_file(infile, outfile, preserve_mode,
49+
preserve_times, link, level)
3950

4051
def run(self):
4152
"""Build modules, packages, and copy data files to build directory"""

0 commit comments

Comments
 (0)