Live data from Hacker News

How to create a Python package in 2022

mathspp.com

111–120 of 153 posts

Re: How to create a Python package in 2022

#111
post #61

Earlier quoted context omitted.

I guess you have no much experience with python and how easy to get 100% coverage in it.

He's not saying it's difficult to get 100% coverage. He's saying that 100% is a bit suss because you probably wouldn't achieve 100% coverage unless that is your goal (even if Python does make it easy) and that's the wrong goal.

It's a real goal for dynamic languages. You have no other option to be sure your code is not broken. Another option is to use 100%-non-any type hints. It's a way more harder.

I can see it's a non goal then you have access to deployed code and Sentry. But as library author or author of customer apps there is no other way around.

Re: How to create a Python package in 2022

#112
post #97
post #87

What a great article. We start with learning that we absolutely need this Poetry thing because… it's what everyone else uses. It's refreshing to see author who can skip usual badly argued justifications and just plain admin that he does not know shit and is just following rest of the herd. Then we continue by "solving" depependencies by usual way of ignoring them and just freezing whatever happens to be present. Then…

> Poetry thing because… pip freeze doesn't pin transitive dependencies and so you have to pick something and Poetry is fine and actively developed. > virtualenv, because that's just what you have to do when dealing with messed up dependencies No that's what you do when you have multiple dependency trees for different projects on your system. Somehow people got the message that global variables were bad but still thin…

> pip freeze doesn't pin transitive dependencies

AFAIK it lists all installed packages and hence pins all dependencies.

Re: How to create a Python package in 2022

#113
I recently set up a new Python package and ran across the github instructions for automatically uploading the package to pypi. A month later I ran into a bug and needed to push out an update, man was that nice to have automated, and easy to set up.

Re: How to create a Python package in 2022

#114
post #54
post #53

Earlier quoted context omitted.

If I can be forgiven another nitpick regarding readability: The font size is extremely small to the point of being unreadable on a mobile phone.

I think the font size is perfect, but I take offense to the font used for headings

I've been looking for a replacement for that font for a long time. Do you have any suggestions?

Re: How to create a Python package in 2022

#115
post #87

What a great article. We start with learning that we absolutely need this Poetry thing because… it's what everyone else uses. It's refreshing to see author who can skip usual badly argued justifications and just plain admin that he does not know shit and is just following rest of the herd. Then we continue by "solving" depependencies by usual way of ignoring them and just freezing whatever happens to be present. Then…

I had the same reaction. Not much explaining, no justification for the tooling decisions, pushing more undocumented code to pypi because why not, "I saw this other package do this", etc.

I guess it's great if you're just looking for a shortcut to push something up to pypi, but my guess is someone new to it won't really understand what's going on other than some vague sense that they're following "best practices".

And then I imagine that same person will go on to write another article like this, and on and on we go!

Re: How to create a Python package in 2022

#116

Earlier quoted context omitted.

The problem with Python is it's too successful. It has too many useful libraries. I don't really like it very much but it's really hard to ignore it. There is exactly one thing I miss from Python packaging tools: developer mode. I can factor out parts of an application into a library and develop both at the same time by installing the library in editable mode and pointing to the library's local directory. This is som…

Julia had a dev mode as well https://pkgdocs.julialang.org/v1/managing-packages/#developi... It’s packaging tool is top notch. Maybe because it’s developed as a core part of the language.

Good to know. Never tried Julia myself but I see a lot of Julia posts here. I'm also aware it has a really interesting foreign interface with Python, never saw anything like that before.

> Maybe because it’s developed as a core part of the language.

Always thought it was strange how libraries and packaging never seem to be considered part of the language. My favorite example is Scheme: a beautifully minimal language but with no library support and the result was endless fragmentation due to unportable implementations.

Re: How to create a Python package in 2022

#117

Earlier quoted context omitted.

Do you have any tutorials for setting up CI/CD? My impression was that's all stuff that runs in the cloud but if it's something I can use on my own personal projects I'd play with it. Frankly a lot of these things become unintelligible. I've used pre-commit for things like black and autopep8 and that's all pretty understandable to me. The CI/CD things I've read all seem like everyone already understands some giant Ru…

Good example of CI/CD that's not a rube goldberg machine per se: https://github.blog/2022-02-02-build-ci-cd-pipeline-github-a...

Thank you. So does CI/CD require becoming dependent on a cloud service such as github?

Re: How to create a Python package in 2022

#119
post #98
post #94

Earlier quoted context omitted.

Pre-commit running tools in it's own virtual environment is a feature, not a bug, in my book -- it means that the dependencies for my linter tools aren't mixed in with the dependencies for the code I'm writing. And, keeping things separate from setup.cfg or pyproject.toml is optional: The tools still look for configuration in their usual places, so it's still possible have your black options in pyproject.toml and jus…

Except your usual configuration don't necessarily work for your pre-commit hooks. A prime example is mypy.

Sure it can. The pre-commit tool is just a framework for running multiple hooks at commit time against just the files which are modified in that commit. You can configure those hooks however you want.

You also don't have to run the hooks at pre-commit time. Just don't hook pre-commit into your checkout. The pre-commit tool can also be configured to run its checks at a different stages than, well, the pre-commit stage:

https://pre-commit.com/#top_level-default_stages

Re: How to create a Python package in 2022

#120

Earlier quoted context omitted.

Good example of CI/CD that's not a rube goldberg machine per se: https://github.blog/2022-02-02-build-ci-cd-pipeline-github-a...

Thank you. So does CI/CD require becoming dependent on a cloud service such as github?

Not necessarily, it just depends on how invested you are in the CI/CD pipeline for any given project, your preferences regarding self-hosting vs. cloud, and the amount of time you have to dedicate to the subject.

Strictly speaking, any tool or set of tools that allow you to trigger building & deploying/publishing artifacts in response to source control commits can be used to build a CI/CD pipeline. One could write bash scripts linked to a cron job that pulls a remote repository every n minutes and then performs some scripted actions to integrate changes between branches before building & publishing the artifact to a local SFTP server.

If you prefer a more mature solution with better documentation however, there is a (non-exhaustive) list of CI/CD tools on this awesome-devops list:

https://github.com/wmariuss/awesome-devops#continuous-integr...

---

edit: I saw gitlab on the list and realized it is probably the closest self-hosted equivalent to the github option I mentioned previously

https://about.gitlab.com/features/continuous-integration/

Post reply on HN