dojeda / poetry2conda Goto Github PK
View Code? Open in Web Editor NEWConvert pyproject.toml to environment.yaml
License: MIT License
Convert pyproject.toml to environment.yaml
License: MIT License
When the poetry2conda
command fails, the target environment.yaml file is still created with empty contents. This is an undesirable behavior due to the usage of argparse.FileType
. Ideally, the file should be written only when the conversion has succeeded.
Hi, first of all many thanks for this project!
TL;DR: the generated pip
section should include the --index-url
and --extra-index-url
using info from tool.poetry.source
I'm on a limbo of mixed environments and repos, but I need to switch back from a poetry-based to a conda-based build env.
I already have some projects built with poetry and saved on a private devpi index;
the directive to use the private repo is in pyproject.toml
's tool.poetry.source
:
[[tool.poetry.source]]
name = "private"
url = "https://my.private.repo/my/stable/+simple/"
default= true
I added the tool.poetry2conda.dependencies
section to mark my packages with channel = "pip"
, and when I use poetry2conda pyproject.toml environment.yml
, the yaml file contains the pip packages but no --index-url
option.
Passing extra options in the environment.yml
's pip
section is possible from conda version 4.4.0 (see this pr).
It would be wonderful if the url
s specified in the tool.poetry.source
sections could be translated to a --index-url
entry if default = true
, or a --extra-index-url
otherwhise.
Hi,
Thanks for this tool that makes it really easy to keep my conda
friends happy!
I don't really understand why I have to add an extra section to my pyproject.toml
file, as in general I would personally want the environment to be named after the project, and to be warned in case I already have an environment with that name.
If I don't want it to have to same name, I could just change the environment name in the resulting environment.yml
file, right?
What am I missing?
Thanks in advance for the response!
It would be nice to generate a meta.yaml
file to generate conda package with conda build
(https://docs.conda.io/projects/conda-build/en/latest/user-guide/tutorials/build-pkgs.html)
Looks like dependencies with a dot aren't handled well, see below
[tool.poetry.dependencies]
python = "^3.6.1"
ruamel.yaml = "^0.16"
# dev dependencies ...
% poetry2conda --dev pyproject.toml environment.yml
Traceback (most recent call last):
File "/home/vvk/miniconda3/envs/birdfeeder/bin/poetry2conda", line 8, in <module>
sys.exit(main())
File "/home/vvk/miniconda3/envs/birdfeeder/lib/python3.8/site-packages/poetry2conda/convert.py", line 295, in main
converted_obj = convert(args.pyproject, include_dev=args.dev, extras=args.extras)
File "/home/vvk/miniconda3/envs/birdfeeder/lib/python3.8/site-packages/poetry2conda/convert.py", line 53, in convert
dependencies, pip_dependencies = collect_dependencies(
File "/home/vvk/miniconda3/envs/birdfeeder/lib/python3.8/site-packages/poetry2conda/convert.py", line 167, in collect_dependencies
raise ValueError(
ValueError: This converter only supports normal dependencies and git dependencies. No path, url, python restricted, environment markers or multiple constraints. In your case, check the "ruamel" dependency. Sorry.
(Pdb) poetry_dependencies.items()
dict_items([('python', '^3.6.1'), ('ruamel', {'yaml': '^0.16'}), ('poetry2conda', '^0.3'), ('pre-commit', '^2.2.0'), ('pytest', '^5.4'), ('pytest-cov', '^2.7'), ('pytest-mock', '^3.1.0')])
It would be great to automatically update conda
dependencies upon commit/push.
Poetry by default will install your project’s package everytime you run install
unless using the option --no-root
. When exporting an environment.yaml and installing it to a conda virtual environment the root project package is not installed.
Also it is not possible to "sneak" this in as an optional, editable dependency or even a git dependency since Poetry is not happy about the self-loop.
I have a project that has a dependency for a package from an alternate source (not pypi). Is there a work around to to specify a package like that for pip?
To anyone interested,
It has been a while since I updated this project and I currently don't have the bandwidth / time that this project requires.
I have seen that there are plenty of contributions and contributors so please let me know here if you are interested on becoming the maintainer of this project.
It seems obvious, but when a constraing that does not follow semantic version is used on a dependency, poetry2conda will fail. Perhaps the most simple example is:
black = "^19.10b0"
which is present in our own pyproject.toml.
I think that there are two possible solutions here:
The pragmatic one, which is to catch semantic version parsing errors, show a warning and use pin what was declared. In the case of black = "^19.10b0"
, conda will not understand this caret version, but we could warn the use to not use a caret (black = "19.10b0"
) and we could pin it to black==19.10b0
.
The more complex one: since poetry does understand this caret, we should probably re-use poetry caret-handling code. This is complex because we don't want to set poetry as a dependency (it would install poetry on the virtual environment, and this is discouraged on poetry's installation guide). However, I saw that poetry has recently been reorganized on a core package, which may respond to our need.
Following is the error
sumit@Sumits-MacBook-Air backend % poetry2conda pyproject.toml environment.yaml
Traceback (most recent call last):
File "/opt/homebrew/bin/poetry2conda", line 8, in <module>
sys.exit(main())
File "/opt/homebrew/lib/python3.9/site-packages/poetry2conda/convert.py", line 294, in main
converted_obj = convert(args.pyproject, include_dev=args.dev, extras=args.extras)
File "/opt/homebrew/lib/python3.9/site-packages/poetry2conda/convert.py", line 53, in convert
dependencies, pip_dependencies = collect_dependencies(
File "/opt/homebrew/lib/python3.9/site-packages/poetry2conda/convert.py", line 161, in collect_dependencies
tag = constraint["tag"]
KeyError: 'tag'
I'm suspecting this dependency in my pyproject.yaml
is the culprit.
pyppeteer = { git = "https://github.com/pyppeteer/pyppeteer.git", rev = "0fd15a7" }
I guess it would make sense to handle this bi-directional.
I am leaving this here to follow/remind the task of setting up a github workflow.
Hello!
I think this is a great tool, but I think there is one package that stops me from using it. I'm talking about rdkit.
You see, it's impossible to install it as a git dependency and the simplest way to install it is via Conda.
Can I use your tool in this case? And how 😊?)
First of all great work. This looks amazing.
Here is the issue I found:
Tried installing opencv-python-headless = "^3.4.8.29"
Received ValueError: Invalid simple block '^3.4.8.29'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.