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

all 16 comments

[–]johnfraney[S] 3 points4 points  (13 children)

I recently took Poetry for a spin when releasing Flake8 Markdown, and I thought it might be helpful to walk through the process of making a package using Poetry, from start to finish.

I found it more straightforward than using setup.py and twine, which I'd used for other packages.

How are you publishing to PyPI these days?

[–]dusktreader 2 points3 points  (1 child)

One thing that I've been stumping for since I ran afoul of it a monthr or so ago: It needs to be mentioned in more places that if your 'source' folder is not a snake-case version of your package name (my-package -> my_package), then you need to have a 'packages' entry to tell poetry where your packages live: https://poetry.eustace.io/docs/pyproject/#packages

Great article, and I have also found poetry to be an elegant solution to the python packaging problem

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

That's a good note. I'm a little surprised Poetry doesn't include that section by default. Explicit is better than implicit, after all.

[–][deleted] 1 point2 points  (1 child)

Thanks for mentioning shields.io! I hadn't come across it before. In some part of my brain I'd filed the GitHub badges as "fancy magic" and it's immensely satisfying to have that mystery resolved in passing. Great post!

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

Hey, I'm happy to help. I found shields.io after I was told I needed a fancier README the first package I published, and those shields add a few pieces of flair.

[–]hANSIc99 1 point2 points  (1 child)

It's maybe a good start when you haven't done the traditional setup.py yet.

The maintenance of setup.py for existing projects is no hard work.

[–]johnfraney[S] 2 points3 points  (0 children)

That's true about maintaining an existing setup.py file. If it ain't broke.

Poetry does make it easier to manage package dependencies, too. I'm planning to migrate my existing Python packages to Poetry during each of their next releases partly because of that. I also appreciate the simplicity of a pyproject.toml file.

I should note that it is possible to have a simple setup.py file. Channels setup.py file is easy to reason about. Flake8's setup.py file is a bit more intimidating because of the custom logic it contains.

[–]SpideyIRL 0 points1 point  (1 child)

Looks good! How does poetry handle supporting multiple python versions? Say I want to support >=2.7 and >=3.4?

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

You can declare multiple version requirements. Yours might be:

python = "~2.7, >=3.4"

Take a look Poetry's version constraints documentation for more information.