fastai / nbdev

Create delightful software with Jupyter Notebooks
https://nbdev.fast.ai/
Apache License 2.0
4.91k stars 487 forks source link

Adding complicated dependencies #360

Closed jcpayne closed 3 years ago

jcpayne commented 3 years ago

Is there documentation somewhere of how to add complicated dependencies? My nbdev builds are failing when nbdev_test_nbs hits imports that aren't in plain Python 3. There is one line in the nbdev Tutorial that suggests adding packages to the requirements = line in settings.ini, but fastai itself has 4 different kinds of requirements listed in settings.ini:

requirements = fastcore>=1.3.8...
pip_requirements = torch>=1.7.0,<1.8...
conda_requirements = pytorch>=1.7.0,<1.8
dev_requirements = nbdev>=1.0.10...

Also, I'm working with Detectron2 which requires a couple of complex package installation commands that I don't know how to add to a simple requirements template:

pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu101/torch1.5/index.html
pip install -U 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI' --ignore-installed certifi

I'd appreciate any advice. If there is no way to add the dependencies, I guess I could prevent all tests from running, but I would like to do the CI tests if possible since it's good programming practice to include them.

Thanks

John

muellerzr commented 3 years ago

You should do git+git:// on your link and add it to whatever requirements you ay have like so:

requirements = fastcore>=1.3.8.... git+git://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI

@hamelsmu you may know more on the pip installing custom wheels?

jcpayne commented 3 years ago

Thanks @muellerzr. I'll try that. Is there any reason to prefer requirements=... over the other variants (pip_requirements etc.) that I listed?

muellerzr commented 3 years ago

No, it was just an example

hamelsmu commented 3 years ago

@jcpayne shall I close this issue?

jcpayne commented 3 years ago

Not yet, please. Several questions are still unanswered; 1) How to write the detectron2 import line; 2) Zach's suggestion doesn't include the flags -- can I include them? (I haven't tried yet) 2) What is the difference, if any, between the 4 kinds of requirement statements. Why are all 4 present in fastai?

hamelsmu commented 3 years ago

@jph00 any recommendations on the best way to handle this?

jph00 commented 3 years ago

Summary:

For the format of each, see the pypi and conda docs on creating specifications in setup.py and meta.yaml.

@hamelsmu any chance you could add this to the docs somewhere?

@jcpayne since the lines you're showing aren't just setup.py specs, I'm not sure it's possible to specify them as a requirement in pip. Since nbdev just passes the string directly to pip, there's nothing we can do to support requirements that pip doesn't support.

jcpayne commented 3 years ago

Thanks @jph00 and @hamelsmu for your replies - I appreciate them. I'll see if I can get it to work but it looks like I'll have to learn something about setup.py and meta.yaml first!

John

jph00 commented 3 years ago

FYI if you don't need conda support, you can ignore meta.yaml

hamelsmu commented 3 years ago

@jcpayne @jph00 I corrected the summary above to avoid future confusion

image

hamelsmu commented 3 years ago

@hamelsmu any chance you could add this to the docs somewhere?

Added in https://github.com/fastai/nbdev/pull/399

cvillagrasa commented 1 year ago

Hi! I've been searching for a while and I'm unable to find the following:

In nbdev, if I want to use conda specifications in accordance to meta.yaml, should I place them under conda_requirements in settings.ini or should I create a meta.yaml?

Thanks in advance,