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

Use canonical name when validating package from directory #1305

Merged
merged 1 commit into from
Sep 24, 2019
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
6 changes: 3 additions & 3 deletions poetry/puzzle/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,16 +403,16 @@ def get_package_from_directory(
finally:
os.chdir(current_dir)

if name and name != package_name:
package = Package(package_name, package_version)

if name and name != package.name:
# For now, the dependency's name must match the actual package's name
raise RuntimeError(
"The dependency name for {} does not match the actual package's name: {}".format(
name, package_name
)
)

package = Package(package_name, package_version)

package.description = package_summary

for req in reqs:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "1.2.3"
19 changes: 19 additions & 0 deletions tests/fixtures/git/github.com/demo/non-canonical-name/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
from setuptools import setup


kwargs = dict(
name="Demo",
license="MIT",
version="0.1.2",
description="Demo project.",
author="Sébastien Eustace",
author_email="sebastien@eustace.io",
url="https://github.com/demo/demo",
packages=["demo"],
install_requires=["pendulum>=1.4.4"],
extras_require={"foo": ["cleo"], "bar": ["tomlkit"]},
)


setup(**kwargs)
5 changes: 3 additions & 2 deletions tests/puzzle/test_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,16 @@ def test_search_for_vcs_read_setup_raises_error_if_no_version(provider, mocker):
provider.search_for_vcs(dependency)


def test_search_for_directory_setup_egg_info(provider):
@pytest.mark.parametrize("directory", ["demo", "non-canonical-name"])
def test_search_for_directory_setup_egg_info(provider, directory):
dependency = DirectoryDependency(
"demo",
Path(__file__).parent.parent
/ "fixtures"
/ "git"
/ "github.com"
/ "demo"
/ "demo",
/ directory,
)

package = provider.search_for_directory(dependency)[0]
Expand Down