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

Cleanup vendored dependencies #25

Merged
merged 4 commits into from
Apr 23, 2020
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
184 changes: 92 additions & 92 deletions poetry.lock

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions poetry/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
import sys


try:
from pathlib import Path
except ImportError:
# noinspection PyUnresolvedReferences
from pathlib2 import Path

__version__ = "1.0.0a5"

__vendor_site__ = (Path(__file__).parent / "_vendor").as_posix()

if __vendor_site__ not in sys.path:
sys.path.insert(0, __vendor_site__)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I agree it would be better in theory, I wonder if this won't conflict with what we do in Poetry, and if the vendors of poetry-core will not take precedence.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, I want to do a bit more testing on this one actually. We could move it into poetry/__init__.py. Although, I am not a 100% on the ordering.

One thing I was wondering if we could provide a kind of proxy instead that can be smart enough to pick system one if the vendor site is not available. That would mean it would achieve what we want, while maintaining explicit imports.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For posterity, if the sys path option does need to be replaced later. This can be an alternative.

import sys
import importlib

from poetry.core.utils._compat import Path

__all__ = []
__vendored__ = {}

try:
    # poor developer's requirements parser
    with open(Path(__file__).parent / "vendor.txt") as f:
        for line in f.readlines():
            name, version = line.split("==")
        __vendored__[name] = version
        module_name = "poetry.core._vendor.{}".format(name)

        try:
            locals()[name] = importlib.import_module(module_name)
        except ImportError:
            locals()[name] = importlib.import_module(name)

        sys.modules[module_name] = locals()[name]
        __all__.append(name)
except (FileNotFoundError, ValueError, IndexError) as e:
    pass

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At that point, it might make sense to just switch to using pip's internal helper: pip._vendor:vendored.

Empty file removed poetry/core/_vendor/__init__.py
Empty file.
278 changes: 0 additions & 278 deletions poetry/core/_vendor/attr/__init__.pyi

This file was deleted.

9 changes: 0 additions & 9 deletions poetry/core/_vendor/attr/_version_info.pyi

This file was deleted.

12 changes: 0 additions & 12 deletions poetry/core/_vendor/attr/converters.pyi

This file was deleted.

15 changes: 0 additions & 15 deletions poetry/core/_vendor/attr/exceptions.pyi

This file was deleted.

5 changes: 0 additions & 5 deletions poetry/core/_vendor/attr/filters.pyi

This file was deleted.

Loading