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

When Building Wheels, Resolve Relative Path Dependencies Correctly #2114

Closed

Conversation

kevinastone
Copy link

@kevinastone kevinastone commented Mar 2, 2020

Building wheels unpacks the sdist which includes a copy of the
pyproject.toml. If dependencies are declared using relative paths
(such as mymodule = { path = '../mymodule' }), these relative paths
are not available from the temporary directory created to unpack and
build the wheel. This fix retains the original path to the project for
those relative dependencies.

Fixes #266.
Fixes #2046

Pull Request Check List

This is just a reminder about the most common mistakes. Please make sure that you tick all appropriate boxes. But please read our contribution guide at least once, it will save you unnecessary review cycles!

  • Added tests for changed code.
  • Updated documentation for changed code.

Note: If your Pull Request introduces a new feature or changes the current behavior, it should be based
on the develop branch. If it's a bug fix or only a documentation update, it should be based on the master branch.

If you have any questions to any of the points above, just submit and ask! This checklist is here to help you, not to deter you from contributing!

Building wheels unpacks the sdist which includes a copy of the
`pyproject.toml`.  If dependencies are delcared using relative paths
(such as `mymodule = { path = '../mymodule' }`), these relative paths
are not available from the temporary directory created to unpack and
build the wheel.  This fix retains the original path to the project for
those relative dependencies.

Fixes python-poetry#266.
@berhoel
Copy link

berhoel commented Apr 1, 2020

Is there any chance this will be approved? It seems the same problem affects checking these projects using "tox".

Copy link
Member

@abn abn left a comment

Choose a reason for hiding this comment

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

While the fix will make the builds succeed, it does changes the current behaviour since the source files used for the package now relies on the original root instead of the isolated source copy. The resolution of relative paths outside of project's source is probably not something we want to encourage as this can cause all sorts of breakages.

For cases where the source is within the same direcotry, another approach to this might be the inclusion of the path explicitly once python-poetry/poetry-core#6 is merged and available.

Another approach could be to use the original root only for path resoultion if the path encountered cannot be found.

@@ -30,7 +30,7 @@ class Factory:
"""

def create_poetry(
self, cwd=None, io=None
self, cwd=None, io=None, original_root=None,
Copy link
Member

Choose a reason for hiding this comment

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

Missing type hint.

@@ -57,7 +57,7 @@ def create_poetry(
name = local_config["name"]
version = local_config["version"]
package = ProjectPackage(name, version, version)
package.root_dir = poetry_file.parent
package.root_dir = original_root or poetry_file.parent
Copy link
Member

Choose a reason for hiding this comment

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

This will sort of defeat the purpose, since we really want the build to use the source in cwd. We might want to consider another approach to this one.

Choose a reason for hiding this comment

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

So after reading #2046 and especially the fact that these relative paths work fine if you build ONLY the wheel or ONLY the sdist... I have to ask, where is the need for this "isolated source copy" coming from? Building only the sdist doesn't seem to need it, building only the wheel doesn't seem to need it. So why is the CompleteBuilder trying to do something more than simply running both individual builders?

@kevinastone
Copy link
Author

It sounds like paths outside of the project source are not supported then. Are there use-cases where relative paths work correctly? I've been trying to build more monorepo repositories, but they all fail on this wheel unpacking step.

I'd recommend removing support for relative paths given all the footguns in the current implementation.

@kevinastone kevinastone closed this Apr 3, 2020
@abn
Copy link
Member

abn commented Apr 7, 2020

Well, there are use cases where projects are not built/distributed where it would work. Like an application project. So, I'd be reluctant to support the removal of support relative paths.

As for your particular use case, I recently raised #2270 as a means to enable cases like this. This should provide a cleaner approach to managing python mono-repos. It will require a bit of discussion before finalising how it would work exactly. So, feedback is welcome there.

Copy link

github-actions bot commented Mar 1, 2024

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected
Projects
None yet
5 participants