diff --git a/docs/_static/test-py.html b/docs/_static/test-py.html index 7ab28779..7c29b5f6 100644 --- a/docs/_static/test-py.html +++ b/docs/_static/test-py.html @@ -37,7 +37,7 @@ let q = `${i}`.padStart(4, '0'); const pyodide = await pyodideReadyPromise; const answer = await pyodide.runPythonAsync(` - from src import p${q} + from euler.python.src import p${q} p${q}.main() `); if (answer === null || answer === undefined) { diff --git a/python/Makefile b/python/Makefile index 9366dc6e..26dd4bfb 100644 --- a/python/Makefile +++ b/python/Makefile @@ -68,6 +68,19 @@ clean: rm -r ./{*,*/*}{.pyc,__pycache__,.mypy_cache} || echo webpack: - mkdir -p ../docs/_static/dist - wget https://cdn.jsdelivr.net/pyodide/v0.26.2/full/pyodide.js -O ../docs/_static/dist/pyodide.js - tar --exclude=__pycache__ -czvf ../docs/_static/dist/python.tar.gz src + # Create temporary directory for the archive content + mkdir -p ../docs/_static/dist/tmp + cp -r ../* ../docs/_static/dist/tmp + + # Add __init__.py files to the temporary directory + echo "# init file" > ../docs/_static/dist/tmp/__init__.py + echo "# init file" > ../docs/_static/dist/tmp/python/__init__.py + + # Exclude unwanted directories and create tarball + cd ../docs/_static/dist/tmp && \ + tar --exclude='__pycache__' --exclude='*/__pycache__' \ + --exclude='!_data' --exclude='!python' \ + -czvf ../python.tar.gz . + + # Clean up temporary directory + rm -rf ../docs/_static/dist/tmp diff --git a/python/src/__init__.py b/python/src/__init__.py index f10a3bc3..dc07a1dc 100644 --- a/python/src/__init__.py +++ b/python/src/__init__.py @@ -10,7 +10,7 @@ for i in range(1, 10000): try: - name = f'p{i:04}' # noqa + name = f'p{i:0>4}' # noqa module = import_module(f'.{name}', __name__) setattr(modules[__name__], name, module) __all__.append(name) @@ -24,4 +24,4 @@ def run_problems() -> None: # pragma: no cover start = perf_counter() answer = p() stop = perf_counter() - print(f'The answer to problem {i:04} is {answer!r} (found in {(stop - start) * 1000:,}ms)') # noqa + print(f'The answer to problem {i:0>4} is {answer!r} (found in {(stop - start) * 1000:,}ms)') # noqa