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

Poetry export does not export local editable requirements correctly #145

Closed
3 tasks done
pawelrubin opened this issue Dec 9, 2020 · 11 comments · Fixed by #258
Closed
3 tasks done

Poetry export does not export local editable requirements correctly #145

pawelrubin opened this issue Dec 9, 2020 · 11 comments · Fixed by #258

Comments

@pawelrubin
Copy link

  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

Issue

Local editable packages are not exported correctly by poetry. Thus, pip install -r requirements.txt fails with error:

ERROR: Invalid requirement: 'example-pkg @ /Users/pawelvewd/projects/test_poetry/example_pkg' (from line 3 of requirements.txt)
Hint: It looks like a path. File 'example-pkg @ /Users/pawelvewd/projects/test_poetry/example_pkg' does not exist.

Expected result

-e ./example_pkg["foo"] ; python_version >= "3.9"

Current result

example-pkg @ /Users/pawelvewd/projects/test_poetry/example_pkg; python_version >= "3.9"
  • the path should be relative IMO
  • Poetry does not export extras
  • Poetry does not export develop = true (editable mode)
@gitpushdashf
Copy link

I ran into this as well. Thanks for posting the bug.

@ShayNehmad-RecoLabs
Copy link

I need this as well! Please let us know what's up with this issue.

@lee-hodg
Copy link

Yep, I was just about to create an issue for this. Thanks for posting.

@stygmate
Copy link

stygmate commented Feb 3, 2021

same here sticking with 1.0.0 version

@bow
Copy link

bow commented Mar 4, 2021

I just stumbled upon this as well (Poetry 1.1.4, Python 3.9.1). In my case, I made the generated requirements.txt work well with pip by changing the path into a direct reference (My use case was not strictly only local development)

Would it make sense to have this behavior for path dependencies?

  • If develop = true, create a -e <path> line (as noted in the issue description)
  • If develop = false, create a direct reference

@justinvanwinkle
Copy link

is poetry still being actively developed? Lack of support for relative paths is a huge barrier to adoption.

@fkaleo
Copy link

fkaleo commented Dec 1, 2021

I just stumbled upon this as well (Poetry 1.1.4, Python 3.9.1). In my case, I made the generated requirements.txt work well with pip by changing the path into a direct reference (My use case was not strictly only local development)

Would it make sense to have this behavior for path dependencies?

* If `develop` = true, create a `-e <path>` line (as noted in the issue description)

* If `develop` = false, create a direct reference

Thanks for the idea @bow ! Would you have an example of how exactly you did it, ie. what you wrote in your pyproject.toml?

@bow
Copy link

bow commented Dec 1, 2021

@fkaleo It was actually done outside of Poetry ~ simply using sed to add a file:// prefix to the generated path.

I should say first, I just tested this below again in Poetry 1.1.7 and I could see that it already creates direct references for the local dependency. So it seems like the trick below is not necessary anymore. My use case was also to generate wheels from requirements.txt (i.e. pip wheel) and not pip install.

That being said, with something like this in my pyproject.toml (local-pkg has its own pyproject.toml):

...
[tool.poetry.dependencies]
local-pkg = { path = "/path/to/local/pkg" }

it was simply this

poetry export -f requirements.txt -o /tmp/requirements.txt
  && sed -i 's/local-pkg @ /local-pkg @ file:\/\//1' /tmp/requirements.txt
  && pip wheel -r /tmp/requirements.txt --wheel-dir=/path/to/a/dir

@neersighted neersighted transferred this issue from python-poetry/poetry Oct 11, 2022
@asaf-kali
Copy link

asaf-kali commented Apr 30, 2023

Took a similar approach to @bow (as a makefile command, works on Mac):

freeze:
	poetry export -f requirements.txt --output requirements.txt
	sed -i '' '/my-package/d' requirements.txt
	echo "-e sub-dir/" >> requirements.txt

@Slanman3755
Copy link

+1 running into this as well

@fredsensibill
Copy link
Contributor

I opened a PR following @bow suggestion. Hopefully I can get a maintainer to look at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.