diff setup.py @ 52706:9ff926737dbc

setup: __modulepolicy__.py created in the source dir for editable mode
author paugier <pierre.augier@univ-grenoble-alpes.fr>
date Tue, 14 Jan 2025 15:55:16 +0100
parents 9ec635cc0a29
children 6ce3fc909a68
line wrap: on
line diff
--- a/setup.py	Thu Jan 23 08:50:22 2025 +0100
+++ b/setup.py	Tue Jan 14 15:55:16 2025 +0100
@@ -495,9 +495,6 @@
                 )
 
     def run(self):
-        basepath = os.path.join(self.build_lib, 'mercurial')
-        self.mkpath(basepath)
-
         rust = self.distribution.rust
         if self.distribution.pure:
             modulepolicy = 'py'
@@ -513,6 +510,14 @@
                 b'modulepolicy = b"%s"\n' % modulepolicy.encode('ascii'),
             ]
         )
+
+        if self.editable_mode:
+            here = os.path.dirname(__file__)
+            basepath = os.path.join(here, 'mercurial')
+        else:
+            basepath = os.path.join(self.build_lib, 'mercurial')
+            self.mkpath(basepath)
+
         write_if_changed(os.path.join(basepath, '__modulepolicy__.py'), content)
 
         build_py.run(self)