replit/upm

Poetry installing wrong package

rayzchen opened this issue ยท 8 comments

On PyPi, there are 2 packages called glm: glm and PyGLM. The former is now unmaintained and is (I believe) a json parser, whereas the other is an OpenGL mathematics library. I am developing a library which depends on the latter, but it is imported with import glm. However, upm guess will automatically resolve the dependencies by installing glm which then screws up PyGLM. Is there a way to turn off upm guess from running automatically when I run my repl?

I have the same problem with the Discord API wrapper.

The code for importing the package is import discord, so UPM wrongly guesses that the package is called discord and adds it with poetry add discord.
(According to https://pypi.org/project/discord/ that package should not be used, the correct package is discord.py).

Anyways, my problem is that I need to use the master branch of that package's repo, so I added the package manually to the toml file:

[tool.poetry.dependencies]
python = "^3.8"
"discord.py" = { git = "https://github.com/Rapptz/discord.py.git", branch = "master" }

But UPM adds discord again even if discord.py is already imported.
So, in the end, my toml file ends up looking like this...

[tool.poetry.dependencies]
python = "^3.8"
"discord.py" = { git = "https://github.com/Rapptz/discord.py.git", branch = "master" }
discord = "^1.7.3"

...with two different versions of the same package imported twice. Which is not great.


Turning UPM off or stopping it would be a good solution.

No need for this. Replit just failed to guess the package.

To get around this, add #upm package(package-name) at the end of your import statement

Ex.

import discord #upm package(discord.py)

For more information check the docs

this shouldn't be needed here, it should just use the right library.

lmmx commented

This is not a scalable way to install Python packages, this should be turned off if packaging metadata is available (and should create that packaging metadata on first run, therefore switching itself off). I.e. the correct thing to do is to defer to pyproject.toml dependencies, and not haphazardly guess from import statements. I keep checking back to find it not fixed, Iโ€™d love to try Replit but this is a show stopper for me.

Iโ€™d really like to see this prioritised and thought I should comment rather than just intermittently checking for progress.

This dovetails with some of the work we've been doing recently to improve the dependencies search pane, I'll see what can be done to improve this. Thanks for your patience, all, agreed that this should definitely not be up to the user to inform the tool to behave correctly.

lmmx commented

Er... I was using this issue to track whether this bug was resolved or not. It just got closed after a list of manual replacements has been added to in #191 ("guess package suggestions"). I don't think this is solving the problem

@lmmx Sorry for closing this issue without comment, there were a few different threads here that I was trying to address, it looks like I missed the main one.

Is there a way to turn off upm guess from running automatically when I run my repl?

Yes. Add the following line in the root section of your .replit file (up top, at the same level as run):

disableGuessImports = true

This will disable upm guessing entirely. This configuration option is not publicly documented, but there is discussion on Ask, which suggests the omission of that config option in our docs should be addressed.

More broadly, work on improving the guesser has continued in #15. Hopefully this resolves the issue, and again I do apologize for not communicating more around how/why this issue was closed.

lmmx commented

Oh thank you for documenting here! Sorry I thought it was just being swept under the rug lol, love to see it! Congrats on solving at long last ๐Ÿ˜ƒ