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

How do you setup a forked repo for developement with poetry? #229

Closed
tadeoos opened this issue Jun 17, 2018 · 14 comments
Closed

How do you setup a forked repo for developement with poetry? #229

tadeoos opened this issue Jun 17, 2018 · 14 comments

Comments

@tadeoos
Copy link
Contributor

tadeoos commented Jun 17, 2018

Hey,
@cauebs already mentioned in #203 that a contributing guide would come handy, for now I am struggling with setting up a proper developement environment. Since there is a pyproject.toml it makes sense to develop poetry using poetry, but when I run poetry install from forked repo dir I get:

Traceback (most recent call last):
  File "/usr/local/bin/poetry", line 7, in <module>
    from poetry.console import main
  File "/<truncated>/open-source/poetry/poetry/console/__init__.py", line 1, in <module>
    from .application import Application
  File "/<truncated>/open-source/poetry/poetry/console/application.py", line 6, in <module>
    from cleo import Application as BaseApplication
ModuleNotFoundError: No module named 'cleo'

As you can see it gets confused with imports: the actual poetry installed on my machine (/usr/local/bin/poetry) starts using paths from the forked repo and hence can't find the modules which of course aren't there since we want to install them with this command...

Any ideas? Contributors - how does your setup looks like?

@cauebs
Copy link
Contributor

cauebs commented Jun 17, 2018

I don't know how the existing contributors handle this, but my workflow has become:

  • Clone my fork
  • poetry develop
  • alias pt .venv/bin/poetry and use pt to test

See if that works for you :)

@tadeoos
Copy link
Contributor Author

tadeoos commented Jun 18, 2018

Unfortunately poetry develop returns the same error. Did you have virtual environemnt already created before using any poetry commands?

@tadeoos
Copy link
Contributor Author

tadeoos commented Jun 18, 2018

I managed to hack my way out of this impass by running poetry install commands not from the forked repository root but from the docs directory... This isn't very nice solution though

@cauebs
Copy link
Contributor

cauebs commented Jun 18, 2018

Did you have virtual environemnt already created before using any poetry commands?

I believe I didn't. What error are you getting?

@tadeoos
Copy link
Contributor Author

tadeoos commented Jun 18, 2018

As I mentioned the error is the same - ModuleNotFoundError. It's all about python module import resolution...
@sdispater have you come across this problem?

@cauebs
Copy link
Contributor

cauebs commented Jun 20, 2018

Ok, let me get this right: you cloned it, ran poetry develop and then how did you run it? Or did it fail in the poetry develop stage already?
Could you show us the exact sequence of commands you're running and the output you're getting?
I don't mean to annoy you, it's just that what I suggested has really worked well for me.

@tadeoos
Copy link
Contributor Author

tadeoos commented Jun 20, 2018

It goes like this:

$ git clone ... 
$ cd poetry
$ pyenv activate poetry-fork-3.6  # activate virtualenv
$ poetry install  # not working
Traceback (most recent call last):
  File "/usr/local/bin/poetry", line 7, in <module>
    from poetry.console import main
  File "/<truncated>/open-source/poetry/poetry/console/__init__.py", line 1, in <module>
    from .application import Application
  File "/<truncated>/open-source/poetry/poetry/console/application.py", line 6, in <module>
    from cleo import Application as BaseApplication
ModuleNotFoundError: No module named 'cleo'

$ poetry develop  # also not working
Traceback (most recent call last):
  File "/usr/local/bin/poetry", line 7, in <module>
    from poetry.console import main
  File "/<truncated>/open-source/poetry/poetry/console/__init__.py", line 1, in <module>
    from .application import Application
  File "/<truncated>/open-source/poetry/poetry/console/application.py", line 6, in <module>
    from cleo import Application as BaseApplication
ModuleNotFoundError: No module named 'cleo'

$ cd docs  # this would work with any other directory as well

$ poetry install  # now it's working cause local `poetry` is no longer in the `$PATH`
Updating dependencies
Resolving dependencies... (34.6s)


Package operations: 49 installs, 0 updates, 0 removals
....

@cauebs
Copy link
Contributor

cauebs commented Jun 20, 2018

Hm... This probably has something to do with pyenv. But it shouldn't happen anyways.
@sdispater any ideas?

@tadeoos
Copy link
Contributor Author

tadeoos commented Jun 20, 2018

Without running any pyenv commands (i.e. running poetry commands without active venv) the error is the same, so I don't think it's connected.

btw I'm running on macOS High Sierra (10.13.5)

@cauebs
Copy link
Contributor

cauebs commented Jun 20, 2018

How did you install poetry?

@tadeoos
Copy link
Contributor Author

tadeoos commented Jun 20, 2018

curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python3

@JacobHayes
Copy link

This issue sounds like pypa/pipenv#2557. Essentially, when using global /usr/local/bin/poetry script from the repo folder, sys.path includes the repo's directory, which has a poetry package that overrides the global poetry package. The global and repo packages could of course have separate dependencies, causing issues.

You can see that in @tadeoos command output where /usr/local/bin/poetry ends up importing from "/<truncated>/open-source/poetry/poetry/console/__init__.py" instead of /usr/local/lib/python3.6/site-packages/poetry/console/__init__.py.

Like @tadeoos pointed out, it works from the docs folder because sys.path didn't include a folder containing a poetry package. I'm guessing @cauebs alias worked because it was using the venv local poetry entrypoint script instead of the global one, which may have a more precise import path?

A short term fix for this is to use python3 -m poetry which forces the global poetry package resolution. A better fix for this is to add a level of indirection with a src dir like using poetry/src/poetry instead of poetry/poetry.

@sdispater
Copy link
Member

If you install Poetry globally via the recommended installer, there should not be any issues.

If you want to test the behavior of your modification to the poetry codebase by executing the poetry executable you can just do poetry run poetry

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

4 participants