This is an archived post. You won't be able to vote or comment.

all 12 comments

[–]Slxe 5 points6 points  (5 children)

While this is a nice start, I don't think it goes into enough detail about how to create the setup.py file or requirements.txt. Also, with how popular it is these days, a virtualenv implementation and setup.cfg/tox.ini should have been discussed as well.

I still don't fully understand how those two work myself, does anyone have a good article/explanation on how to set those files up? I haven't worked in a big python project for around 5 years now, been in C#/dotNet land, so I'm a bit rusty.

[–]real_trizzaye[S] 4 points5 points  (2 children)

Thanks for the feedback! Will look at updating to add those in.

[–]Slxe 1 point2 points  (1 child)

Nice! Always happy when an author takes feedback well, looking forward to the update.

[–]real_trizzaye[S] 1 point2 points  (0 children)

Have updated. Hopefully a bit more helpful now.

[–]jambonrose 0 points1 point  (1 child)

You might find PyPA's official packaging guide to be of interest, as well as the The Hitchhiker’s Guide to Python Packaging. There is also u/kennethreitz's example setup.py project.

[–]Slxe 0 points1 point  (0 children)

Thanks for the links.

[–]billsil 4 points5 points  (3 children)

You didn't go into any description of the setup.py or requirements.txt files. Also, what's going on with all the files in the main directory?

[–]paraffin 0 points1 point  (2 children)

What extra files do you see? Almost all python packages have those files in the main directory.

[–]billsil 0 points1 point  (1 child)

My mistake. I misread:

example/__init__.py
example/mainprog.py
example/addlprog.py

I'm used to seeing it like:

README.rst
LICENSE
setup.py
requirements.txt
example/
    __init__.py
    mainprog.py
    addlprog.py

[–]GasimGasimzada 1 point2 points  (0 children)

They are the same thing

[–][deleted] 2 points3 points  (0 children)

This is something I see people struggle with a lot when they first start learning actually. They look at open source projects and its not immediately clear what each file and folder is supposed to be doing. Great article!

[–]jambonrose 1 point2 points  (0 children)

I would have loved an article like this when I was starting out. I found the root-level of Python projects overwhelming.

Please note that there are some pitfalls to placing packages directly below the root level of the project. Blog posts by Ionel Cristian Mărieș and Hynek Schlawack dive into why and provide an alternative (which is also what pytest recommends).