Skip to content

Comments

Force an update when changing a dependency to point to a local directory#1240

Closed
pdavies wants to merge 1 commit intopython-poetry:masterfrom
pdavies:update-to-local-dir
Closed

Force an update when changing a dependency to point to a local directory#1240
pdavies wants to merge 1 commit intopython-poetry:masterfrom
pdavies:update-to-local-dir

Conversation

@pdavies
Copy link

@pdavies pdavies commented Jul 19, 2019

This fixes the following bug:

  • Your pyproject.toml references a dependency
[tool.poetry.dependencies]
my-dependency = "^1.0.0"
  • You realise you need to make parallel changes to the dependency, so you change the reference to point to a local checkout of the dependency:
[tool.poetry.dependencies]
my-dependency = { path = "../my-dependency/" }
  • You run poetry update - but nothing happens. It insists that the dependency is already installed, and we continue to use the installed copy in site-packages. Worse, poetry show now believes that you are using the local directory, even though you're not (as pip show confirms).

@pdavies pdavies changed the title Force an update when switching package to dir Force an update when changing a dependency to point to a local directory Jul 19, 2019
Copy link
Contributor

@jacebrowning jacebrowning left a comment

Choose a reason for hiding this comment

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

Thanks! I've definitely run into this problem.

operations.append(Update(pkg, package))
elif (
package.source_type == "directory"
and pkg.source_type != "directory"
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we can generalize this for any type of change in the dependency source type (file -> directory or directory -> git for instance)

Copy link
Contributor

Choose a reason for hiding this comment

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

That seems like it ought to be the right answer, but it looks as though the detection of source type for installed packages is not currently reliable:

  • so far as I can see, it is only ever set to "git" (or nothing at all)
  • and actually, even packages that are installed as "directory" are reported as "git", if it happens that the code is in a git repository (which is fairly likely to be the case).
    • I suppose by the time you get to doing pip freeze, the two cases are indistinguishable

Presumably in an ideal world the source_type of installed packages would be made reliable - but it's not clear to me how to achieve that.

@brycedrennan brycedrennan added the kind/bug Something isn't working as expected label Aug 17, 2019
Copy link
Member

@sdispater sdispater left a comment

Choose a reason for hiding this comment

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

Could you add a test covering this issue?

@stale
Copy link

stale bot commented Dec 4, 2019

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Dec 4, 2019
@jacebrowning
Copy link
Contributor

@pdavies Are you still working on this? If not, I can try to work on a fix for this bug.

@stale stale bot removed the stale label Dec 4, 2019
@dimbleby
Copy link
Contributor

dimbleby commented Dec 4, 2019

This should be fixed in 1.0, by bf2d515 - here

@pdavies
Copy link
Author

pdavies commented Dec 9, 2019

Whoops, I haven't been on GItHub in ages. Happy to see that this has been fixed independently!

@pdavies pdavies closed this Dec 9, 2019
@github-actions
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

Development

Successfully merging this pull request may close these issues.

5 participants