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

[Feature Request] Install dependencies without updating lockfile #602

Closed
2 tasks done
nickpresta opened this issue Nov 6, 2018 · 6 comments
Closed
2 tasks done

Comments

@nickpresta
Copy link

nickpresta commented Nov 6, 2018

  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have searched the documentation and believe that my request is not covered.

Feature Request

I am trying to install a dependency that will not result in a lockfile update, similar in behavior to yarn install --no-lockfile.

The reason I am looking for this feature is the ability to better test with tox when having multiple "environments". For example, I want to test on Python 3.6 with several versions of Django (1.9, 1.11, 2.1, for example). My tox.ini looks like this:

[tox]
skipsdist = True
envlist = {py36}-django{19,111,21}, {py37}-django{19,111,21}

[testenv]
install_command = poetry add -D {packages}
whitelist_externals = poetry
deps =
    django19: django=^1.9
    django111: django=^1.11
    django21: django=^2.1
commands =
    poetry install -v
    poetry run pytest -v tests/

When I get rid of the additional Django dependency, everything works fine and as expected, but I need to be able to install Django in the virtualenv for that specific test run without actually updating the poetry.lock file for local development or subsequent runs.

Thanks!

EDIT To add, I'm more than willing to help add this functionality, but I would need some help on where to start. I see AddCommand -- it seems like this could be solved by calling installer.update(False) when the --no-lockfile option is passed.

@jacebrowning
Copy link
Contributor

Does $ poetry run pip install foobar work?

@nickpresta
Copy link
Author

Yes. That works suitably. Thanks

@hugorodgerbrown
Copy link

@nickpresta do you have any more details on how you got this to work? I have exactly the same issue - I cannot get tests running against multiple Django versions, as poetry install always overwrites whatever tox has installed.

@laggardkernel
Copy link

Does $ poetry run pip install foobar work?

There's no difference with using pip install directly. The new added library will not be tracked in pyproject.toml.

@pshved
Copy link

pshved commented Jul 8, 2020

I'm experiencing the same issue. I'm using Travis CI and want to test my package against multiple versions of Tensorflow. tensorflow is a dependency in my pyproject.tml and Poetry always upgrades.

My workaround for this has been to remove this package from the config and add it back with a strict version. Thankfully, Poetry's CLI makes it simple. So I changed the install workflow to this (note that TF_VERSION is specified in the Travis config):

pip install poetry
poetry remove tensorflow
poetry add tensorflow==$TF_VERSION
poetry install

And it worked for me*. Note that poetry remove will also install other packages, so don't be surprised.

Here's my full travis.yml for reference

* due to #2271, my line actually reads, poetry add tensorflow==$TF_VERSION tensorflow-estimator==$TF_VERSION

Copy link

github-actions bot commented Mar 3, 2024

This issue 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 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants