Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't write duplicate egg-info dir #115

Merged
merged 2 commits into from
Nov 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/115.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Don't write redundant ``egg-info`` under project root when ``src`` is used as package base.
4 changes: 2 additions & 2 deletions src/requirementslib/models/setup_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def iter_egginfos(path, pkg_name=None):
if not entry.name.endswith("egg-info"):
for dir_entry in iter_egginfos(entry.path, pkg_name=pkg_name):
yield dir_entry
elif pkg_name is None or entry.name.startswith(pkg_name):
elif pkg_name is None or entry.name.startswith(pkg_name.replace("-", "_")):
yield entry


Expand Down Expand Up @@ -224,7 +224,7 @@ def run_setup(self):
target_cwd = self.setup_py.parent.as_posix()
with cd(target_cwd), _suppress_distutils_logs():
script_name = self.setup_py.as_posix()
args = ["egg_info", "--egg-base", self.base_dir]
args = ["egg_info"]
g = {"__file__": script_name, "__name__": "__main__"}
local_dict = {}
if sys.version_info < (3, 5):
Expand Down
10 changes: 10 additions & 0 deletions tests/unit/test_setup_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import pytest
import sys
import os

from requirementslib.models.requirements import Requirement

Expand Down Expand Up @@ -32,3 +33,12 @@ def test_remote_req(url_line, name, requires):
if "typing" in requires and not sys.version_info < (3, 5):
requires.remove("typing")
assert sorted(list(setup_dict.get("requires").keys())) == sorted(requires)


def test_no_duplicate_egg_info():
"""When the package has 'src' directory, do not write egg-info in base dir."""
base_dir = os.path.abspath(os.getcwd())
r = Requirement.from_line("-e {}".format(base_dir))
egg_info_name = "{}.egg-info".format(r.name.replace("-", "_"))
assert os.path.isdir(os.path.join(base_dir, "src", egg_info_name))
assert not os.path.isdir(os.path.join(base_dir, egg_info_name))