News for hackers. Stuff that matters.
Re:How to make a Python package in 2021 by neolog on Wednesday April 07, 2021 @10:20PM (#26734371)
Just use Poetry [1]. It's popular and works well.

[1] https://python-poetry.org/

Re:How to make a Python package in 2021 by sergiomattei on Wednesday April 07, 2021 @11:16PM (#26734724)
Huge thumbs up to Poetry. It's drastically simplified package management for me and replaced Pipenv (which I simply dreaded working with due to performance and DX issues).

I no longer start Python projects without Poetry. It's really good.

EDIT: Also, it's being integrated to most PaaS as well. I deploy to Render.com with Poetry now.

Re:How to make a Python package in 2021 by guggle on Thursday April 08, 2021 @12:24AM (#26735065)
That's a 72MB download, and yet another way to fragment the ecosystem. Not something I'd get just to make a package when a default Python setup has recommended tools and everything I need to make and/or install packages.
Re:How to make a Python package in 2021 by BerislavLopac on Thursday April 08, 2021 @04:47AM (#26736522)
> a default Python setup has recommended tools and everything I need to make and/or install packages

No it doesn't. Neither setuptools nor pip are part of the standard library. Yes, they are installed by default in many cases, but they are still "extra tools".

Re:How to make a Python package in 2021 by oblio on Thursday April 08, 2021 @07:24AM (#26737445)
On the list of priorities for any package manager, download size should be #100 on the list.

If you've solved 1-99 and download size is an issue, you're in heaven already.

Re:How to make a Python package in 2021 by cixinlui on Thursday April 08, 2021 @05:14AM (#26736707)
72MB? On a development machine? Are you on dialup?

Poetry doesn't fragment the ecosystem. Unlike setuptools it uses pyproject.toml, which can be read by other tools, and is the correct way of storing package configuration.

A package built using Poetry is installable without Poetry in the exact same way as one built using setuptools.

Re:How to make a Python package in 2021 by guggle on Thursday April 08, 2021 @09:55AM (#26738697)
Last time I tried poetry it was so broken that it was not even usable. I may try again later.
Re:How to make a Python package in 2021 by skrtskrt on Thursday April 08, 2021 @12:13PM (#26740555)
I had a tough time with it ~3 years ago, but now it works great for me
Re:How to make a Python package in 2021 by remram on Thursday April 08, 2021 @10:41AM (#26739290)
I think it's the right direction, and I look forward to Poetry maturing. But right now it has a lot of gotchas, and I would only recommend it for people who are serious about dependency management/compliance/reproducibility.

See details upthread https://news.ycombinator.com/item?id=26739234

Re:How to make a Python package in 2021 by anaganisk on Thursday April 08, 2021 @01:24AM (#26735356)
Default way is pip freeze which I feel is too verbose, is tracking every dependency of django worth it?
Re:How to make a Python package in 2021 by guggle on Thursday April 08, 2021 @04:08AM (#26736262)
That's if you want to pin transitive dependencies, which is the de facto standard in JS world but not always true in Python world, depending on your context.
Re:How to make a Python package in 2021 by tomwojcik on Thursday April 08, 2021 @03:23AM (#26736014)
Yes. Also, check pip-tools by jazzband.
Re:How to make a Python package in 2021 by 1337shadow on Thursday April 08, 2021 @07:13AM (#26737360)
Which, like any jazzband project, you must not use for a commercial project, as stated by their CoC, the Contributor Covenant with a vague & bizarre modification about ethical use at the end. You are simply not allowed to contribute in any way on any kind of paid time, nor are you allowed to pay someone to contribute. This is of course not advertised for when they tell you to give them your OSS projects, for which you have already chosen a license and maybe even a CoC for. For this reason, despite the many non profit projects I maintain, I stay away from jazzband.
Re:How to make a Python package in 2021 by bpeebles on Thursday April 08, 2021 @01:06PM (#26741224)
Do you mean

> Other unethical or unprofessional conduct

from https://jazzband.co/about/conduct ? Or something else?

Re:How to make a Python package in 2021 by fctorial on Thursday April 08, 2021 @05:38AM (#26736828)
There are at least 5 comments in this thread saying "just use the tool I use"
Re:How to make a Python package in 2021 by kuu on Thursday April 08, 2021 @08:09AM (#26737730)
Re:How to make a Python package in 2021 by santiagobasulto on Wednesday April 07, 2021 @10:31PM (#26734433)
+1 for poetry. It also includes deterministic dependency resolution with a lock file.

I just published a repo today[0] using Poetry and it didn’t take me more than 5 minutes. Poetry build && poetry publish

[0] https://github.com/santiagobasulto/hyper-inspector

Re:How to make a Python package in 2021 by rahimnathwani on Wednesday April 07, 2021 @11:44PM (#26734886)
This looks cool. I had never come across rich[0] before.

[0] https://github.com/willmcgugan/rich

Re:How to make a Python package in 2021 by icy on Wednesday April 07, 2021 @10:28PM (#26734425)
Yup, was surprised to see no mention of Poetry. Hands down, the best package manager for Python.
Re:How to make a Python package in 2021 by void_mint on Wednesday April 07, 2021 @11:15PM (#26734713)
Holy crap, for some reason I never thought to consider another package manager than Pip, which I loathe.
Re:How to make a Python package in 2021 by beaugunderson on Friday April 09, 2021 @11:22PM (#26758653)
`poetry` and `pipenv` are both so much slower than `pip-compile` for me (there are many open issues for both complaining about lock speed), and manage to update locked dependencies half the time despite me asking them not to with e.g. `poetry lock --no-update`.
Re:How to make a Python package in 2021 by person_of_color on Wednesday April 07, 2021 @11:44PM (#26734887)
Do any big projects actually use it?
Re:How to make a Python package in 2021 by neolog on Thursday April 08, 2021 @12:10AM (#26735008)
It's only three years old, I can't think of many big projects created in that timespan.
Re:How to make a Python package in 2021 by say_it_as_it_is on Thursday April 08, 2021 @06:09AM (#26737003)
Unless Instagram found migrating to it valuable enough to fund the effort
Re:How to make a Python package in 2021 by tcbasche on Wednesday April 07, 2021 @11:20PM (#26734748)
How does it compare to pipenv?
Re:How to make a Python package in 2021 by smnrchrds on Thursday April 08, 2021 @12:06AM (#26734993)
Pipenv only targets applications; Poetry targets both applications and libraries. Pipenv has quite some drama behind it that I do not want to get into; in contrast, Poetry's development has been quite professional. Pipenv enjoys better tool support, e.g. it is recognized and supported by VS Code; but Poetry does not have the same level of support.
Re:How to make a Python package in 2021 by monsieurbanana on Thursday April 08, 2021 @12:55AM (#26735224)
I don't know anything about pipenv drama, so by morbid curiosity I looked for it and this is the first thing I found:

https://github.com/pypa/pipenv/issues/2228

This is one of the most ridiculous issues I've read. If the rest of the "drama" is like that, then eh.

Re:How to make a Python package in 2021 by smnrchrds on Thursday April 08, 2021 @01:32AM (#26735390)
The drama was surrounding false advertising so to speak. Pipenv promised a lot but did not quite deliver, much like the earlier days of MongoDB. But more importantly, it pretended or at least heavily implied it was an official PSF-affiliated project, when it was not. How that claim was substantiated was also subject to drama.
Re:How to make a Python package in 2021 by ric2b on Thursday April 08, 2021 @01:37PM (#26741576)
It also had no releases for over a year, even though the master branch was getting frequent updates and the performance of the last release was atrocious (and I'm not sure if it has improved much).

I did like the emojis in the logs though.

Re:How to make a Python package in 2021 by kbd on Thursday April 08, 2021 @12:19AM (#26735039)
FWIW here's VSCode's issue for supporting Poetry[1] and here's their plan to support it[2]:

[1] https://github.com/microsoft/vscode-python/issues/8372

[2] https://github.com/microsoft/vscode-python/wiki/Support-poet...

Re:How to make a Python package in 2021 by spondyl on Thursday April 08, 2021 @12:26AM (#26735076)
From memory, there was a whole thing where pipenv, created by Kenneth Reitz of requests fame, was misaccurately portrayed as the official successor to pip when that wasn't true
Re:How to make a Python package in 2021 by tcbasche on Thursday April 08, 2021 @03:36AM (#26736082)
I recall this, but I wasn’t quite clear on what the issue was with pipenv itself (other than questionable behaviour from the author)
Re:How to make a Python package in 2021 by pseudalopex on Thursday April 08, 2021 @04:00AM (#26736219)
It was buggy. It was slow. It didn't even try to support developing libraries.
Re:How to make a Python package in 2021 by tcbasche on Thursday April 08, 2021 @04:28AM (#26736394)
Now it’s all coming back to me. I remember it half supporting in-house pip repositories but not quite
Re:How to make a Python package in 2021 by losvedir on Thursday April 08, 2021 @09:15AM (#26738287)
I just moved a project from pipenv to poetry at work. My biggest issue with pipenv is that you can't selectively upgrade dependencies. Trying to `pipenv update xyz` basically blows away your lockfile and updates everything. There's a command line flag to be more selective but it doesn't work. I found an open GitHub issue about it that's years old.

Poetry by contrast works pretty much like any modern dependency system you'd be familiar with from another language like cargo, npm, or hex.

Re:How to make a Python package in 2021 by skrtskrt on Thursday April 08, 2021 @12:14PM (#26740573)
In addition to everything else already said, pipenv is mind-bogglingly slow and buggy. Like 30 minutes and a timeout error to install pyspark.
Re:How to make a Python package in 2021 by neolog on Wednesday April 07, 2021 @11:24PM (#26734771)
Poetry is better.
Re:How to make a Python package in 2021 by tcbasche on Wednesday April 07, 2021 @11:25PM (#26734785)
Well that settles it
Re:How to make a Python package in 2021 by acdanger on Wednesday April 07, 2021 @11:30PM (#26734818)
I think pipenv is better for managing non-published Python environments, so there.
Re:How to make a Python package in 2021 by bliteben on Thursday April 08, 2021 @12:04AM (#26734981)
pipenv has slightly better support in vscode
Re:How to make a Python package in 2021 by neolog on Thursday April 08, 2021 @12:27AM (#26735079)
> Support for poetry environments is currently our highest upvoted feature request on GitHub.

https://github.com/microsoft/vscode-python/wiki/Support-poet...

Re:How to make a Python package in 2021 by marban on Thursday April 08, 2021 @12:06AM (#26734991)
For poetry, it makes sense to use `poetry self update --preview` — I often come across weird bugs that take too long to get fixed in the current release.