sm-Fifteen / asgi-server-timing-middleware

Creative Commons Zero v1.0 Universal
45 stars 2 forks source link

Create a setup.py script #1

Open sm-Fifteen opened 4 years ago

sm-Fifteen commented 4 years ago

I don't really have much experience in the way of packaging and publishing python modules, but that's probably something I should get around doing if I want people to be able to use this.

sumerc commented 4 years ago

You are absolutely right about that.

1/ You can look at a simple one that I have written recently here: https://github.com/blackfireio/python-sdk/blob/master/setup.py

2/ You should definitely have some kind of unit testing. I would suggest Travis for CI.

3/ I suggest following flow: when you tag something in master branch, a release job will be triggered in CI which builds the python package and converts it to a .whl via using python setup.py bdist_wheel. Then you will publish the package to PyPI. For publishing: twine is your friend. It is very simple to use and integrate.

At this point the package should be installable just by pip install asgi-server-timing-middleware

4/ Then announce in python-announce, reddit or whatever. You might know these better than me:)

Do not hesitate to ask for help at any of these. I think I can help.

BTW, an idea: asgi-server-timing-middleware seems a bit too verbose. Maybe more compact name? Not sure. This is coming from a guy who wrote yet another ... profiler :)

sm-Fifteen commented 4 years ago

1/ You can look at a simple one that I have written recently here: https://github.com/blackfireio/python-sdk/blob/master/setup.py

Thanks! That was a pretty good starting point.

2/ You should definitely have some kind of unit testing. I would suggest Travis for CI.

Yeah, I've been telling myself the same thing since I created this repo, but I'm still trying to figure out how one is supposed to unit-test a timing/profiling tool, given execution time falls outside of the function-as-a-unit concept. There's also how the entire module is basically one class with a constructor and a __call__ method right now, so it's not exactly setup for testing, but I'll try and figure something out.

3/ I suggest following flow: when you tag something in master branch, a release job will be triggered in CI which builds the python package and converts it to a .whl via using python setup.py bdist_wheel.

I'll keep that part on ice until I figure out how I'm going to go about number 2/

Then you will publish the package to PyPI. For publishing: twine is your friend. It is very simple to use and integrate.

At this point the package should be installable just by pip install asgi-server-timing-middleware

That's going to be next on my list. PyPI has a test instance to let people test package uploading, so I'll be sure to try it on there first in case I mess up.

4/ Then announce in python-announce, reddit or whatever. You might know these better than me:)

Hmm, I might want to at least raise it on the FastAPI issue and on awesome-asgi.

Do not hesitate to ask for help at any of these. I think I can help.

After all you've already done on yappi those past months to even make this possible? I'd still want to have some merit left for myself. ;)

BTW, an idea: asgi-server-timing-middleware seems a bit too verbose. Maybe more compact name? Not sure. This is coming from a guy who wrote yet another ... profiler :)

I'm keeping the name descriptive and to the point because I don't think I would want to "brand" this project. It holds in less than 100 lines of python right now and I don't really expect it to grow past 200. Note that the class is just called ServerTimingMiddleware, which makes it sound like a bit less of a mouthful.

sumerc commented 4 years ago

Yeah, I've been telling myself the same thing since I created this repo, but I'm still trying to figure out how one is supposed to unit-test a timing/profiling tool, given execution time falls outside of the function-as-a-unit concept. There's also how the entire module is basically one class with a constructor and a call method right now, so it's not exactly setup for testing, but I'll try and figure something out.

Yeah the testing might be tricky. Not sure if this helps, but you might want to have a look at here maybe: https://github.com/florimondmanca/ddtrace-asgi/blob/master/tests/test_trace_middleware.py

I'm keeping the name descriptive and to the point because I don't think I would want to "brand" this project.

Makes sense.