@@ -46,7 +46,6 @@ def __init__(
46
46
self ._poetry = poetry
47
47
self ._package = poetry .package
48
48
self ._path = poetry .file .parent
49
- self ._original_path = self ._path
50
49
self ._excluded_files = None
51
50
self ._executable = Path (executable or sys .executable ) # type: Path
52
51
@@ -99,7 +98,7 @@ def build(self):
99
98
def find_excluded_files (self ): # type: () -> Set[str]
100
99
if self ._excluded_files is None :
101
100
# Checking VCS
102
- vcs = get_vcs (self ._original_path )
101
+ vcs = get_vcs (self ._path )
103
102
if not vcs :
104
103
vcs_ignored_files = set ()
105
104
else :
@@ -158,7 +157,9 @@ def find_files_to_add(
158
157
if self .format in formats :
159
158
for current_file in file .glob ("**/*" ):
160
159
include_file = BuildIncludeFile (
161
- path = current_file , source_root = self ._path
160
+ path = current_file ,
161
+ project_root = self ._path ,
162
+ source_root = self ._path ,
162
163
)
163
164
164
165
if not current_file .is_dir () and not self .is_excluded (
@@ -176,10 +177,12 @@ def find_files_to_add(
176
177
else :
177
178
source_root = self ._path
178
179
179
- include_file = BuildIncludeFile (path = file , source_root = source_root )
180
+ include_file = BuildIncludeFile (
181
+ path = file , project_root = self ._path , source_root = source_root
182
+ )
180
183
181
184
if self .is_excluded (
182
- include_file .relative_to_source_root ()
185
+ include_file .relative_to_project_root ()
183
186
) and isinstance (include , PackageInclude ):
184
187
continue
185
188
@@ -197,13 +200,15 @@ def find_files_to_add(
197
200
if self ._package .build_script and not exclude_build :
198
201
to_add .add (
199
202
BuildIncludeFile (
200
- path = self ._package .build_script , source_root = self ._path
203
+ path = self ._package .build_script ,
204
+ project_root = self ._path ,
205
+ source_root = self ._path ,
201
206
)
202
207
)
203
208
204
209
return to_add
205
210
206
- def get_metadata_content (self ): # type: () -> bytes
211
+ def get_metadata_content (self ): # type: () -> str
207
212
content = METADATA_BASE .format (
208
213
name = self ._meta .name ,
209
214
version = self ._meta .version ,
@@ -310,14 +315,17 @@ def temporary_directory(cls, *args, **kwargs):
310
315
class BuildIncludeFile :
311
316
def __init__ (
312
317
self ,
313
- path , # type: Path
314
- source_root = None , # type: Optional[Path]
318
+ path , # type: Union[Path, str]
319
+ project_root , # type: Union[Path, str]
320
+ source_root = None , # type: Optional[Union[Path, str]]
315
321
):
316
322
"""
323
+ :param project_root: the full path of the project's root
317
324
:param path: a full path to the file to be included
318
325
:param source_root: the root path to resolve to
319
326
"""
320
327
self .path = Path (path )
328
+ self .project_root = Path (project_root ).resolve ()
321
329
self .source_root = None if not source_root else Path (source_root ).resolve ()
322
330
if not self .path .is_absolute () and self .source_root :
323
331
self .path = self .source_root / self .path
@@ -346,6 +354,9 @@ def __hash__(self):
346
354
def __repr__ (self ): # type: () -> str
347
355
return str (self .path )
348
356
357
+ def relative_to_project_root (self ): # type(): -> Path
358
+ return self .path .relative_to (self .project_root )
359
+
349
360
def relative_to_source_root (self ): # type(): -> Path
350
361
if self .source_root is not None :
351
362
return self .path .relative_to (self .source_root )
0 commit comments