Reuse Python deps between phases and split by dir structure

This commit is contained in:
Reinout Meliesie 2025-03-09 19:58:29 +01:00
parent 6f7d8ae4ce
commit 2e83d0e020
Signed by: zedfrigg
GPG key ID: 3AFCC06481308BC6

View file

@ -10,6 +10,87 @@ with pkgs . kernelmaft . python ;
with pkgs . python311Packages ;
with stdenv ;
let
simplePythonDependencies = [
aiohappyeyeballs
aiohttp
aiosignal
amqp
asgiref
attrs
billiard
bleach
boto3
botocore
bw-file-resubmit
celery
certifi
cffi
chardet
click
colorthief
cron-descriptor
cryptography
deprecated
django
django-appconf
django-celery-beat
django-csp
django-imagekit
django-model-utils
django-oauth-toolkit
django-pgtrigger
django-sass-processor
django-storages
django-timezone-field
environs
frozenlist
googleapis-common-protos
grpcio
idna
importlib-metadata
jmespath
jwcrypto
kombu
libsass
markdown
marshmallow
multidict
oauthlib
opentelemetry-api
opentelemetry-exporter-otlp-proto-common
opentelemetry-exporter-otlp-proto-grpc
opentelemetry-proto
opentelemetry-sdk
opentelemetry-semantic-conventions
packaging
pilkit
pillow
protobuf
psycopg2
pycryptodome
pyotp
python-crontab
python-dateutil
python-dotenv
qrcode
redis
requests
s3-tar
s3transfer
six
sqlparse
typing-extensions
urllib3
vine
webencodings
wrapt
yarl
] ;
overlappingPythonDependencies = [] ;
in
mkDerivation {
pname = "bookwyrm" ;
version = "2025-02-14-ba1f180" ;
@ -23,71 +104,17 @@ mkDerivation {
dontPatch = true ;
dontConfigure = true ;
buildPhase = ''
runHook preBuild
mkdir -p /build/lib/python3.11/site-packages
ln -sf ${aiohappyeyeballs}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${aiohttp}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${aiosignal}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${amqp}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${asgiref}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${attrs}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${billiard}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${bleach}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${boto3}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${botocore}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${bw-file-resubmit}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${celery}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${certifi}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${cffi}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${click}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${colorthief}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${cron-descriptor}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${cryptography}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${django}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${django-celery-beat}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${django-csp}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${django-imagekit}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${django-model-utils}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${django-oauth-toolkit}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${django-pgtrigger}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${django-sass-processor}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${django-storages}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${django-timezone-field}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${environs}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${frozenlist}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${idna}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${jmespath}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${jwcrypto}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${kombu}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${libsass}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${markdown}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${marshmallow}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${multidict}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${oauthlib}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${packaging}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${pillow}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${psycopg2}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${pycryptodome}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${pyotp}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${python-crontab}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${python-dateutil}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${python-dotenv}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${qrcode}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${redis}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${requests}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${s3-tar}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${s3transfer}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${six}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${sqlparse}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${typing-extensions}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${urllib3}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${vine}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${webencodings}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
ln -sf ${yarl}/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
# Python dependencies
for dependency in "${ concatStringsSep " " simplePythonDependencies }" ; do
ln -sf $dependency/lib/python3.11/site-packages/* /build/lib/python3.11/site-packages/
done
export PYTHONPATH=/build/lib/python3.11/site-packages
@ -103,84 +130,7 @@ mkDerivation {
runHook postBuild
'' ;
installPhase = let
pythonDependencies = [
aiohappyeyeballs
aiohttp
aiosignal
amqp
asgiref
attrs
billiard
bleach
boto3
botocore
bw-file-resubmit
celery
certifi
cffi
chardet
click
colorthief
cron-descriptor
cryptography
deprecated
django
django-appconf
django-celery-beat
django-csp
django-imagekit
django-model-utils
django-oauth-toolkit
django-pgtrigger
django-sass-processor
django-storages
django-timezone-field
environs
frozenlist
googleapis-common-protos
grpcio
idna
importlib-metadata
jmespath
jwcrypto
kombu
libsass
markdown
marshmallow
multidict
oauthlib
opentelemetry-api
opentelemetry-exporter-otlp-proto-common
opentelemetry-exporter-otlp-proto-grpc
opentelemetry-proto
opentelemetry-sdk
opentelemetry-semantic-conventions
packaging
pilkit
pillow
protobuf
psycopg2
pycryptodome
pyotp
python-crontab
python-dateutil
python-dotenv
qrcode # I.e. python311Packages . qrcode
redis # I.e. python311Packages . redis
requests
s3-tar
s3transfer
six
sqlparse
typing-extensions
urllib3
vine
webencodings
wrapt
yarl
] ;
in ''
installPhase = ''
runHook preInstall
mkdir -p $out/bin
@ -189,24 +139,10 @@ mkDerivation {
# Python dependencies
pythonDependencies="${ concatStringsSep " " pythonDependencies }"
for package in $pythonDependencies ; do
for directory in $( cd $package/lib/python3.11/site-packages ; find -mindepth 1 -type d -not -name __pycache__ ) ; do
mkdir -p $out/lib/python3.11/site-packages/$directory &
done
for dependency in "${ concatStringsSep " " simplePythonDependencies }" ; do
ln -sf $dependency/lib/python3.11/site-packages/* $out/lib/python3.11/site-packages/
done
wait
for package in $pythonDependencies ; do
for file in $( cd $package/lib/python3.11/site-packages ; find -type f -not -path \*__pycache__\* ) ; do
ln -s $package/lib/python3.11/site-packages/$file $out/lib/python3.11/site-packages/$file &
done
done
wait
# Python packages
cp -r $src/bookwyrm $out/lib/python3.11/site-packages/