Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding building with pyproject.toml #375

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 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,14 @@ jobs:

- name: Build
run: |
python setup.py --testing install --prefix=install-prefix
pip install --upgrade pip
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 +74,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 +94,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 -ckqy testing\\testing.py --run all

build-MacOS:

Expand All @@ -115,7 +117,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 +131,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