Description
Bug report
Bug description:
Dear maintainers,
I am using Ubuntu Noble 24.04 development. I know there are some alternatives to freeze, but I have to maintain a larger project as CGI script which is (for me) not so easy to transform and I use it up to 20 years now.
$ python3 --version
Python 3.12.2
$ dpkg -l | grep python3.12
ii python3.12 3.12.2-1 amd64 Interactive high-level object-oriented language (version 3.12)
...
$ cat helloworld.py
#!/usr/bin/python3
print("Hello, World!")
$ /usr/share/doc/python3.12/examples/freeze/freeze.py -o frozen helloworld.py
...
$ cd frozen
$ make
...
x86_64-linux-gnu-gcc -Wl,-Bsymbolic-functions -g -fwrapv -O2 -Xlinker -expo
rt-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions config.o frozen.o M___future__.o M__
_main__.o ...
M_zipp.o /usr/lib/x86_64-linux-gnu/libpython3.12.so -lm -lm -lz -lm -lm -lexpat -lexpat Modules/_hacl/libHacl_Hash_SHA2.a -lz -ldl -lm -o helloworld
/usr/bin/ld: cannot find Modules/_hacl/libHacl_Hash_SHA2.a: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [Makefile:1236: helloworld] Error 1
The linker does not find the library Modules/_hacl/libHacl_Hash_SHA2.a
. As far I can see, Ubuntu does not deliver Modules/_hacl/libHacl_Hash_SHA2.a
as a binary anywhere in the system or as another deb-package.
The only option I see so far is to compile the python sources myself and copy/link the static Modules folder to the current directory. The following Dockerfile shows that (after removing RUN
and changing WORKDIR
to cd
it should be also runable as shell script). However, this is very unhandy and runs > 1h on my machine.
FROM docker.io/library/ubuntu:noble
# enable package sources
RUN sed -i '/deb-src/s/^# //' /etc/apt/sources.list && apt-get update
# Ubuntu cloud images do not install all files from packages. This drops, e.g.,
# the Python examples; therefore, remove the Ubuntu cloud "excludes" configuration.
RUN rm -f /etc/dpkg/dpkg.cfg.d/excludes
# install required packages
RUN apt-get --yes install build-essential python3.12-dev python3.12-examples
# build python
RUN apt-get --yes build-dep python3.12
RUN mkdir /build /demo /demo/frozen
WORKDIR /build
RUN apt-get --yes source python3.12
WORKDIR /build/python3.12-3.12.2
RUN DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage --no-sign -b -j16
# create python demo program
WORKDIR /demo
RUN echo '#!/usr/bin/python3\nprint("Hello, World!")' >helloworld.py
# run freeze
RUN /usr/share/doc/python3.12/examples/freeze/freeze.py -o frozen helloworld.py
# add required link to static modules
RUN ln -s /build/python3.12-3.12.2/build-static/Modules /demo/frozen/Modules
# build and run frozen demo program
WORKDIR /demo/frozen
RUN make && ./helloworld
Why is the Hacl library statically linked? Is linking to it necessary at all? Would it be an option to have it as .so as I am used e.g. from psycopg? If needed, in any case it should be provided as binary by the distro. Further, the by freeze generated frozen/Makefile
(see Makefile.txt) is full of $(sourcedir)
referencing the python source directory (after a build), e.g., LIBHACL_SHA2_A=Modules/_hacl/libHacl_Hash_SHA2.a
. freeze should generate paths as (then) the lib is located by the linux distro.
With Python 3.11.x everythings works like a charm. Should Ubuntu deliver the Module _hacl as binary, or which form? I cannot find any hint in the system and in the package repo. If desired, I could open a respective issue in Ubuntu Lauchpad bugtracker.
Many thanks for looking into it,
Chris
CPython versions tested on:
3.12
Operating systems tested on:
Linux