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

Packages at relative paths not found #1518

Closed
jdrake opened this issue Nov 15, 2021 · 17 comments
Closed

Packages at relative paths not found #1518

jdrake opened this issue Nov 15, 2021 · 17 comments
Assignees

Comments

@jdrake
Copy link

jdrake commented Nov 15, 2021

I have a monorepo and am using Poetry to manage all the individual packages. (I'm not using Pants for this for other reasons.)

Packages depend on a mix of regular external libraries in pypi and local packages. For example:

[tool.poetry]
name = "ns_lexio_db"
version = "0.1.0"
description = ""
authors = []
license = "Proprietary"

[tool.poetry.dependencies]
python = "^3.6.5"
alembic = "0.9.7"
Click = "7.0"
ns_database_seeding = { path = "../lib/database_seeding", develop = true }
ns_python_core = { path = "../lib/python_core", develop = true }

[tool.poetry.dev-dependencies]

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.poetry.scripts]
lexio-db = "ns_lexio_db.cli:cli"

From here, the ns_database_seeding package depends on other internal packages and use path links too.

Next I export the requirements:

poetry export -f requirements.txt --without-hashes -o requirements.txt

which gives something like:

...
newrelic==5.24.0.153; python_full_version >= "3.6.5" and python_full_version < "4.0.0"
...
ns-feature-flag-client @ file:///Users/jdrake/talos2/lib/feature_flag_client; python_full_version >= "3.6.5" and python_full_version < "4.0.0"
...

To build the pex I run:

pex --requirement=requirements.txt --script=lexio-db --sources-directory=. --output-file=lexio-db.pex  

But that fails with:

    ERROR: Command errored out with exit status 1:
     command: /Users/jdrake/.pex/venvs/s/2f33bdcc/venv/bin/python3.6 /Users/jdrake/.pex/venvs/s/2f33bdcc/venv/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /private/var/folders/4l/fzzb6qx11z34_6xfrs9w0pp80000gp/T/tmpfuc9lsur
         cwd: /private/var/folders/4l/fzzb6qx11z34_6xfrs9w0pp80000gp/T/pip-download-a3hcfey8/ns-admin
    Complete output (16 lines):
    Traceback (most recent call last):
      File "/Users/jdrake/.pex/venvs/s/2f33bdcc/venv/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 280, in <module>
        main()
      File "/Users/jdrake/.pex/venvs/s/2f33bdcc/venv/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 263, in main
        json_out['return_val'] = hook(**hook_input['kwargs'])
      File "/Users/jdrake/.pex/venvs/s/2f33bdcc/venv/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 133, in prepare_metadata_for_build_wheel
        return hook(metadata_directory, config_settings)
      File "/private/var/folders/4l/fzzb6qx11z34_6xfrs9w0pp80000gp/T/pip-build-env-wq5hwh1m/overlay/lib/python3.6/site-packages/poetry/core/masonry/api.py", line 43, in prepare_metadata_for_build_wheel
        poetry = Factory().create_poetry(Path(".").resolve(), with_dev=False)
      File "/private/var/folders/4l/fzzb6qx11z34_6xfrs9w0pp80000gp/T/pip-build-env-wq5hwh1m/overlay/lib/python3.6/site-packages/poetry/core/factory.py", line 93, in create_poetry
        self.create_dependency(name, constraint, root_dir=package.root_dir)
      File "/private/var/folders/4l/fzzb6qx11z34_6xfrs9w0pp80000gp/T/pip-build-env-wq5hwh1m/overlay/lib/python3.6/site-packages/poetry/core/factory.py", line 251, in create_dependency
        extras=constraint.get("extras", []),
      File "/private/var/folders/4l/fzzb6qx11z34_6xfrs9w0pp80000gp/T/pip-build-env-wq5hwh1m/overlay/lib/python3.6/site-packages/poetry/core/packages/directory_dependency.py", line 41, in __init__
        raise ValueError("Directory {} does not exist".format(self._path))
    ValueError: Directory ../feature_flag_client does not exist
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Users/jdrake/.pex/venvs/s/2f33bdcc/venv/bin/python3.6 /Users/jdrake/.pex/venvs/s/2f33bdcc/venv/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /private/var/folders/4l/fzzb6qx11z34_6xfrs9w0pp80000gp/T/tmpfuc9lsur Check the logs for full command output.
pid 80108 -> /Users/jdrake/.pex/venvs/8fa46d08dd05e0160395f355cccb51e48f384a1b/30f8c74d3988c60c0f5aeae7604ec76b6ce2368a/pex --disable-pip-version-check --no-python-version-warning --exists-action a --use-deprecated legacy-resolver --isolated -q --cache-dir /Users/jdrake/.pex download --dest /private/var/folders/4l/fzzb6qx11z34_6xfrs9w0pp80000gp/T/tmpanbshq0u/Users.jdrake..pyenv.versions.3.6.8.bin.python3.6 --requirement requirements.txt --index-url https://pypi.org/simple --retries 5 --timeout 15 exited with 1 and STDERR:
None

It seems like pex (or pip under the hood) is picking up on the pyproject.toml files for internal dependencies (via pip hook) but misinterpreting the relative paths. They are in each pyproject.toml file and poetry.lock file relative to that project, but it seems like pex or pip is interpreting them as relative to some virtualenv or current directory or something.

I am using the newest versions of pip, poetry, and pex.

@jsirois
Copy link
Member

jsirois commented Nov 15, 2021

Before digging into getting this style of PEX build working, can you try the much simpler PEP-517 strategy (I.E.: just let Poetry build it) below and report back?:

pex --script=lexio-db . --output-file=lexio-db.pex

This should work for any Poetry or other PEP-517 built project. Pex in fact dogfoods this for itself (it uses Flit instead of Poetry):
https://github.com/pantsbuild/pex/blob/0f6b37ebdd8a93a39a6d571a73213c101c9131c7/scripts/package.py#L25-L56

@jsirois jsirois self-assigned this Nov 15, 2021
@jdrake
Copy link
Author

jdrake commented Nov 15, 2021

ubuntu@ip-10-65-104-139:~/talos/db$ pex --script=lexio-db . --output-file=lexio-db.pex
    ERROR: Command errored out with exit status 1:
     command: /home/ubuntu/.pex/venvs/s/3b91b06e/venv/bin/python /home/ubuntu/.pex/venvs/s/3b91b06e/venv/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmp_w9llznd
         cwd: /tmp/pip-req-build-cbf0u8o8
    Complete output (16 lines):
    Traceback (most recent call last):
      File "/home/ubuntu/.pex/venvs/s/3b91b06e/venv/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 286, in <module>
        main()
      File "/home/ubuntu/.pex/venvs/s/3b91b06e/venv/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 269, in main
        json_out["return_val"] = hook(**hook_input["kwargs"])
      File "/home/ubuntu/.pex/venvs/s/3b91b06e/venv/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 135, in prepare_metadata_for_build_wheel
        return hook(metadata_directory, config_settings)
      File "/tmp/pip-build-env-ho8yf7xl/overlay/lib/python3.6/site-packages/poetry/core/masonry/api.py", line 43, in prepare_metadata_for_build_wheel
        poetry = Factory().create_poetry(Path(".").resolve(), with_dev=False)
      File "/tmp/pip-build-env-ho8yf7xl/overlay/lib/python3.6/site-packages/poetry/core/factory.py", line 93, in create_poetry
        self.create_dependency(name, constraint, root_dir=package.root_dir)
      File "/tmp/pip-build-env-ho8yf7xl/overlay/lib/python3.6/site-packages/poetry/core/factory.py", line 251, in create_dependency
        extras=constraint.get("extras", []),
      File "/tmp/pip-build-env-ho8yf7xl/overlay/lib/python3.6/site-packages/poetry/core/packages/directory_dependency.py", line 41, in __init__
        raise ValueError("Directory {} does not exist".format(self._path))
    ValueError: Directory ../lib/database_seeding does not exist
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/ubuntu/.pex/venvs/s/3b91b06e/venv/bin/python /home/ubuntu/.pex/venvs/s/3b91b06e/venv/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmp_w9llznd Check the logs for full command output.
pid 10550 -> /home/ubuntu/.pex/venvs/c98b77f6c56c6f321bcf4fce331c971b0bd9b444/5690c24fbd8140971250cdec814b5f89a8262f94/pex --disable-pip-version-check --no-python-version-warning --exists-action a --use-deprecated legacy-resolver --isolated -q --cache-dir /home/ubuntu/.pex download --dest /tmp/tmpl8eywg5y/home.ubuntu..pyenv.versions.3.6.12.bin.python3.6 . --index-url https://pypi.org/simple --retries 5 --timeout 15 exited with 1 and STDERR:
None

@jsirois
Copy link
Member

jsirois commented Nov 15, 2021

Urg. This should mean Pip also fails? Can you try pip wheel . and report back?

@jdrake
Copy link
Author

jdrake commented Nov 15, 2021

Yup, unfortunately:

ubuntu@ip-10-65-104-139:~/talos/db$ pip wheel .
Processing /home/ubuntu/talos/db
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
ERROR: Exception:
Traceback (most recent call last):
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3021, in _dep_map
    return self.__dep_map
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2815, in __getattr__
    raise AttributeError(attr)
AttributeError: _DistInfoDistribution__dep_map

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3101, in __init__
    super(Requirement, self).__init__(requirement_string)
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_vendor/packaging/requirements.py", line 117, in __init__
    raise InvalidRequirement(f"Invalid URL: {req.url}")
pip._vendor.packaging.requirements.InvalidRequirement: Invalid URL: ../lib/database_seeding

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_internal/cli/base_command.py", line 164, in exc_logging_wrapper
    status = run_func(*args)
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_internal/cli/req_command.py", line 205, in wrapper
    return func(self, options, args)
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_internal/commands/wheel.py", line 144, in run
    requirement_set = resolver.resolve(reqs, check_supported_wheels=True)
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 93, in resolve
    collected.requirements, max_rounds=try_to_avoid_resolution_too_deep
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_vendor/resolvelib/resolvers.py", line 482, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_vendor/resolvelib/resolvers.py", line 374, in resolve
    failure_causes = self._attempt_to_pin_criterion(name)
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_vendor/resolvelib/resolvers.py", line 214, in _attempt_to_pin_criterion
    criteria = self._get_updated_criteria(candidate)
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_vendor/resolvelib/resolvers.py", line 204, in _get_updated_criteria
    for requirement in self._p.get_dependencies(candidate=candidate):
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_internal/resolution/resolvelib/provider.py", line 204, in get_dependencies
    return [r for r in candidate.iter_dependencies(with_requires) if r is not None]
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_internal/resolution/resolvelib/provider.py", line 204, in <listcomp>
    return [r for r in candidate.iter_dependencies(with_requires) if r is not None]
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 236, in iter_dependencies
    requires = self.dist.iter_dependencies() if with_requires else ()
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_internal/metadata/pkg_resources.py", line 91, in iter_dependencies
    return self._dist.requires(extras)
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2736, in requires
    dm = self._dep_map
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3023, in _dep_map
    self.__dep_map = self._compute_dependencies()
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3033, in _compute_dependencies
    reqs.extend(parse_requirements(req))
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3094, in parse_requirements
    yield Requirement(line)
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3103, in __init__
    raise RequirementParseError(str(e))
pip._vendor.pkg_resources.RequirementParseError: Invalid URL: ../lib/database_seeding

@jsirois
Copy link
Member

jsirois commented Nov 15, 2021

@jdrake
Copy link
Author

jdrake commented Nov 15, 2021

Ahh ok, so Poetry supports relative paths but not pip

@jsirois
Copy link
Member

jsirois commented Nov 15, 2021

Well, it does apparently but behind a flag. Can you try?: pip wheel --use-feature=in-tree-build .

@jsirois
Copy link
Member

jsirois commented Nov 15, 2021

If that works, I can probably expose an equivalent flag for that in Pex.

@jdrake
Copy link
Author

jdrake commented Nov 15, 2021

Oh interesting, good to know.

Same error:

ubuntu@ip-10-65-104-139:~/talos/db$ pip install -U pip
Requirement already satisfied: pip in /home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages (21.3.1)
ubuntu@ip-10-65-104-139:~/talos/db$ pip wheel --use-feature=in-tree-build .
DEPRECATION: In-tree builds are now the default. pip 22.1 will enforce this behaviour change. A possible replacement is to remove the --use-feature=in-tree-build flag.
Processing /home/ubuntu/talos/db
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
ERROR: Exception:
Traceback (most recent call last):
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3021, in _dep_map
    return self.__dep_map
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2815, in __getattr__
    raise AttributeError(attr)
AttributeError: _DistInfoDistribution__dep_map

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3101, in __init__
    super(Requirement, self).__init__(requirement_string)
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_vendor/packaging/requirements.py", line 117, in __init__
    raise InvalidRequirement(f"Invalid URL: {req.url}")
pip._vendor.packaging.requirements.InvalidRequirement: Invalid URL: ../lib/database_seeding

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_internal/cli/base_command.py", line 164, in exc_logging_wrapper
    status = run_func(*args)
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_internal/cli/req_command.py", line 205, in wrapper
    return func(self, options, args)
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_internal/commands/wheel.py", line 144, in run
    requirement_set = resolver.resolve(reqs, check_supported_wheels=True)
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 93, in resolve
    collected.requirements, max_rounds=try_to_avoid_resolution_too_deep
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_vendor/resolvelib/resolvers.py", line 482, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_vendor/resolvelib/resolvers.py", line 374, in resolve
    failure_causes = self._attempt_to_pin_criterion(name)
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_vendor/resolvelib/resolvers.py", line 214, in _attempt_to_pin_criterion
    criteria = self._get_updated_criteria(candidate)
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_vendor/resolvelib/resolvers.py", line 204, in _get_updated_criteria
    for requirement in self._p.get_dependencies(candidate=candidate):
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_internal/resolution/resolvelib/provider.py", line 204, in get_dependencies
    return [r for r in candidate.iter_dependencies(with_requires) if r is not None]
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_internal/resolution/resolvelib/provider.py", line 204, in <listcomp>
    return [r for r in candidate.iter_dependencies(with_requires) if r is not None]
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 236, in iter_dependencies
    requires = self.dist.iter_dependencies() if with_requires else ()
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_internal/metadata/pkg_resources.py", line 91, in iter_dependencies
    return self._dist.requires(extras)
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2736, in requires
    dm = self._dep_map
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3023, in _dep_map
    self.__dep_map = self._compute_dependencies()
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3033, in _compute_dependencies
    reqs.extend(parse_requirements(req))
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3094, in parse_requirements
    yield Requirement(line)
  File "/home/ubuntu/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3103, in __init__
    raise RequirementParseError(str(e))
pip._vendor.pkg_resources.RequirementParseError: Invalid URL: ../lib/database_seeding

@jsirois
Copy link
Member

jsirois commented Nov 15, 2021

Hrm. OK. I don't think there is much I'm going to be able to do here. Is this workflow acceptable / does it even work for you?:

rm -rf dist/
poetry build -f wheel
pex dist/*.whl --script=lexio-db --output-file=lexio-db.pex

I'm relying here on Poetry hopefully building all local wheels it needs for the current project and plopping them in dist. I tested against poetry itself, but that just has the 1 project. I don't have my hands on a multi-project structure to test this quickly for myself.

@jsirois
Copy link
Member

jsirois commented Nov 15, 2021

Ok, cloned this: https://github.com/ya-mori/python-monorepo
Poetry does not build all local deps :/. There is no nice way I can tell to get those local deps either. Poetry is too pretty in the relevant commands to sanely parse this:

$ poetry show
The virtual environment found in /home/jsirois/.pex/venvs/e758bce3929d6c303b73fc1bc283372ab12d38af/2d1d404c3de23b1810386195be7410700b1feb14 seems to be broken.
Recreating virtualenv project-two-kJAods8U-py3.9 in /home/jsirois/.cache/pypoetry/virtualenvs/project-two-kJAods8U-py3.9
absl-py                0.11.0                   Abseil Python Common Libraries, see https://github.com/abseil/abseil-py.
astunparse             1.6.3                    An AST unparser for Python
attrs                  20.3.0                   Classes Without Boilerplate
cachetools             4.2.1                    Extensible memoizing collections and decorators
certifi                2020.12.5                Python package for providing Mozilla's CA Bundle.
chardet                4.0.0                    Universal encoding detector for Python 2 and 3
flatbuffers            1.12                     The FlatBuffers serialization format for Python
gast                   0.3.3                    Python AST that abstracts the underlying Python version
google-auth            1.27.1                   Google Authentication Library
google-auth-oauthlib   0.4.3                    Google Authentication Library
google-pasta           0.2.0                    pasta is an AST-based Python refactoring library
grpcio                 1.32.0                   HTTP/2-based RPC framework
h5py                   2.10.0                   Read and write HDF5 files from Python
idna                   2.10                     Internationalized Domain Names in Applications (IDNA)
keras-preprocessing    1.1.2                    Easy data preprocessing and data augmentation for deep learning models
lib-one                0.1.0 ../../libs/lib-one 
lib-two                0.1.0 ../../libs/lib-two 
markdown               3.3.4                    Python implementation of Markdown.
more-itertools         8.7.0                    More routines for operating on iterables, beyond itertools
numpy                  1.19.5                   NumPy is the fundamental package for array computing with Python.
oauthlib               3.1.0                    A generic, spec-compliant, thorough implementation of the OAuth request-signing logic
opt-einsum             3.3.0                    Optimizing numpys einsum function
packaging              20.9                     Core utilities for Python packages
pluggy                 0.13.1                   plugin and hook calling mechanisms for python
protobuf               3.15.5                   Protocol Buffers
py                     1.10.0                   library with cross-python path, ini-parsing, io, code, log facilities
pyasn1                 0.4.8                    ASN.1 types and codecs
pyasn1-modules         0.2.8                    A collection of ASN.1-based protocols modules.
pyparsing              2.4.7                    Python parsing module
pytest                 5.4.3                    pytest: simple powerful testing with Python
requests               2.25.1                   Python HTTP for Humans.
requests-oauthlib      1.3.0                    OAuthlib authentication support for Requests.
rsa                    4.7.2                    Pure-Python RSA implementation
six                    1.15.0                   Python 2 and 3 compatibility utilities
tensorboard            2.4.1                    TensorBoard lets you watch Tensors Flow
tensorboard-plugin-wit 1.8.0                    What-If Tool TensorBoard plugin.
tensorflow             2.4.1                    TensorFlow is an open source machine learning framework for everyone.
tensorflow-estimator   2.4.0                    TensorFlow Estimator.
termcolor              1.1.0                    ANSII Color formatting for output in terminal.
typing-extensions      3.7.4.3                  Backported and Experimental Type Hints for Python 3.5+
urllib3                1.26.3                   HTTP library with thread-safe connection pooling, file post, and more.
wcwidth                0.2.5                    Measures the displayed width of unicode strings in a terminal
werkzeug               1.0.1                    The comprehensive WSGI web application library.
wrapt                  1.12.1                   Module for decorators, wrappers and monkey patching.

And:

$ poetry show --tree
The virtual environment found in /home/jsirois/.pex/venvs/e758bce3929d6c303b73fc1bc283372ab12d38af/2d1d404c3de23b1810386195be7410700b1feb14 seems to be broken.
Recreating virtualenv project-two-kJAods8U-py3.9 in /home/jsirois/.cache/pypoetry/virtualenvs/project-two-kJAods8U-py3.9
lib-one 0.1.0
lib-two 0.1.0
└── tensorflow ^2.4.1
    ├── absl-py >=0.10,<1.0 
    │   └── six * 
    ├── astunparse >=1.6.3,<1.7.0 
    │   └── six >=1.6.1,<2.0 (circular dependency aborted here)
    ├── flatbuffers >=1.12.0,<1.13.0 
    ├── gast 0.3.3 
    ├── google-pasta >=0.2,<1.0 
    │   └── six * (circular dependency aborted here)
    ├── grpcio >=1.32.0,<1.33.0 
    │   └── six >=1.5.2 (circular dependency aborted here)
    ├── h5py >=2.10.0,<2.11.0 
    │   ├── numpy >=1.7 
    │   └── six * (circular dependency aborted here)
    ├── keras-preprocessing >=1.1.2,<1.2.0 
    │   ├── numpy >=1.9.1 (circular dependency aborted here)
    │   └── six >=1.9.0 (circular dependency aborted here)
    ├── numpy >=1.19.2,<1.20.0 (circular dependency aborted here)
    ├── opt-einsum >=3.3.0,<3.4.0 
    │   └── numpy >=1.7 (circular dependency aborted here)
    ├── protobuf >=3.9.2 
    │   └── six >=1.9 (circular dependency aborted here)
    ├── six >=1.15.0,<1.16.0 (circular dependency aborted here)
    ├── tensorboard >=2.4,<3.0 
    │   ├── absl-py >=0.4 (circular dependency aborted here)
    │   ├── google-auth >=1.6.3,<2 
    │   │   ├── cachetools >=2.0.0,<5.0 
    │   │   ├── pyasn1-modules >=0.2.1 
    │   │   │   └── pyasn1 >=0.4.6,<0.5.0 
    │   │   ├── rsa >=3.1.4,<5 
    │   │   │   └── pyasn1 >=0.1.3 (circular dependency aborted here)
    │   │   └── six >=1.9.0 (circular dependency aborted here)
    │   ├── google-auth-oauthlib >=0.4.1,<0.5 
    │   │   ├── google-auth >=1.0.0 (circular dependency aborted here)
    │   │   └── requests-oauthlib >=0.7.0 
    │   │       ├── oauthlib >=3.0.0 
    │   │       └── requests >=2.0.0 
    │   │           ├── certifi >=2017.4.17 
    │   │           ├── chardet >=3.0.2,<5 
    │   │           ├── idna >=2.5,<3 
    │   │           └── urllib3 >=1.21.1,<1.27 
    │   ├── grpcio >=1.24.3 (circular dependency aborted here)
    │   ├── markdown >=2.6.8 
    │   │   └── importlib-metadata * 
    │   │       ├── typing-extensions >=3.6.4 
    │   │       └── zipp >=0.5 
    │   ├── numpy >=1.12.0 (circular dependency aborted here)
    │   ├── protobuf >=3.6.0 (circular dependency aborted here)
    │   ├── requests >=2.21.0,<3 (circular dependency aborted here)
    │   ├── six >=1.10.0 (circular dependency aborted here)
    │   ├── tensorboard-plugin-wit >=1.6.0 
    │   └── werkzeug >=0.11.15 
    ├── tensorflow-estimator >=2.4.0,<2.5.0 
    ├── termcolor >=1.1.0,<1.2.0 
    ├── typing-extensions >=3.7.4,<3.8.0 (circular dependency aborted here)
    └── wrapt >=1.12.1,<1.13.0 
pytest 5.4.3 pytest: simple powerful testing with Python
├── atomicwrites >=1.0
├── attrs >=17.4.0
├── colorama *
├── importlib-metadata >=0.12
│   ├── typing-extensions >=3.6.4 
│   └── zipp >=0.5 
├── more-itertools >=4.0.0
├── packaging *
│   └── pyparsing >=2.0.2 
├── pluggy >=0.12,<1.0
│   └── importlib-metadata >=0.12 
│       ├── typing-extensions >=3.6.4 
│       └── zipp >=0.5 
├── py >=1.5.0
└── wcwidth *

@jsirois
Copy link
Member

jsirois commented Nov 15, 2021

Afaict you'll either need to build all needed local wheels yourself and then combine those with the exported poetry lock - lots of fiddly there. Otherwise it seems like #1361 would work if implemented since it appears to be the case that poetry install does install local projects as dist-info distributions.

@jdrake
Copy link
Author

jdrake commented Nov 15, 2021

This gives the same error:

rm -rf dist/
poetry build -f wheel
pex dist/*.whl --script=lexio-db --output-file=lexio-db.pex
# pip._vendor.pkg_resources.RequirementParseError: Invalid URL: ../lib/database_seeding

I'll see if building all the local wheels could work. If it doesn't I'll probably end up refactoring the system around it to use a regular installation method.

Thanks so much for digging in @jsirois!

@jsirois
Copy link
Member

jsirois commented Nov 15, 2021

Aha, here is the issue:

$ unzip -qc dist/project_two-0.1.0-py3-none-any.whl project_two-0.1.0.dist-info/METADATA | grep Requires-Dist
Requires-Dist: lib-one @ ../../libs/lib-one
Requires-Dist: lib-two @ ../../libs/lib-two

Poetry is building invalid wheels via:

  1. https://www.python.org/dev/peps/pep-0345/#version-specifiers ->
  2. https://www.python.org/dev/peps/pep-0440/#file-urls

@jsirois
Copy link
Member

jsirois commented Nov 15, 2021

I'll see if this ug has been filed. I do hope this is only the case for the build command or else it means its impossible to publish a valid set of dists to PyPI from a multi-project Poetry repo!

@jsirois
Copy link
Member

jsirois commented Nov 15, 2021

@jsirois
Copy link
Member

jsirois commented Nov 15, 2021

Ok, @jdrake the only way to get this working sanely in Pex will be if #1361 gets implemented; otherwise, Poetry is breaking too many PEPs to work with without writing a bunch of special case code to deal with Poetry projects. I'm going to close as won't fix in favor of #1361. Please speak up though if you have ideas on other ways for Pex to handle this.

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

No branches or pull requests

2 participants