Skip to content

Commit 8c1399c

Browse files
committed
Refactor build process to streamline setup and improve cross-platform compatibility
1 parent 0e19258 commit 8c1399c

File tree

5 files changed

+73
-36
lines changed

5 files changed

+73
-36
lines changed

.github/workflows/build_app.yaml

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,6 @@ jobs:
127127
with:
128128
submodules: recursive
129129

130-
- name: Install system dependencies
131-
run: |
132-
sudo apt-get update
133-
sudo apt-get install git build-essential libxmu-dev libxi-dev libgl-dev libglew-dev libpng-dev libfreetype6-dev libxml2-dev libmsgpack-dev libglm-dev libnetcdf-dev linux-libc-dev autoconf perl
134-
135-
- name: Initialize vcpkg
136-
run: |
137-
git clone https://github.com/Microsoft/vcpkg.git vendor/vcpkg
138-
139130
- name: Setup Python 3.11
140131
uses: actions/setup-python@v5
141132
with:
@@ -145,30 +136,16 @@ jobs:
145136
run: |
146137
python -m venv .venv
147138
source .venv/bin/activate
148-
python -m pip install wheel setuptools cibuildwheel
139+
python -m pip install wheel setuptools
149140
python -m pip install -r requirements.txt
150141
151-
- name: Bootstrap vcpkg
152-
run: ${{ env.VCPKG_ROOT }}/bootstrap-vcpkg.sh -disableMetrics
153-
154-
- name: Install vcpkg dependencies
155-
run: |
156-
${{ env.VCPKG_ROOT }}/vcpkg install
157-
158-
- name: Last build environment setup steps
159-
run: |
160-
source .venv/bin/activate
161-
python automations/my_automator.py setup dev-env
162-
163-
- name: Build C extension
142+
- name: Build app package
164143
run: |
165-
source .venv/bin/activate
166-
python automations/my_automator.py setup dev-env
167-
cibuildwheel .
144+
./automator.sh build app
168145
169146
- name: Upload artifact
170147
uses: actions/upload-artifact@v4
171148
with:
172-
name: PyMOL-wheel-GNU-Linux-3.11
173-
path: ./wheelhouse/*.whl
149+
name: Open-Source-PyMOL-GNU-Linux-3.11-Setup
150+
path: ./dist/exe.linux*
174151
# --- end

automations/build_exe.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def setup_build_environment(self) -> None:
7878
def setup_based_build(self) -> None:
7979
"""Uses the cx_freeze setup.py for the build process."""
8080
self.setup_build_environment()
81-
if const.WIN32:
81+
if const.WIN32 or const.__linux__:
8282
subprocess.run(
8383
[const.PYTHON_EXECUTABLE, self.build_script_filepath, "build_exe"],
8484
stdout=sys.stdout, stderr=sys.stderr, text=True, cwd=const.OS_SPECIFIC_DIR
@@ -88,7 +88,8 @@ def setup_based_build(self) -> None:
8888
[const.PYTHON_EXECUTABLE, self.build_script_filepath, "bdist_mac"],
8989
stdout=sys.stdout, stderr=sys.stderr, text=True, cwd=const.OS_SPECIFIC_DIR
9090
)
91-
91+
else:
92+
const.invalid_platform()
9293
shutil.copytree(self.build_dir, pathlib.Path(const.PROJECT_ROOT_DIR / "dist"),
9394
dirs_exist_ok=True)
9495

os_specific/linux/logo.png

191 KB
Loading
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import sys
2+
import pathlib
3+
4+
import toml
5+
from cx_Freeze import setup
6+
7+
from automations.const import OS_SPECIFIC_DIR
8+
9+
10+
# <editor-fold desc="Module constants">
11+
PROJECT_ROOT_DIR = pathlib.Path(__file__).parent.parent.parent
12+
PYTHON_VERSION = f"{sys.version_info.major}.{sys.version_info.minor}"
13+
PYMOL_PACKAGE_DIR = pathlib.Path(PROJECT_ROOT_DIR / f".venv/lib/python{PYTHON_VERSION}/site-packages/pymol")
14+
15+
tmp_pyproject_toml = toml.load(
16+
str(pathlib.Path(PROJECT_ROOT_DIR / "pyproject.toml"))
17+
)
18+
PROJECT_NAME = tmp_pyproject_toml["project"]["name"]
19+
PROJECT_VERSION = tmp_pyproject_toml["project"]["version"]
20+
21+
SHARED_SUFFIX = f".cpython-{PYTHON_VERSION.replace('.', '')}-x86_64-linux-gnu.so"
22+
# </editor-fold>
23+
24+
25+
build_exe_options = {
26+
"includes": [
27+
"copy",
28+
"encodings",
29+
"PyQt5.uic",
30+
"pymol.povray",
31+
"pymol.parser",
32+
"uuid"
33+
],
34+
"include_files": [
35+
(
36+
pathlib.Path(PYMOL_PACKAGE_DIR / f"_cmd{SHARED_SUFFIX}"),
37+
f"./lib/pymol/_cmd{SHARED_SUFFIX}"
38+
)
39+
]
40+
}
41+
42+
43+
setup(
44+
name="Open-Source-PyMOL",
45+
version=PROJECT_VERSION,
46+
options={
47+
"build_exe": build_exe_options
48+
},
49+
executables=[
50+
{
51+
"target_name": "Open-Source-PyMOL",
52+
"script": pathlib.Path(PYMOL_PACKAGE_DIR / "startup_wrapper.py"),
53+
"base": "gui",
54+
"icon": pathlib.Path(OS_SPECIFIC_DIR / "logo.png"),
55+
}
56+
],
57+
)

os_specific/macos/setup_build_exe.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@
77
from automations.const import OS_SPECIFIC_DIR
88

99
# <editor-fold desc="Module constants">
10-
tmp_pyproject_toml = toml.load("../pyproject.toml")
10+
PROJECT_ROOT_DIR = pathlib.Path(__file__).parent.parent.parent
11+
PYTHON_VERSION = f"{sys.version_info.major}.{sys.version_info.minor}"
12+
PYMOL_PACKAGE_DIR = pathlib.Path(PROJECT_ROOT_DIR / f".venv/lib/python{PYTHON_VERSION}/site-packages/pymol")
13+
14+
tmp_pyproject_toml = toml.load(
15+
str(pathlib.Path(PROJECT_ROOT_DIR / "pyproject.toml"))
16+
)
1117
PROJECT_NAME = tmp_pyproject_toml["project"]["name"]
1218
PROJECT_VERSION = tmp_pyproject_toml["project"]["version"]
1319

14-
PYTHON_VERSION = f"{sys.version_info.major}.{sys.version_info.minor}"
15-
SHARED_SUFFIX = f".cpython-{PYTHON_VERSION.replace('.', '')}-darwin.so" # TODO: Check if this is correct
16-
17-
PROJECT_ROOT_DIR = pathlib.Path(__file__).parent.parent.parent
18-
PYMOL_PACKAGE_DIR = pathlib.Path(PROJECT_ROOT_DIR / f".venv/lib/python{PYTHON_VERSION}/site-packages/pymol")
20+
SHARED_SUFFIX = f".cpython-{PYTHON_VERSION.replace('.', '')}-darwin.so"
1921
# </editor-fold>
2022

2123

0 commit comments

Comments
 (0)