Skip to content

Python files outside of Python package disrupt the determination of import paths #21

Description

@wshanks

I tried to use python-vendorize on a package that includes a bin/app_cli.py data file. Ideally, this file would be formatted as an entry point instead, but the way it is packaged now shows up as ../../bin/app_cli.py in RECORD. This puts a .. in the top_level_names set which throws off the way relative imports end up getting written. I think filtering out paths that start with ../ in the following section would be sufficient?

def _read_top_level_names_from_dist_info(dist_info_path):
path = os.path.join(dist_info_path, "RECORD")
if not os.path.exists(path):
return
py_extension = ".py"
with open(path, "rt", encoding="utf-8") as fileobj:
for line in csv.reader(fileobj):
if len(line) > 0:
record_path = line[0]
if record_path.endswith(py_extension):
top_part = pathlib.Path(record_path).parts[0]
if top_part.endswith(py_extension):
yield top_part[:-len(py_extension)]
else:
yield top_part

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions