News for hackers. Stuff that matters.
Re:Makesite.py – Simple, lightweight, and magic-free static ... by brenden2 on Sunday November 24, 2019 @11:43AM (#21621503)
Cool, but I'm so tired of Python that I've started to avoid any projects written with it. Dealing with dependencies, 2 vs. 3, pip, virtualenv, etc is such a pain.

I think the Java/Go/Rust model where all dependencies are included in the binary is the way to go.

Re:Makesite.py – Simple, lightweight, and magic-free static ... by joshklein on Sunday November 24, 2019 @03:07PM (#21622963)
You raise a fair general point about Python dependencies, but that issue is usually related to poorly considered use of third-party dependencies or the need to distribute binaries and leverage C bindings.

But here we have exactly the kind of project that should be written in Python, forked and cloned by you, then tweaked and maintained as if you wrote it yourself. From a brief glance through the code, and taking the submission title at face value, this project is a refreshingly appropriate use of the right language. I offer this as someone who writes Python and Go, generally preferring Go anywhere possible.

I plan to poke around some more in this repo to see if I can easily replace my use of Hugo with this, since I use only a tiny fraction of the features in Hugo and have found it challenging to hack on it as a low-priority weekend project.

For turning personal blog posts from markdown to HTML with some general convenience functions around maintaining the front-matter and templates, I can’t think of something more appropriate than a Python script sitting inside your blog directory with all of its dependencies except the interpreter itself checked in with your templates and content.

Re:Makesite.py – Simple, lightweight, and magic-free static ... by RobertRoberts on Sunday November 24, 2019 @04:25PM (#21623535)
I won't bother with Python again because these conflicts happen on your first time even trying out the language. (running linux, any better on Windows?)

It was such a mess that I can't even describe the frustration. And I even got Apache working with SVN! (40 pages of docs and no testing points from start till it's fully working, yuck)

EDIT: Since I got downvotes so quick, tell me why anyone should choose Python over the many alternative out now?

Re:Makesite.py – Simple, lightweight, and magic-free static ... by nurettin on Sunday December 01, 2019 @02:57AM (#21674439)
Sorry you went through the trouble of what is called "setting up a development environment" and yes, I wish you could simply start coding and distributing programs as soon as you boot up a computer, but that is simply not the case anymore. Not with python, not with ruby and not with go.
Re:Makesite.py – Simple, lightweight, and magic-free static ... by joshklein on Sunday November 24, 2019 @05:15PM (#21623829)
There’s too much to untangle for a brief explanation, but if this really happened when you tried writing Python on Linux for the first time, or using a program written in Python you installed through your distribution’s package manager, file a bug report with your distribution.
Re:Makesite.py – Simple, lightweight, and magic-free static ... by RobertRoberts on Sunday November 24, 2019 @09:55PM (#21625069)
It wasn't "bugs" it was all the hoops to jump through, conflicting hoops, multiple installed versions, pip vs all the other package installers, that also caused conflicts, etc...

Since I am not a Python dev, I would be unable to provide a useful report even if it were bugs.

Re:Makesite.py – Simple, lightweight, and magic-free static ... by idoubtit on Sunday November 24, 2019 @12:12PM (#21621734)
In my opinion, the worst problem is the lack of a standard way to handle dependencies. I recently had a hard time deploying a small Python project over a few heterogeneous Linux machines.

For example, this "simple, lightweight" program has dependencies, as one can see in its .travis.yaml file. That's why the readme has the command `pip install commonmark` (plus more dependencies for dev). But, wait, doesn't `pip` install as root in /usr/local/ by default? (BTW, the documentation of `pip install` is mute on the subject.) So I should use pipenv, but last time I tried it was broken and the ticket had low activity. So virtualenv + pip, but it's a mess since I like using many terminals. I've heard about poetry, but that's not standard at all...

Re:Makesite.py – Simple, lightweight, and magic-free static ... by marmaduke on Sunday November 24, 2019 @05:08PM (#21623785)
You should use pip install --user, which pip will tell you about if you run pip install -h.

Virtualenv is usually excessive unless you have to handle lots of version problems

Re:Makesite.py – Simple, lightweight, and magic-free static ... by tedmiston on Sunday November 24, 2019 @06:56PM (#21624404)
Dockerizing Python apps provides a nice isolation that makes managing dependencies across multiple apps much easier.
Re:Makesite.py – Simple, lightweight, and magic-free static ... by kalia35 on Sunday November 24, 2019 @01:56PM (#21622447)
Why is virtualenv a mess with multiple terminals ? pip install for root unless you activate a virtualenv in which case it installs in it. If you make an alias of . env/bin/activate it is very simple, no ?
Re:Makesite.py – Simple, lightweight, and magic-free static ... by mixmastamyk on Sunday November 24, 2019 @01:45PM (#21622377)
It is not hard, it is just folks desimplifying things to solve largely theoretical problems.

Just pip install to the location you choose. sudo or —user is fine 99% of the time. Venvs are only needed for big work projects.

Re:Makesite.py – Simple, lightweight, and magic-free static ... by jacquesm on Sunday November 24, 2019 @12:47PM (#21621991)
Python deployment is a shitshow. Unfortunately mission critical stuff (looking at you letsencrypt) is also written in it which means that your systems are built on very shaky foundations.
Re:Makesite.py – Simple, lightweight, and magic-free static ... by kalia35 on Sunday November 24, 2019 @01:53PM (#21622423)
What ? This seems like a bold affirmation. I find it very simple actually :

  apt install python3 virtualenv
  virtualenv env
  . env/bin/activate
  pip install -r requirements.txt
Done. And then with fabric you can automate deployments in a few lines of codes !
Re:Makesite.py – Simple, lightweight, and magic-free static ... by jacquesm on Sunday November 24, 2019 @02:10PM (#21622550)
Right up until it nukes your perfectly working server.

The happy case works, it always does. The problem is in the edge cases and the exceptions. This probably goes for the bulk of all software.

Re:Makesite.py – Simple, lightweight, and magic-free static ... by kalia35 on Sunday November 24, 2019 @04:57PM (#21623719)
Well in ten years I have never had a nuked server by pip or virtualenv. I am sure there are edge cases but that must be true for all the ways of deploying stuff. I guess the ones you know well appear simple to you !
Re:Makesite.py – Simple, lightweight, and magic-free static ... by jacquesm on Sunday November 24, 2019 @05:06PM (#21623775)
I've had a production server be hosed by running 'letsencrypt-auto'. My bad I guess but still, that's one that I really did not see coming.
Re:Makesite.py – Simple, lightweight, and magic-free static ... by StavrosK on Sunday November 24, 2019 @05:19PM (#21623856)
I kind of agree with both of you. I don't think Python deployment is that bad, as most modern managers get it right (I prefer Poetry nowadays). However something like letsencrypt-auto, which AFAIK installs its own dependencies, is not something I'd run. I've actually never used it precisely because it's too magical. Programs shouldn't install their own dependencies anywhere outside of a virtualenv.
Re:Makesite.py – Simple, lightweight, and magic-free static ... by kalia35 on Monday November 25, 2019 @11:45AM (#21629933)
Does certbot do the same ? I don’t use either so I can’t tell.

I strongly agree that any python program must install its dependencies in a virtualenv. One could even argue that this principle could be extended to any software !

Re:Makesite.py – Simple, lightweight, and magic-free static ... by jklehm on Sunday November 24, 2019 @08:42PM (#21624821)
Have you heard of our Lord and Savior pipx? Solves the python tool isolation issue nicely.
Re:Makesite.py – Simple, lightweight, and magic-free static ... by StavrosK on Sunday November 24, 2019 @08:51PM (#21624854)
I haven't used it, I use virtualfish which does a great job as well.
Re:Makesite.py – Simple, lightweight, and magic-free static ... by jklehm on Sunday November 24, 2019 @08:59PM (#21624884)
Virtualfish is new to me, will check it out thanks.
Re:Makesite.py – Simple, lightweight, and magic-free static ... by StavrosK on Sunday November 24, 2019 @09:02PM (#21624892)
And it turned out that pipx wasn't what I thought it was, so thank you as well! Though virtualfish is only useful if you use the fish shell.
Re:Makesite.py – Simple, lightweight, and magic-free static ... by xmprt on Sunday November 24, 2019 @02:41PM (#21622781)
People who know what they're doing can build a lot of things with python. It just so happens that I am not one of those people so I try to avoid it with a ten foot stick. I still use things built with python everyday.
Re:Makesite.py – Simple, lightweight, and magic-free static ... by fanf2 on Sunday November 24, 2019 @02:13PM (#21622574)
We like `dehydrated` for ACME
Re:Makesite.py – Simple, lightweight, and magic-free static ... by tedmiston on Sunday November 24, 2019 @06:59PM (#21624420)
Re:Makesite.py – Simple, lightweight, and magic-free static ... by caro_douglos on Sunday November 24, 2019 @08:30PM (#21624771)
Have you always used this or did you make a transition after LE burned you?
Re:Makesite.py – Simple, lightweight, and magic-free static ... by tedmiston on Sunday November 24, 2019 @09:56PM (#21625074)
I heard about dehydrated from PythonAnywhere [1]. I haven't ever been burned by LE from a Python library, but I have had issues in the past with the kube-lego Helm chart not renewing as it should (easily fixed by deleting the pod though). [I know kube-lego is in maintenance mode now in favor of cert-manager.]

[1]: https://help.pythonanywhere.com/pages/LetsEncrypt

Re:Makesite.py – Simple, lightweight, and magic-free static ... by drunken-serval on Sunday November 24, 2019 @12:55PM (#21622035)
Or go to the dark side and install Wordpress.

It’s actually not as bad as I thought it would be. I modified one of the twenty-x themes that come with it and installed a few plugins to make a decent personal site. It took less time that it would have to create anything with remotely similar functionality.

I run it off a single vps that has no other purpose. If it gets hacked, nothing of value is lost. I can revoke the api keys for the external services I use and restore to a new server from my backups.

Re:Makesite.py – Simple, lightweight, and magic-free static ... by x3haloed on Sunday November 24, 2019 @12:57PM (#21622051)
More like the vulnerable side.
Re:Makesite.py – Simple, lightweight, and magic-free static ... by bishalb on Sunday November 24, 2019 @10:31PM (#21625228)
WordPress used to be quite vulnerable a few years ago, but nowadays not so much, just avoid less popular plugins and you should be ok. Of course since it's the most widely used cms's out there, its a prime target for hackers. But the "WordPress is vulnerable" thing is much of a meme in the current day.
Re:Makesite.py – Simple, lightweight, and magic-free static ... by web007 on Monday November 25, 2019 @12:36AM (#21625732)
You've got to be kidding.

https://wpvulndb.com/

Six security vulnerabilities in core WP just last month.

It's still a mess, and every plugin gives it a bigger attack surface.

Re:Makesite.py – Simple, lightweight, and magic-free static ... by drunken-serval on Sunday November 24, 2019 @01:12PM (#21622171)
Any software has vulnerabilities. You have to keep the operating system on any server patched and set up basic defenses even for a static site.
Re:Makesite.py – Simple, lightweight, and magic-free static ... by theamk on Sunday November 24, 2019 @06:43PM (#21624334)
Well, there are more and less vulnerable things.

For example, making sure that software cannot modify itself will ensure that even if server is vulnerable, it won’t get permanently compromised. Having a server that does not execute any file with right extension makes sure that sanitization errors do not lead to code execution. Having admin system be separate from main site makes sure XSS cannot cause compromises.

Re:Makesite.py – Simple, lightweight, and magic-free static ... by stevenicr on Sunday November 24, 2019 @02:36PM (#21622738)
with a default wp install - you are right, however it's trivial to add a couple of security plugins and turn on auto-update.

adding the "ipgeoblock plugin" wipes out most attacks straight away.

with some of my wp sites that got attacked a lot on a regular basis, I use a 'static html generator' plugin - and delete all the wp php files -

no way to login, add comments or hack the wp core or plugins or themes, since they are not in use when you convert it all the static html.

On wp sites where I actually add content with regularity, I don't delete the wp files, and just use shield, sucuri, ipgeoblock, plugin things like that depending on threat.

Re:Makesite.py – Simple, lightweight, and magic-free static ... by skittleson on Sunday November 24, 2019 @03:32PM (#21623149)
wordpress is great for quick sites. Long term maintenance is where I have been bitten.
Re:Makesite.py – Simple, lightweight, and magic-free static ... by cxr on Sunday November 24, 2019 @01:49PM (#21622396)
> I think the Java/Go/Rust model where all dependencies are included in the binary is the way to go.

This is how triple scripts are designed[1] to work.

One proof-of-concept just so happens to be a minimalist static site generator called triickl[2]. You can drop it onto (virtually) any machine, double click, and point it at a source directory for your site—subject to the expectation that it follows a certain jekyll-like structure—and then you're off to the races. I'm using it as the build step for the triplescripts.org home page itself and my personal site.

1. https://triplescripts.org/format#self-contained

1. https://releases.triplescripts.org/triickl/

Re:Makesite.py – Simple, lightweight, and magic-free static ... by tedmiston on Sunday November 24, 2019 @06:52PM (#21624379)
You can create and distribute all-in-one Python executables with PyInstaller.

I've used it in multistage Docker builds to produce very clean, minimal production images like what people commonly do in Go.

https://pyinstaller.readthedocs.io/en/stable/usage.html

Re:Makesite.py – Simple, lightweight, and magic-free static ... by theamk on Sunday November 24, 2019 @06:46PM (#21624345)
I’ll by Go or Rust, but Java? I have spent too much time fixing java software recently.. it’s dependencies are a complete pain.
Re:Makesite.py – Simple, lightweight, and magic-free static ... by diminoten on Sunday November 24, 2019 @02:33PM (#21622713)
Have you tried writing a web app in Java/Go/Rust vs. Python in the past year?
Re:Makesite.py – Simple, lightweight, and magic-free static ... by suyash on Sunday November 24, 2019 @01:27PM (#21622264)
I would have considered if this project was using Node.js instead Python as well.
Re:Makesite.py – Simple, lightweight, and magic-free static ... by dastx on Sunday November 24, 2019 @02:44PM (#21622800)
Sure, let's install 1 million dependencies instead of 5.
Re:Makesite.py – Simple, lightweight, and magic-free static ... by bigiain on Sunday November 24, 2019 @08:11PM (#21624708)

  gulp build
  Error: cannot find dependency 'left pad.js'