Loading python/deployment/pyinstaller.yml 0 → 100644 +102 −0 Original line number Diff line number Diff line --- # First create a .spec file locally using `pyi-makespec --onefile`, and commit it to your repo. # Point PYINSTALLER_TARGET to that file. Defaults to "main.spec". include: - local: python/generic.yml variables: PYINSTALLER_EXTRA_ARGS: "" PYINSTALLER_TARGET: main.spec PYINSTALLER_WINDOWS_PYVERSION: "" # Needs to be a Chocolatey installable version, i.e. 3.10.8 PYINSTALLER_WINDOWS_CHOCO_EXTRA_ARGS: "" .python:pyinstaller: stage: build extends: .python:pre variables: JOB_PACKAGE: pyinstaller script: - pip install -q --log=${CI_PROJECT_DIR}/pip-log.txt ${JOB_PACKAGE} - pip install -q --log=${CI_PROJECT_DIR}/pip-log.txt ${PYTHON_CONTEXT} - | echo "[*] Job info:" echo "Target: ${PYINSTALLER_TARGET}" echo "Job extra args: ${PYINSTALLER_EXTRA_ARGS}" artifacts: paths: - build - dist - pip-log.txt when: always # rules: # Reenable when this one is released: https://gitlab.com/gitlab-org/gitlab/-/issues/283881 # - exists: # - $PYINSTALLER_TARGET # This doesn't use a container image as shared runners use virtual machines python:pyinstaller:windows: extends: .python:pyinstaller script: - | If (${PYINSTALLER_WINDOWS_PYVERSION}) { ${PYINSTALLER_WINDOWS_CHOCO_EXTRA_ARGS}+=" --version=${PYINSTALLER_WINDOWS_PYVERSION}" } - choco install -y python --no-progress ${PYINSTALLER_WINDOWS_CHOCO_EXTRA_ARGS}.Split() - $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") - wget https://github.com/upx/upx/releases/download/v4.0.1/upx-4.0.1-win64.zip -OutFile upx.zip - Expand-Archive upx.zip C:\ - mv C:\upx* C:\upx - If (-Not ${PYTHON_CONTEXT}) { ${PYTHON_CONTEXT}="." } - pip install -q --log=${CI_PROJECT_DIR}/pip-log.txt wheel - !reference [".python:pyinstaller", script] - pyinstaller "${PYINSTALLER_TARGET}" ${PYINSTALLER_EXTRA_ARGS}.Split() --upx-dir C:\upx - | if (-Not "${PWD}" -eq "${CI_PROJECT_DIR}") { echo "[*] Moving output files to job root dir." cp -r build ${CI_PROJECT_DIR}\ cp -r dist ${CI_PROJECT_DIR}\ } - ${OUTPUT}=Resolve-Path -Relative dist\*.exe | % {$_ -replace "\\","/"} | Out-String - | echo "Executable: ${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/${OUTPUT}" tags: - shared-windows python:pyinstaller:linux: extends: .python:pyinstaller script: - | echo "[*] Installing binutils and upx using OS package manager..." if command -v apk > /dev/null; then apk add -q binutils upx elif command -v apt-get > /dev/null;then apt-get update -qq && apt-get install -qqy binutils upx else echo "[!] Can't install binutils and upx because neither apk nor apt-get is available. The job will probably fail." fi - PYTHON_CONTEXT=${PYTHON_CONTEXT:=.} - !reference [".python:pyinstaller", script] - pyinstaller "${PYINSTALLER_TARGET}" ${PYINSTALLER_EXTRA_ARGS} - | if [ "${PWD}" != "${CI_PROJECT_DIR}" ]; then cp -r build dist ${CI_PROJECT_DIR}/ fi - | echo "Executable: ${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/$(find dist -executable -type f)" # python:pyinstaller:check: # Reenable when this one is released: https://gitlab.com/gitlab-org/gitlab/-/issues/283881 # extends: .python:pyinstaller # script: # - echo "[!] $PYINSTALLER_TARGET does not exist. Create it using 'pyi-makespec'." # - exit 1 # artifacts: null # rules: # - exists: # - $PYINSTALLER_TARGET # when: never tests/jobs/python.yml +11 −0 Original line number Diff line number Diff line --- include: - local: python/collections/all.yml - local: python/deployment/pyinstaller.yml - local: project-automation/workflow.yml variables: PYTHON_CONTEXT: tests/mockup_projects/python/pep518 PYINSTALLER_TARGET: tests/mockup_projects/python/pep518/mymodule.spec python:build:setuptools: extends: python:build Loading @@ -14,3 +16,12 @@ python:build:setuptools: python:twine: rules: - when: never # This one takes about 5 minutes each time, so only test it when we change the job or its dependencies python:pyinstaller:windows: rules: - changes: - python/deployment/pyinstaller.yml - python/generic.yml # exists: # Reenable when this one is released: https://gitlab.com/gitlab-org/gitlab/-/issues/283881 # - $PYINSTALLER_TARGET tests/mockup_projects/python/pep518/mymodule.spec 0 → 100644 +44 −0 Original line number Diff line number Diff line # -*- mode: python ; coding: utf-8 -*- block_cipher = None a = Analysis( ['mypackage518/mymodule.py'], pathex=[], binaries=[], datas=[], hiddenimports=[], hookspath=[], hooksconfig={}, runtime_hooks=[], excludes=[], win_no_prefer_redirects=False, win_private_assemblies=False, cipher=block_cipher, noarchive=False, ) pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) exe = EXE( pyz, a.scripts, a.binaries, a.zipfiles, a.datas, [], name='mymodule', debug=False, bootloader_ignore_signals=False, strip=False, upx=True, upx_exclude=[], runtime_tmpdir=None, console=True, disable_windowed_traceback=False, argv_emulation=False, target_arch=None, codesign_identity=None, entitlements_file=None, ) tests/mockup_projects/python/pep518/mypackage518/mymodule.py +4 −0 Original line number Diff line number Diff line Loading @@ -18,3 +18,7 @@ def too_complicated() -> None: for i in range(1000): print("was this really necessary??") print("I guess it was") if __name__ == "__main__": print("Hello, World!") tests/mockup_projects/python/pep518/poetry.lock +350 −350 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
python/deployment/pyinstaller.yml 0 → 100644 +102 −0 Original line number Diff line number Diff line --- # First create a .spec file locally using `pyi-makespec --onefile`, and commit it to your repo. # Point PYINSTALLER_TARGET to that file. Defaults to "main.spec". include: - local: python/generic.yml variables: PYINSTALLER_EXTRA_ARGS: "" PYINSTALLER_TARGET: main.spec PYINSTALLER_WINDOWS_PYVERSION: "" # Needs to be a Chocolatey installable version, i.e. 3.10.8 PYINSTALLER_WINDOWS_CHOCO_EXTRA_ARGS: "" .python:pyinstaller: stage: build extends: .python:pre variables: JOB_PACKAGE: pyinstaller script: - pip install -q --log=${CI_PROJECT_DIR}/pip-log.txt ${JOB_PACKAGE} - pip install -q --log=${CI_PROJECT_DIR}/pip-log.txt ${PYTHON_CONTEXT} - | echo "[*] Job info:" echo "Target: ${PYINSTALLER_TARGET}" echo "Job extra args: ${PYINSTALLER_EXTRA_ARGS}" artifacts: paths: - build - dist - pip-log.txt when: always # rules: # Reenable when this one is released: https://gitlab.com/gitlab-org/gitlab/-/issues/283881 # - exists: # - $PYINSTALLER_TARGET # This doesn't use a container image as shared runners use virtual machines python:pyinstaller:windows: extends: .python:pyinstaller script: - | If (${PYINSTALLER_WINDOWS_PYVERSION}) { ${PYINSTALLER_WINDOWS_CHOCO_EXTRA_ARGS}+=" --version=${PYINSTALLER_WINDOWS_PYVERSION}" } - choco install -y python --no-progress ${PYINSTALLER_WINDOWS_CHOCO_EXTRA_ARGS}.Split() - $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") - wget https://github.com/upx/upx/releases/download/v4.0.1/upx-4.0.1-win64.zip -OutFile upx.zip - Expand-Archive upx.zip C:\ - mv C:\upx* C:\upx - If (-Not ${PYTHON_CONTEXT}) { ${PYTHON_CONTEXT}="." } - pip install -q --log=${CI_PROJECT_DIR}/pip-log.txt wheel - !reference [".python:pyinstaller", script] - pyinstaller "${PYINSTALLER_TARGET}" ${PYINSTALLER_EXTRA_ARGS}.Split() --upx-dir C:\upx - | if (-Not "${PWD}" -eq "${CI_PROJECT_DIR}") { echo "[*] Moving output files to job root dir." cp -r build ${CI_PROJECT_DIR}\ cp -r dist ${CI_PROJECT_DIR}\ } - ${OUTPUT}=Resolve-Path -Relative dist\*.exe | % {$_ -replace "\\","/"} | Out-String - | echo "Executable: ${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/${OUTPUT}" tags: - shared-windows python:pyinstaller:linux: extends: .python:pyinstaller script: - | echo "[*] Installing binutils and upx using OS package manager..." if command -v apk > /dev/null; then apk add -q binutils upx elif command -v apt-get > /dev/null;then apt-get update -qq && apt-get install -qqy binutils upx else echo "[!] Can't install binutils and upx because neither apk nor apt-get is available. The job will probably fail." fi - PYTHON_CONTEXT=${PYTHON_CONTEXT:=.} - !reference [".python:pyinstaller", script] - pyinstaller "${PYINSTALLER_TARGET}" ${PYINSTALLER_EXTRA_ARGS} - | if [ "${PWD}" != "${CI_PROJECT_DIR}" ]; then cp -r build dist ${CI_PROJECT_DIR}/ fi - | echo "Executable: ${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/$(find dist -executable -type f)" # python:pyinstaller:check: # Reenable when this one is released: https://gitlab.com/gitlab-org/gitlab/-/issues/283881 # extends: .python:pyinstaller # script: # - echo "[!] $PYINSTALLER_TARGET does not exist. Create it using 'pyi-makespec'." # - exit 1 # artifacts: null # rules: # - exists: # - $PYINSTALLER_TARGET # when: never
tests/jobs/python.yml +11 −0 Original line number Diff line number Diff line --- include: - local: python/collections/all.yml - local: python/deployment/pyinstaller.yml - local: project-automation/workflow.yml variables: PYTHON_CONTEXT: tests/mockup_projects/python/pep518 PYINSTALLER_TARGET: tests/mockup_projects/python/pep518/mymodule.spec python:build:setuptools: extends: python:build Loading @@ -14,3 +16,12 @@ python:build:setuptools: python:twine: rules: - when: never # This one takes about 5 minutes each time, so only test it when we change the job or its dependencies python:pyinstaller:windows: rules: - changes: - python/deployment/pyinstaller.yml - python/generic.yml # exists: # Reenable when this one is released: https://gitlab.com/gitlab-org/gitlab/-/issues/283881 # - $PYINSTALLER_TARGET
tests/mockup_projects/python/pep518/mymodule.spec 0 → 100644 +44 −0 Original line number Diff line number Diff line # -*- mode: python ; coding: utf-8 -*- block_cipher = None a = Analysis( ['mypackage518/mymodule.py'], pathex=[], binaries=[], datas=[], hiddenimports=[], hookspath=[], hooksconfig={}, runtime_hooks=[], excludes=[], win_no_prefer_redirects=False, win_private_assemblies=False, cipher=block_cipher, noarchive=False, ) pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) exe = EXE( pyz, a.scripts, a.binaries, a.zipfiles, a.datas, [], name='mymodule', debug=False, bootloader_ignore_signals=False, strip=False, upx=True, upx_exclude=[], runtime_tmpdir=None, console=True, disable_windowed_traceback=False, argv_emulation=False, target_arch=None, codesign_identity=None, entitlements_file=None, )
tests/mockup_projects/python/pep518/mypackage518/mymodule.py +4 −0 Original line number Diff line number Diff line Loading @@ -18,3 +18,7 @@ def too_complicated() -> None: for i in range(1000): print("was this really necessary??") print("I guess it was") if __name__ == "__main__": print("Hello, World!")
tests/mockup_projects/python/pep518/poetry.lock +350 −350 File changed.Preview size limit exceeded, changes collapsed. Show changes