diff --git a/README.md b/README.md index 949751f..ab7c83d 100644 --- a/README.md +++ b/README.md @@ -55,12 +55,15 @@ if __name__ == '__main__': The sources are hosted on [GitHub](https://github.com/fredboudon/PyQGLViewer). -To create a conda environment with all dependencies: +To create and activate a conda environment with all dependencies, using `environment-linux.yml`, `environment-macos.yml` or `environment-windows.yml` for your platform: ``` -conda env create -f environment.yml +conda env create -f environment-linux.yml +conda activate qglviewer ``` +macOS also requires the Xcode Command Line Tools, and Windows Visual Studio 2022 with the C++ tools. + To build and install the project: ``` diff --git a/conda/bld.bat b/conda/bld.bat deleted file mode 100644 index d6c2b4c..0000000 --- a/conda/bld.bat +++ /dev/null @@ -1 +0,0 @@ -sip-install --verbose diff --git a/conda/build.sh b/conda/build.sh deleted file mode 100644 index 604d590..0000000 --- a/conda/build.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - -# Inspired from https://github.com/conda-forge/pyqt-feedstock/tree/main/recipe - -if [ "$(uname)" == "Linux" ]; -then - USED_BUILD_PREFIX=${BUILD_PREFIX:-${PREFIX}} - - ln -s ${GXX} g++ || true - ln -s ${GCC} gcc || true - ln -s ${USED_BUILD_PREFIX}/bin/${HOST}-gcc-ar gcc-ar || true - - export LD=${GXX} - export CC=${GCC} - export CXX=${GXX} - export PKG_CONFIG_EXECUTABLE=$(basename $(which pkg-config)) - - export PATH=${PWD}:${PATH} -fi - - -echo "**** BUILD" -sip-install --verbose - -echo -echo "****** CHECK PYTHON LIB" - -# To check if Python lib is not in the dependencies with conda-forge distribution. -# See https://github.com/conda-forge/boost-feedstock/issues/81 -if [ `uname` = "Darwin" ]; then - otool -L `${PYTHON} -c "import PyQGLViewer as pyqgl ; print(pyqgl.__file__)"` -fi - - -if [ "$(uname)" == "Linux" ]; -then - ldd `${PYTHON} -c "import PyQGLViewer as pyqgl ; print(pyqgl.__file__)"` - -fi -echo "****** END OF BUILD PROCESS" diff --git a/conda/meta.yaml b/conda/meta.yaml index 545a1ed..5b67a99 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -16,50 +16,50 @@ about: build: number: 2 - string: py{{ PY_VER }} + script: + - readlink -f "$(which g++)" # [linux] + - g++ --version # [linux] + - sip-install --verbose script_env: - SETUPTOOLS_SCM_PRETEND_VERSION requirements: build: - - {{ compiler('cxx')}} + - {{ compiler('cxx') }} + - {{ stdlib('c') }} + # on linux qmake calls g++ by its plain name, that compiler('cxx') does not provide + - gxx # [linux] - make # [unix] - - pkg-config # [linux] - - {{ cdt('mesa-libgl-devel') }} # [linux] # match libqglviewer CDT GL strategy - # from https://conda-forge.org/docs/maintainer/knowledge_base.html#libgl - - python # [build_platform != target_platform] - - sip # [build_platform != target_platform] - - pyqt-builder # [build_platform != target_platform] + - pkg-config # [unix] host: - python - pip - - qt-main + - sip<=6.10 - pyqt - - libqglviewer - - sip - pyqt5-sip - - pyqt-builder - - {{ cdt('mesa-libgl-devel') }} # [linux] - - libxcb # [linux] - - pthread-stubs # [linux] + - pyqt-builder 1.18.* + - packaging + - qt-main + - libqglviewer + - libgl-devel # [linux] - xorg-libxfixes # [linux] - run: - python - - {{ pin_compatible('pyqt', max_pin='x.x') }} - - {{ pin_compatible('libqglviewer', max_pin='x.x') }} + - pyqt + - libqglviewer - pyopengl - xorg-libxfixes # [linux] test: - requires: # [unix] - - pytest # [unix] - - pytest-qt # [unix] - - pytest-xvfb # [unix] + requires: + - pytest + - pytest-qt + - pytest-xvfb # [linux] imports: - PyQGLViewer - source_files: # [unix] - - test/*.py # [unix] - commands: # [unix] - - pytest -v # [unix] + source_files: + - test/*.py + commands: + - set QT_QPA_PLATFORM=offscreen # [win] + - pytest -v diff --git a/environment-linux.yml b/environment-linux.yml new file mode 100644 index 0000000..4a190e1 --- /dev/null +++ b/environment-linux.yml @@ -0,0 +1,32 @@ +# Linux developer environment, mirroring conda/meta.yaml. +# Versions follow conda-forge. Only sip and pyqt-builder are pinned as in the +# recipe, and sysroot as in conda-forge-pinning. +name: qglviewer +channels: + - conda-forge +dependencies: + # compiler('cxx') and stdlib('c') from the recipe. cxx-compiler provides g++ + # without target prefix, as called by qmake (gxx in the recipe does the same). + # g++ finds this sysroot by itself. + - cxx-compiler + - sysroot_linux-64=2.17 + - make + - pkg-config + # host + - python + - pip + - sip<=6.10 + - pyqt + - pyqt5-sip + - pyqt-builder=1.18.* + - packaging + - qt-main + - libqglviewer + - libgl-devel + - xorg-libxfixes + # run + - pyopengl + # test + - pytest + - pytest-qt + - pytest-xvfb diff --git a/environment-macos.yml b/environment-macos.yml new file mode 100644 index 0000000..d1926e2 --- /dev/null +++ b/environment-macos.yml @@ -0,0 +1,30 @@ +# macOS developer environment (Intel and Apple Silicon), mirroring conda/meta.yaml. +# Versions follow conda-forge. Only sip and pyqt-builder are pinned as in the +# recipe. +# +# Xcode Command Line Tools are required: qmake gets the SDK path from xcrun. +name: qglviewer +channels: + - conda-forge +dependencies: + # clang++ as called by qmake. The clangxx_osx-* wrappers of compiler('cxx') + # are arch specific and only set env flags, that qmake does not read. + - cxx-compiler + - make + - pkg-config + # host + - python + - pip + - sip<=6.10 + - pyqt + - pyqt5-sip + - pyqt-builder=1.18.* + - packaging + - qt-main + - libqglviewer + # run + - pyopengl + # test + - pytest + - pytest-qt + - pytest-xvfb diff --git a/environment-windows.yml b/environment-windows.yml new file mode 100644 index 0000000..696ce73 --- /dev/null +++ b/environment-windows.yml @@ -0,0 +1,27 @@ +# Windows developer environment, mirroring conda/meta.yaml. +# Versions follow conda-forge. Only sip and pyqt-builder are pinned as in the +# recipe. +# +# Visual Studio 2022 with the C++ tools is required: activation of the env sets +# up its compiler and nmake. +name: qglviewer +channels: + - conda-forge +dependencies: + # compiler('cxx') from the recipe + - cxx-compiler + # host + - python + - pip + - sip<=6.10 + - pyqt + - pyqt5-sip + - pyqt-builder=1.18.* + - packaging + - qt-main + - libqglviewer + # run + - pyopengl + # test + - pytest + - pytest-qt diff --git a/environment.yml b/environment.yml deleted file mode 100644 index 9744c67..0000000 --- a/environment.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: qglviewer -channels: - - conda-forge -dependencies: - - python - - pip - - qt-main - - pyqt - - libqglviewer - - sip - - pyqt5-sip - - xorg-libxfixes # [linux] - - pyqt-builder diff --git a/project.py b/project.py index 77dd049..f0eda41 100644 --- a/project.py +++ b/project.py @@ -19,13 +19,13 @@ import os +import platform +import subprocess from pyqtbuild import PyQtBindings, PyQtProject def determine_pyqglviewer_version(): - import os, subprocess - version = os.environ.get("SETUPTOOLS_SCM_PRETEND_VERSION",None) if version is None: try: @@ -68,28 +68,20 @@ def __init__(self, project): print("Instanciation of the PyQGLViewerBindings ") def apply_user_defaults(self, tool): - import platform, os - - CONDA_PREFIX = os.environ.get('CONDA_PREFIX',None) - PREFIX = os.environ.get('PREFIX',None) - CONDA_BUILD_SYSROOT = os.environ.get('CONDA_BUILD_SYSROOT',None) - - if platform.system() in ['Darwin','Linux'] : + system = platform.system() + prefix = os.environ.get("PREFIX") or os.environ.get("CONDA_PREFIX") + + if system in ('Darwin','Linux') : self.libraries.append('QGLViewer') - if not CONDA_PREFIX is None: - self.include_dirs.append(f'{CONDA_PREFIX}/include') - self.library_dirs.append(f'{CONDA_PREFIX}/lib') - if not PREFIX is None: - self.include_dirs.append(f'{PREFIX}/include') - self.library_dirs.append(f'{PREFIX}/lib') - - if platform.system() == 'Linux': + if prefix: + self.include_dirs.append(f'{prefix}/include') + self.library_dirs.append(f'{prefix}/lib') + + if system == 'Linux': self.libraries.append('GLU') - if not CONDA_BUILD_SYSROOT is None : - self.include_dirs.append(f'{CONDA_BUILD_SYSROOT}/usr/include') - elif platform.system() == 'Windows': + elif system == 'Windows': self.libraries.append('QGLViewer2') self.libraries.append('opengl32') self.libraries.append('glu32') diff --git a/pyproject.toml b/pyproject.toml index 9b3ae39..cac2451 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ # Specify the build system. [build-system] # "setuptools", "setuptools-scm" not used -requires = ["sip", "PyQt-builder"] +requires = ["sip<=6.10", "PyQt-builder=1.18"] build-backend = "sipbuild.api" @@ -15,6 +15,10 @@ readme = "README.md" authors = [ { name = "Frederic Boudon", email = "frederic.boudon@cirad.fr" } ] +dependencies = [ + "PyQt5", + "PyQt5-sip" +] [tool.sip.project] sip-module = "PyQt5.sip" @@ -24,5 +28,6 @@ sip-files-dir = "sip" qmake-QT = ['xml', 'opengl', 'gui', 'widgets'] tags = ['QGLViewer_2_9_1'] + # Could specified directly with new construct but currently only working on MacOS. Instead options set in project.py # libraries = ['QGLViewer ; system_platform == "Linux"','GLU ; system_platform == "Linux"'] \ No newline at end of file