Comments (28)
% poetry init
% poetry add `cat requirements.txt`
from poetry.
Release 0.10.0
adds a new init
command which covers this use case.
from poetry.
This works for me in bash:
$ poetry init
$ for item in $(cat requirements.txt); do poetry add "${item}"; done
from poetry.
There is no way currently to migrate a project to poetry
without building your pyproject.toml
file by hand.
And, to be honest, I don't think it's a feature I will add since there are multiple ways to declare your dependencies in Python at the moment (which I want to standardized with poetry
): in a requirements.txt
file, in setup.py
, in setup.cfg
.
So, hopefully, you do not have too many dependencies and it should be a quick process with the poetry add
command.
from poetry.
This. So much this. This is absolutely needed for a CLI like this.
from poetry.
Currently, no, it's not possible but that's something I'd like to add.
I will see if I can add it in the next feature release.
from poetry.
@sdispater I didn't mean to migrate a project. I meant to init poetry in an existing directory. Similar to what "git init" or "npm init" do.
from poetry.
from poetry.
How is this an issue if you can just do:
cd project
poetry init -n
- Realize your dependency management was awful so far
poetry add package
for each of your project dependenciespoetry add -D package
for each of your development dependencies- Be done and happy you took the time to provide some sensible structure to your project, and suddenly have this great overview after thinking through what your project really depends on.
The other stuff, such as README.rst
, project/
and tests/
, doesn't make sense for an existing project since those are already there, or your project needs a manual cleanup. poetry
can not ever know how to fix up your current project structure, because it did not adhere to the poetry expected standard, so it can be anything.
You can of course do poetry new project_name
and move your stuff in there, if you really want the base structure. But again, can't do this automatically, because poetry wouldn't be able to know what to do with existing conflicting files.
from poetry.
Hope that CLI could support reading package list from stdin to install, something like cat requirements.txt | poetry add -
from poetry.
FOR /F "usebackq delims==" %i IN (cat requirements.txt
) DO poetry add %i
on Windows
from poetry.
Windows PowerShell
Get-Content requirements.txt | ForEach-Object { poetry add $_.split('==')[0] }
from poetry.
from poetry.
FOR /F "usebackq delims==" %i IN (
cat requirements.txt
) DO poetry add %i
on Windows
This worked for me.
for /F "tokens=*" %i in (requirements.txt) do poetry add %i
from poetry.
@cglacet I didn't read the older messages in details, but yes, seems like potentially "dangerous" advice.
It depends what requirements.txt
contains exactly. Sometimes it is the raw output of pip freeze
sometimes it is a meaningful list. There is no rule. People can put whatever they want in it.
If it is a carefully curated list of direct top level install dependencies (i.e. import dependencies), then it is all good. Otherwise, it could lead to issues down the line.
For sure do not add the output of pip freeze
to your pyproject.toml
.
from poetry.
I happened to have an existing pyproject.toml file and it just throws an error that it already exists. meaning i manually need to add the poetry stuff. Small thing, but some feedback nonetheless
from poetry.
I was just about to ask the same question. Being turned down by pipenv multiple times now (it still has not earned even the 1.0 release stamp), id like to try poetry, but i dont want to create the toml file by hand. I wont bother calling poetry add a few times, but i dont wanna mess with the files syntax by hand. Looking forward to that feature!
from poetry.
Build dependencies go into the requires
field of thebuild-system
section. Typically for a poetry project the only build dependency is poetry itself or poetry-core for more recent projects:
[build-system]
requires = ['poetry-core>=1.0.0']
# ...
Install dependencies are the things that you want to be installed alongside your project, typically because your code imports them at run time. So the recommendation is to list only the libraries your code actually imports directly. Those belong in the [tool.poetry.dependencies]
section.
And you definitely should not add the dependencies of your dependencies to that section.
Development dependencies are typically the tools you use while working on your code, so things like pytest, pylint, black, etc. and they belong in the tool.poetry.dev-dependencies
section.
pip freeze would give you everything that is currently installed in the environment, so it contains your dependencies but also the dev dependencies and the dependencies of your direct dependencies and the dependencies of your dev dependencies. So pip freeze
is definitely not the thing that you want.
from poetry.
There are many projects that already have pyproject.toml
but lack a Poetry section, leading to an error like:
[tool.poetry] section not found in /Users/elazzarin/code/pytrends/pyproject.toml
It seems relatively straightforward to resolve by hand, so may be helpful to add to the poetry init
process if someone wants to migrate to Poetry smoothly.
from poetry.
@sdispater OK, thank you.
from poetry.
+1
from poetry.
Awesome .. gonna try this tomorrow!
from poetry.
FOR /F "usebackq delims==" %i IN (cat requirements.txt) DO poetry add %i
This doesn't add packages with version pinning.
ex: it adds Django instead of Django==1.11.20
I would suggest removing the "usebackq delims=="
from poetry.
Yeah init
command was added but what I would expect is installing all stocks components - .toml, foo_projectname/, test_foo_projectanme/, README.rst. Current init option prompts an empty .toml file, which doesn't seem necessary.
from poetry.
Are we really supposed to put all requirements in poetry (pip freeze
output)? Or are we only supposed to add build dependencies?
from poetry.
@sinoroc Thanks for the very quick and precise answer. I was questioning the answers proposing to directly add everything from requirements.txt
which I think in practice often contains the whole pip freeze
output.
from poetry.
from poetry.
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.
from poetry.
Related Issues (20)
- Make `[tool.poetry.scripts]` available from a pip installation HOT 3
- Requesting JSON Schema for `virtualenvs` in `poetry-core` HOT 8
- Cannot install torch on MacOS: poetry selects 2.3.0 which is not available on Apple Silicon HOT 2
- Multi-architecture wheels from the same source HOT 6
- 2.0.0 Release HOT 1
- Poetry failing to add Scipy to project HOT 2
- Pip does not work in poetry installation HOT 3
- Poetry doesn't use custom pyenv environment HOT 2
- Ability to specify a "target" for non-package mode
- Poetry version solving fails HOT 9
- Poetry Dependency Specification: platform manylinux2014_x86_64 not supported HOT 5
- `poetry install` fails with `IsADirectoryError [Errno 21] Is a directory: '/path/to/my-package' ` HOT 2
- All poetry commands fail with [Errno 2] No such file or directory: 'python' HOT 3
- Add flag to `poetry add` to allow the installation of the latest compatible version HOT 3
- `poetry shell` doesn't work with `mise` and `fish` shell, venv python is behind mise in path HOT 3
- changing local dependency to editable does not reinstall as editable dependency HOT 1
- the latest Poetry, Cannot recognize the new version of Python HOT 2
- extra depdency not included in lock file if platform being set HOT 2
- PermissionError during poetry lock when source is git, with virtualenvs.create=false HOT 3
- Add support for keyring as a subprocess subprocess (rather than keyring as an import) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from poetry.