duckinator / bork

A Python build and release management tool.
https://bork.readthedocs.io
MIT License
12 stars 2 forks source link

[v7.0.2] Fix `bork build` failure due to bad mkdir() call. #341

Closed duckinator closed 9 months ago

duckinator commented 9 months ago

This is the only user-facing change for v7.0.2.

Fixes #338.

nbraud commented 9 months ago

@duckinator Did you manage to make a reproducing testcase for this? 'cause I had the same patch, but I couldn't be sure that fixed it :sweat:

duckinator commented 9 months ago

Honestly, I don't remember. This was less than 3 hours before I wound up in the ER last night. 😅

duckinator commented 9 months ago

@nbraud digging through my shell history, it looks like my testcase was Homf.

With bork v7.0.2:

(venv) puppy@orthrus.fox:~/dev/duckinator/homf main+ bork --version
bork v7.0.2
(venv) puppy@orthrus.fox:~/dev/duckinator/homf main+ bork clean
(venv) puppy@orthrus.fox:~/dev/duckinator/homf main+ bork build
Processing ./dist/homf-0.0.1-py3-none-any.whl
Installing collected packages: homf
Successfully installed homf-0.0.1

[notice] A new release of pip is available: 23.0.1 -> 23.3.1
[notice] To update, run: pip install --upgrade pip
(venv) puppy@orthrus.fox:~/dev/duckinator/homf main+

After downgrading to Bork v7.0.1:

(venv) puppy@orthrus.fox:~/dev/duckinator/homf main+ pip3 install bork==7.0.1
Collecting bork==7.0.1
[...]
Successfully installed bork-7.0.1

[notice] A new release of pip is available: 23.0.1 -> 23.3.1
[notice] To update, run: pip install --upgrade pip
(venv) puppy@orthrus.fox:~/dev/duckinator/homf main+ bork --version
bork v7.0.1
(venv) puppy@orthrus.fox:~/dev/duckinator/homf main+ bork clean
(venv) puppy@orthrus.fox:~/dev/duckinator/homf main+ bork build
Traceback (most recent call last):
  File "/usr/home/puppy/dev/duckinator/homf/venv/bin/bork", line 8, in <module>
    sys.exit(main())
  File "/usr/home/puppy/dev/duckinator/homf/venv/lib/python3.9/site-packages/bork/cli.py", line 227, in main
    args.func(args)
  File "/usr/home/puppy/dev/duckinator/homf/venv/lib/python3.9/site-packages/bork/cli.py", line 52, in build
    api.build()
  File "/usr/home/puppy/dev/duckinator/homf/venv/lib/python3.9/site-packages/bork/api.py", line 37, in build
    raise e
  File "/usr/home/puppy/dev/duckinator/homf/venv/lib/python3.9/site-packages/bork/api.py", line 33, in build
    builder.zipapp()
  File "/usr/home/puppy/dev/duckinator/homf/venv/lib/python3.9/site-packages/bork/builder.py", line 91, in zipapp
    _prepare_zipapp(dest, _bdist_file())
  File "/usr/home/puppy/dev/duckinator/homf/venv/lib/python3.9/site-packages/bork/builder.py", line 54, in _prepare_zipapp
    Path(dest).mkdir()
  File "/usr/local/lib/python3.9/pathlib.py", line 1323, in mkdir
    self._accessor.mkdir(self, mode)
FileNotFoundError: [Errno 2] No such file or directory: 'build/zipapp'
(venv) puppy@orthrus.fox:~/dev/duckinator/homf main+

I can reproduce this trivially, too, so it seems like a good starting point for a testcase.

duckinator commented 9 months ago

Basic testcase is as follows.

hello_world/__init__.py:

def main():
    print("hello, world!")

pyproject.toml:

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "hello_world"
version = "0.0.1"

[tool.bork.zipapp]
enabled = true
main = "hello_world:main"

(that's it)