Skip to content

Commit

Permalink
adding building with pyproject
Browse files Browse the repository at this point in the history
  • Loading branch information
pp-amaskaev authored and ye11owSub committed Aug 6, 2024
1 parent 03d7a7f commit 51b0bc4
Show file tree
Hide file tree
Showing 4 changed files with 492 additions and 250 deletions.
17 changes: 9 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
python3-numpy
python3-pil
python3-pytest
python3-pip
- name: Install collada2gltf
run: |
Expand All @@ -43,13 +44,13 @@ jobs:
- name: Build
run: |
python setup.py --testing install --prefix=install-prefix
pip install -v --config-settings testing=True .
env:
DEBUG: 1

- name: Test
run: |
./install-prefix/bin/pymol -ckqy testing/testing.py --run all
pymol -ckqy testing/testing.py --run all
build-Windows:

Expand All @@ -72,7 +73,7 @@ jobs:
shell: cmd
run: |-
CALL %CONDA_ROOT%\\Scripts\\activate.bat
conda install -y -c conda-forge -c schrodinger python cmake libpng freetype pyqt glew libxml2 numpy=1.26.4 catch2=2.13.3 glm libnetcdf collada2gltf biopython pillow msgpack-python pytest
conda install -y -c conda-forge -c schrodinger python cmake libpng freetype pyqt glew libxml2 numpy=1.26.4 catch2=2.13.3 glm libnetcdf collada2gltf biopython pillow msgpack-python pytest pip python-build
- name: Conda info
shell: cmd
Expand All @@ -92,13 +93,13 @@ jobs:
shell: cmd
run: |
CALL %CONDA_ROOT%\\Scripts\\activate.bat
python setup.py --testing install --prefix=%GITHUB_WORKSPACE%\\install-prefix
pip install -v --config-settings testing=True .
- name: Test
shell: cmd
run: |
CALL %CONDA_ROOT%\\Scripts\\activate.bat
%GITHUB_WORKSPACE%\\install-prefix\\Scripts\\pymol.bat -ckqy testing\\testing.py --run all
pymol.bat -ckqy testing\\testing.py --run all
build-MacOS:

Expand All @@ -115,7 +116,7 @@ jobs:
bash $CONDA_ROOT.sh -b -p $CONDA_ROOT
export PATH="$CONDA_ROOT/bin:$PATH"
conda config --set quiet yes
conda install -y -c conda-forge -c schrodinger python cmake libpng freetype pyqt glew libxml2 numpy=1.26.4 catch2=2.13.3 glm libnetcdf collada2gltf biopython pillow msgpack-python pytest
conda install -y -c conda-forge -c schrodinger python cmake libpng freetype pyqt glew libxml2 numpy=1.26.4 catch2=2.13.3 glm libnetcdf collada2gltf biopython pillow msgpack-python pytest pip python-build
conda info
- name: Get additional sources
Expand All @@ -129,9 +130,9 @@ jobs:
run: |-
export MACOSX_DEPLOYMENT_TARGET=12.0
export PATH="$CONDA_ROOT/bin:$PATH"
python setup.py install --prefix=${GITHUB_WORKSPACE}/install-prefix
pip install -v --config-settings testing=True .
- name: Test
run: |-
export PATH="$CONDA_ROOT/bin:$PATH"
${GITHUB_WORKSPACE}/install-prefix/bin/pymol -ckqy testing/testing.py --run all
pymol -ckqy testing/testing.py --run all
36 changes: 36 additions & 0 deletions _custom_build/backend.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Adopted from pillow and pycapnp

import sys

from setuptools.build_meta import build_wheel

backend_class = build_wheel.__self__.__class__


class _CustomBuildMetaBackend(backend_class):
def run_setup(self, setup_script="setup.py"):
if self.config_settings:
flags = [
f"--{k}={v}"
for k, v in self.config_settings.items()
]
sys.argv = sys.argv[:1] + ["build_ext"] + flags + sys.argv[1:]
return super().run_setup(setup_script)

def build_wheel(
self, wheel_directory, config_settings=None, metadata_directory=None
):
self.config_settings = config_settings
return super().build_wheel(wheel_directory, config_settings, metadata_directory)

def build_editable(
self, wheel_directory, config_settings=None, metadata_directory=None
):
self.config_settings = config_settings
return super().build_editable(
wheel_directory, config_settings, metadata_directory
)

_backend = _CustomBuildMetaBackend()
build_wheel = _backend.build_wheel
build_editable = _backend.build_editable
49 changes: 49 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
[project]
name = "pymol"
readme = "README.md"
requires-python = ">=3.9"
dynamic=["version"]
license = {file = "LICENSE"}
description = """
PyMOL is a Python-enhanced molecular graphics tool.
It excels at 3D visualization of proteins, small molecules, density,
surfaces, and trajectories. It also includes molecular editing,
ray tracing, and movies. Open Source PyMOL is free to everyone!
"""
authors = [
{name = "Schrodinger", email = "[email protected]"},
]
dependencies = [
"numpy>=1.26.4,<2",
]

[build-system]
build-backend = "backend"
backend-path = ["_custom_build"]
requires = [
"numpy>=1.26.4,<2",
"setuptools>=69.2.0",
]

[project.optional-dependencies]
test = [
"pillow==10.3.0",
"pytest==8.2.2",
]

[project.urls]
Homepage = "https://pymol.org"
Documentation = "https://pymol.org/dokuwiki"
Repository = "https://github.com/schrodinger/pymol-open-source"
"Bug Tracker" = "https://github.com/schrodinger/pymol-open-source/issues"
Changelog = "https://github.com/schrodinger/pymol-open-source/blob/master/ChangeLog"

[project.scripts]
pymol = "pymol:launch"

[tool.setuptools.packages.find]
where = ["modules"]

[tool.setuptools.package-data]
pmg_qt = ["forms/*.ui"]

Loading

0 comments on commit 51b0bc4

Please sign in to comment.