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

Setup.py and / or pypi package #2525

Closed
Leon0402 opened this issue Mar 19, 2021 · 8 comments
Closed

Setup.py and / or pypi package #2525

Leon0402 opened this issue Mar 19, 2021 · 8 comments
Labels
enhancement New feature or request Stale

Comments

@Leon0402
Copy link

🚀 Feature

Add a setup.py or / and publish a package on pypi for easier use.

Motivation

It is often required in ordner to load the model to have the original source code. Furthermore, there are some useful scripts in here.
It would be a lot easier to set up a project using yolov5 if there were at least a setup.py file. Best case you would also upload it to pypi obviously.

For example: You could then use yolov5 with the package manager poetry, where you can specify a github repository.

Pitch

  1. Add a setup.py file -> Don't have to be very advanced, should be less than 10 lines of code. Just specifying some meta data and requirements
  2. Optionally upload to pypi to make it even easier to use

Alternatives

An alternative to uploading it to pypi is just using only a setup.py. That would be a huge improvement already and it's easy to implement.
You could obviously also use a package manager like poetry instead of a setup.py, which is easy to implement as well and can also do the uploading to pypi.

Additional context

@Leon0402 Leon0402 added the enhancement New feature or request label Mar 19, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2021

👋 Hello @Leon0402, thank you for your interest in 🚀 YOLOv5! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.

If this is a 🐛 Bug Report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available.

For business inquiries or professional support requests please visit https://www.ultralytics.com or email Glenn Jocher at glenn.jocher@ultralytics.com.

Requirements

Python 3.8 or later with all requirements.txt dependencies installed, including torch>=1.7. To install run:

$ pip install -r requirements.txt

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

CI CPU testing

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), testing (test.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.

@glenn-jocher
Copy link
Member

@Leon0402 this is a great idea! See #2481 for some details on this.

@Leon0402
Copy link
Author

Perfect! As I said, personally it would also be a a lot easier if you just provide a setup.py -> This allows including the project in for example poetry by url. No need for pypi, although it is a nice extra :-)

from setuptools import setup

setup(
    name="yolov5",
    url="https://github.com/ultralytics/yolov5",
    maintainer="ultralytics",
    maintainer_email="glenn.jocher@ultralytics.com",
    packages=["models", "utils"],
    install_requires=["opencv-python", "matplotlib", "torchvision", "PyYAML", "requests", "pandas", "seaborn"],
)

Might look like this. I think that's all I need to use it with poetry (at least yolov5 version4 I think?). I can make a PR, but I thought it might make more sense if you do it.
It's mainly just listing some metatdata and you know better than me what belongs in there :-)

@glenn-jocher
Copy link
Member

glenn-jocher commented Apr 15, 2021

@Leon0402 hmm interesting. I hadn't thought of creating a setup.py other than for pypi. https://github.com/python-poetry looks interesting.

Your setup.py file is very simple, are you sure that would be enough? We've been working on a similar one that's a bit more detailed here (for the TODO ultralytics package).
https://github.com/ultralytics/pip/blob/master/setup.py

@glenn-jocher
Copy link
Member

@Leon0402 also could you submit a PR for your idea? I think that would be helpful to understand it better.

@Leon0402
Copy link
Author

Leon0402 commented Apr 15, 2021

I'm not very experienced with setup.py or in general packaging in python. I pretty much did the minimal config I could come up with, so poetry would install all dependencies and find the packages.

It's pretty much a subset of yours. I see just a few differences:

  1. I was just interested in those packages I actually use. As I was working on a coreml export script, I only need model/yolo.py (and that file needed a few others).
  2. You automatically read your requirements.txt, while I did list all dependencies manually without any version for only the code I include (-> Therefore my dependencies list is shorter than your requirements list)
  3. I didn't care about a version
  4. I didn't care about metadata, which is mainly for pypi and things like this ( I think only a few fields like maintainer were required)

My poetry setup for yolov5 is just:

[tool.poetry.dependencies]
yolov5 = { path = "../yolov5", develop = true }

in pyproject.toml

So I've cloned the project and added the setup.py in the root. The develop flag is so that poetry picks up changes I do for instance switching branches on yolov5. That's also why I didn't need a version in the setup.py

If you consider using poetry: From my personal experience, poetry is a great idea and I use it in all my projects. The specification of dependencies along with automatic virtual environments just make it a lot easier for me. But it's not always super easy. It has some bugs. I also had problems with making my stuff cross plattform, especially with pytorch. It's not (completly) poetrys fault. It's mainly because different machines, different os, different python versions need different python packages and too often python packages for a specific os or python version are just missing on pypi. For instance pytorch (used to be) not available on pypi for Windows, but for all other platforms. But poetry doesn't do a good job at failing fast, giving good error messages and stuff like that.
But still: Would recommend it!

@glenn-jocher
Copy link
Member

@Leon0402 interesting, thanks for the ideas!

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Stale
Projects
None yet
Development

No branches or pull requests

2 participants