File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change 11
11
from inspect import isawaitable
12
12
from logging import getLogger
13
13
from pathlib import Path
14
- from subprocess import CalledProcessError
14
+ from subprocess import PIPE , CalledProcessError
15
15
from types import TracebackType
16
16
from typing import (
17
17
TYPE_CHECKING ,
@@ -344,6 +344,19 @@ async def build_local(self) -> None:
344
344
target .parent .mkdir (parents = True , exist_ok = True )
345
345
if not target .exists ():
346
346
shutil .copy2 (source , target , follow_symlinks = False )
347
+
348
+ # as .git is not copied, we have to initialize a dummy git repository
349
+ # in the copied directory (for setuptools-scm)
350
+ git_init_cmd = ("git" , "init" , "--initial-branch=dummy" )
351
+ with tempfile .SpooledTemporaryFile (max_size = 1024 ) as f :
352
+ process = await asyncio .create_subprocess_exec (
353
+ * git_init_cmd , cwd = tmp , stdout = f , stderr = PIPE
354
+ )
355
+ out , err = await process .communicate ()
356
+ if process .returncode :
357
+ raise CalledProcessError (
358
+ process .returncode , " " .join (git_init_cmd ), stderr = err
359
+ )
347
360
except CalledProcessError :
348
361
logger .warning (
349
362
"Could not list un-ignored files using git. Copying full working directory..."
Original file line number Diff line number Diff line change @@ -220,7 +220,9 @@ async def _copy_tree(
220
220
)
221
221
out , err = await process .communicate ()
222
222
if process .returncode :
223
- raise CalledProcessError (process .returncode , " " .join (cmd ), stderr = err )
223
+ raise CalledProcessError (
224
+ process .returncode , " " .join (git_init_cmd ), stderr = err
225
+ )
224
226
225
227
226
228
async def file_exists (repo : Path , ref : GitRef , file : PurePath ) -> bool :
You can’t perform that action at this time.
0 commit comments