Files
chia-blockchain/build_scripts/pyinstaller.spec
T
6d9219b0c4 CHIA-597: Use poetry for package management (#11057)
* preliminary setup with poetry

* don't worry about locking the poetry env for the exploration right now

* recover black config in pyproject.toml

* install.sh for linting workflow

* pull chiavdf version from poetry in install-timelord.sh

* activate etc in upload and lint workflow

* debug poetry show output on macos

* update to clvm-tools 0.4.4

* add back setproctitle

* catchup deps

* lock

* allow 3.10

* debug

* make Install.ps1 use poetry as well

* -ErrorAction Ignore

* more todo about python version selection

* make install-timelord.sh modifications more posix compliant

* gitignore .penv* and .venv* as well

* remove requirements.penv.txt

* get artifact check requirements from poetry

* fix .gitignore for venv symlink

* separate out poetry setup

* :

* comment out code to be worked on

* setup poetry for dependency check

* ignore new poetry symlink

* chia_rs==0.1.4

* a few updates

* some missed updates `:[`

* update some types libs

* fix extras

* activate

* just use `python` somewhere

* for windows

* less symlinking for windows

* oops

* s

* more

* # shellcheck disable=SC2086

* activate action

* more python version

* lock up

* include ipython (for python >=3.8)

* add miniupnpc extra

* add poetry-dynamic-versioning

* type it out

* better match dev versioning

* catch up and delete setup.py again

* lock

* add pytest-cov

* .penv/bin/poetry

* .venv for windows activation

* update pytest-xdist

* install upnp extra

* upnp

* quote

* maybe update some deps

* mandatory and string

* oops

* slighty tidy

* debug pip list

* debug

* pybind11 maybe instead?

* remove pip install debugging

* debug without upnp nor pypi.chia.net

* chiavdf==1.0.8

* bring back upnp

* re-enable upnp

* diagnostic exception reraise

* .exe?

* diagnostics

* .cmd...?

* light tidy

* more cleanup

* make dependency check script not cwd dependent for finding the poetry env

* correct sh substitution

* lock

* coverage 7

* todo cleanup

* poetry update

* interesting

* windows too

* support non-editable install via scripts again

* oops

* again

* sheesh

* fixup

* more

* more

* Update dependencies

* various pre-commit linter updates

* add pyupgrade to extras list

* use priority=supplemental instead of secondary

* Add in some missing deps

* update setuptools and pyinstaller to match main

* venv->.venv

* lint fixes

* update a few packages for 3.12 support

* get zstd from chia resource for python 3.12

* Adjustments to dynamic versioning

* experiments with versioning

* test fixes

Signed-off-by: Earle Lowe <e.lowe@chia.net>

* fixup last commit

* include upnp as extra when installing on windows

* include mozilla-ca as a package for the cacert.pem file

* some windows tweaks

* use SPECPATH as anchor path in pyinstaller.spec file

* Add lxml as dev dependency

* Fixup typo in lxml version

* Update some packages to resolve GH vuln reports

* Update more packages to resolve GH vulns

* Ignore pylint license in depedency checker

* match installation of the dynamic version plugin on windows

* Fix issues with setting windows environment and use pip to install plugin per poetry docs recommendation

* properly apply non-editable option with -i

* use -f with ln to remove existing file as needed

* use shell=true for subprocess to help windows run chia if it's a .cmd

* Update .coveragerc

* use shutil.which() to find chia executable in a cross platform way

* mypy fixes

* Address conflicts for numpy based on python version

* Update lock file

* Remove troublesome reference to pypi source

* Add TODOs for manual install of poetry-dynamic-versioning plugin

* Use poetry dynamic versioning to figure out the version rather than setuptools_scm

* Update .github/workflows/reflow-version.yml

Co-authored-by: Kyle Altendorf <sda@fstab.net>

* Update .github/workflows/test-single.yml

Co-authored-by: Kyle Altendorf <sda@fstab.net>

* Update urllib3

* Attempts to get dynamic versioning to output something semver

* more versioning finangling

* lint pyproject.toml

* Update certifi

---------

Signed-off-by: Earle Lowe <e.lowe@chia.net>
Co-authored-by: Earle Lowe <e.lowe@chia.net>
Co-authored-by: Earle Lowe <30607889+emlowe@users.noreply.github.com>
2024-07-10 08:47:11 -07:00

192 lines
4.6 KiB
RPMSpec

# -*- mode: python ; coding: utf-8 -*-
import importlib
import os
import pathlib
import platform
import sysconfig
from PyInstaller.utils.hooks import collect_submodules, copy_metadata
THIS_IS_WINDOWS = platform.system().lower().startswith("win")
THIS_IS_MAC = platform.system().lower().startswith("darwin")
ROOT = pathlib.Path(SPECPATH).absolute().parent
keyring_imports = collect_submodules("keyring.backends")
# keyring uses entrypoints to read keyring.backends from metadata file entry_points.txt.
keyring_datas = copy_metadata("keyring")[0]
version_data = [
copy_metadata(name)[0]
for name in ["chia-blockchain", "chiapos"]
]
block_cipher = None
SERVERS = [
"data_layer",
"wallet",
"full_node",
"harvester",
"farmer",
"introducer",
"timelord",
]
if THIS_IS_WINDOWS:
hidden_imports_for_windows = ["win32timezone", "win32cred", "pywintypes", "win32ctypes.pywin32"]
else:
hidden_imports_for_windows = []
hiddenimports = [
*collect_submodules("chia"),
*keyring_imports,
*hidden_imports_for_windows,
]
binaries = []
if os.path.exists(f"{ROOT}/madmax/chia_plot"):
binaries.extend([
(
f"{ROOT}/madmax/chia_plot",
"madmax"
)
])
if os.path.exists(f"{ROOT}/madmax/chia_plot_k34",):
binaries.extend([
(
f"{ROOT}/madmax/chia_plot_k34",
"madmax"
)
])
if os.path.exists(f"{ROOT}/bladebit/bladebit"):
binaries.extend([
(
f"{ROOT}/bladebit/bladebit",
"bladebit"
)
])
if os.path.exists(f"{ROOT}/bladebit/bladebit_cuda"):
binaries.extend([
(
f"{ROOT}/bladebit/bladebit_cuda",
"bladebit"
)
])
if THIS_IS_WINDOWS:
chia_mod = importlib.import_module("chia")
dll_paths = pathlib.Path(sysconfig.get_path("platlib")) / "*.dll"
binaries = [
(
dll_paths,
".",
),
(
"C:\\Windows\\System32\\msvcp140.dll",
".",
),
(
"C:\\Windows\\System32\\vcruntime140_1.dll",
".",
),
(
f"{ROOT}\\madmax\\chia_plot.exe",
"madmax"
),
(
f"{ROOT}\\madmax\\chia_plot_k34.exe",
"madmax"
),
(
f"{ROOT}\\bladebit\\bladebit.exe",
"bladebit"
),
(
f"{ROOT}\\bladebit\\bladebit_cuda.exe",
"bladebit"
),
]
datas = []
datas.append((f"{ROOT}/chia/util/english.txt", "chia/util"))
datas.append((f"{ROOT}/chia/util/initial-config.yaml", "chia/util"))
for path in sorted({path.parent for path in ROOT.joinpath("chia").rglob("*.hex")}):
datas.append((f"{path}/*.hex", path.relative_to(ROOT)))
datas.append((f"{ROOT}/chia/ssl/*", "chia/ssl"))
datas.append((f"{ROOT}/mozilla-ca/*", "mozilla-ca"))
datas.extend(version_data)
pathex = []
def add_binary(name, path_to_script, collect_args):
analysis = Analysis(
[path_to_script],
pathex=pathex,
binaries=binaries,
datas=datas,
hiddenimports=hiddenimports,
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
binary_pyz = PYZ(analysis.pure, analysis.zipped_data, cipher=block_cipher)
binary_exe = EXE(
binary_pyz,
analysis.scripts,
[],
exclude_binaries=True,
name=name,
debug=False,
bootloader_ignore_signals=False,
strip=False,
)
collect_args.extend(
[
binary_exe,
analysis.binaries,
analysis.zipfiles,
analysis.datas,
]
)
COLLECT_ARGS = []
add_binary("chia", f"{ROOT}/chia/cmds/chia.py", COLLECT_ARGS)
add_binary("daemon", f"{ROOT}/chia/daemon/server.py", COLLECT_ARGS)
for server in SERVERS:
add_binary(f"start_{server}", f"{ROOT}/chia/server/start_{server}.py", COLLECT_ARGS)
add_binary("start_crawler", f"{ROOT}/chia/seeder/start_crawler.py", COLLECT_ARGS)
add_binary("start_seeder", f"{ROOT}/chia/seeder/dns_server.py", COLLECT_ARGS)
add_binary("start_data_layer_http", f"{ROOT}/chia/data_layer/data_layer_server.py", COLLECT_ARGS)
add_binary("start_data_layer_s3_plugin", f"{ROOT}/chia/data_layer/s3_plugin_service.py", COLLECT_ARGS)
add_binary("timelord_launcher", f"{ROOT}/chia/timelord/timelord_launcher.py", COLLECT_ARGS)
COLLECT_KWARGS = dict(
strip=False,
upx_exclude=[],
name="daemon",
)
coll = COLLECT(*COLLECT_ARGS, **COLLECT_KWARGS)