Skip to content

Commit

Permalink
Merge pull request #2 from ababak/drop_python2
Browse files Browse the repository at this point in the history
Drop python2, support Python 3.9, 3.10, 3.11, 3.12
  • Loading branch information
ababak authored Jul 24, 2024
2 parents 1ce4f11 + 6bc658f commit 36c6c84
Show file tree
Hide file tree
Showing 20 changed files with 97 additions and 133 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ out
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
Thumbs.db
68 changes: 4 additions & 64 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,75 +3,15 @@
# Andriy Babak <[email protected]>
#
# Build the docker image:
# docker build --rm -t ababak/cgcpp:1.6 .
# docker build --rm -t ababak/cgcpp:1.7 .
# docker run --rm -v "$(pwd):c:/source:ro" -r "$(pwd)/out:c:/out" ababak/cgcpp:1.7
# docker run --rm -v "$(pwd -W):c:/source:ro" -v "$(pwd -W)/out:c:/out" ababak/cgcpp:1.7
# See README.md for details

FROM mcr.microsoft.com/windows/servercore:ltsc2019 as base
FROM ababak/boost:latest as base

LABEL maintainer="[email protected]"

SHELL ["powershell", "-ExecutionPolicy", "RemoteSigned", "-Command"]

# Install BuildTools
RUN Invoke-WebRequest "https://aka.ms/vs/16/release/vs_buildtools.exe" -OutFile vs_buildtools.exe; \
Start-Process vs_buildtools.exe -Wait -ArgumentList '\
--quiet \
--wait \
--norestart \
--nocache \
--installPath C:/BuildTools \
--add Microsoft.VisualStudio.Workload.MSBuildTools \
--add Microsoft.VisualStudio.Workload.VCTools \
--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 \
--add Microsoft.VisualStudio.Component.Windows10SDK.18362 \
--add Microsoft.VisualStudio.Component.VC.CMake.Project \
--add Microsoft.VisualStudio.Component.TestTools.BuildTools \
--add Microsoft.VisualStudio.Component.VC.ASAN \
--add Microsoft.VisualStudio.Component.VC.140'; \
Remove-Item c:/vs_buildtools.exe

# Install Chocolatey package manager
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \
iex (New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')

# Install Chocolatey packages
RUN choco install -y \
7zip \
nasm \
openssh \
git

# Install Python
RUN choco install -y \
python2
RUN choco install -y \
python39
RUN choco install -y \
python310

ENV PYTHONIOENCODING UTF-8

# Install Boost
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \
Invoke-WebRequest "https://boost.teeks99.com/bin/1.67.0/boost_1_67_0-msvc-14.1-64.exe" -OutFile boost.exe; \
Start-Process boost.exe -Wait -ArgumentList '/DIR="C:/local/boost_1_67_0" /SILENT'; \
Remove-Item c:/boost.exe
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \
Invoke-WebRequest "https://boost.teeks99.com/bin/1.76.0/boost_1_76_0-msvc-14.1-64.exe" -OutFile boost.exe; \
Start-Process boost.exe -Wait -ArgumentList '/DIR="C:/local/boost_1_76_0" /SILENT'; \
Remove-Item c:/boost.exe
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \
Invoke-WebRequest "https://boost.teeks99.com/bin/1.80.0/boost_1_80_0-msvc-14.1-64.exe" -OutFile boost.exe; \
Start-Process boost.exe -Wait -ArgumentList '/DIR="C:/local/boost_1_80_0" /SILENT'; \
Remove-Item c:/boost.exe

ENV CMAKE_GENERATOR "NMake Makefiles"
RUN setx /M PATH $( \
'c:/cmake' + ';' + \
$env:PATH + ';' + \
$env:PROGRAMFILES + '/NASM' \
)

COPY cmake C:/cmake
COPY build.bat C:/build.bat

Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
[![Docker Image CI](https://github.com/ababak/cgcpp/actions/workflows/docker-image.yml/badge.svg?branch=v1.4.0)](https://github.com/ababak/cgcpp/actions/workflows/docker-image.yml)
[![Docker Image CI](https://github.com/ababak/cgcpp/actions/workflows/docker-image.yml/badge.svg?branch=v1.7.0)](https://github.com/ababak/cgcpp/actions/workflows/docker-image.yml)

# Computer Graphics C++ (cgcpp)
A universal solution for common needs in C++ in computer graphics software.

### Supports
- Python 2.7, Boost 1.67.0 on Windows
- Python 3.9, Boost 1.76.0 on Windows
- Autodesk Maya 2019-2023 on Windows *(Python 2.7 and Boost 1.67.0 in Maya 2019-2022, Python 3.9 and Boost 1.76.0 in Maya 2023)*
- SideFX Houdini 19.0-19.5 on Windows *(Python 2.7 and Boost 1.67.0 in Houdini 19.0, Python 3.9 and Boost 1.76.0 in Houdini 19.5)*
- Python 3.10, Boost 1.80.0 on Windows
- Python 3.11, Boost 1.82.0 on Windows
- Python 3.12, Boost 1.85.0 on Windows
- Autodesk Maya 2019-2025 on Windows *(Python 3.9 and Boost 1.76.0 in Maya 2023, Python 3.10 and Boost 1.80.0 in Maya 2024, Python 3.11 and Boost 1.82.0 in Maya 2025)*
- SideFX Houdini 19.0-19.5 on Windows *(Python 3.9 and Boost 1.76.0 in Houdini 19.5, Python 3.10 and Boost 1.80.0 in Houdini 20.0)*

Support for other platforms and other DCC applications may come later.

Expand Down
69 changes: 39 additions & 30 deletions cmake/build_functions.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# (c) Andriy Babak 2020-2021
# (c) Andriy Babak 2020-2024
#
# date: 08/09/2020
# modified: 05/08/2022 16:02:45
# modified: 24/07/2024 13:34:57
#
# Author: Andriy Babak
# e-mail: [email protected]
Expand All @@ -13,21 +13,23 @@
function(build_maya_module MAYA_VERSION PROJECT_BUILD_TYPE)
find_package (Maya REQUIRED)
set (CMAKE_BUILD_TYPE "${PROJECT_BUILD_TYPE}" CACHE INTERNAL "" FORCE)
if (MAYA_VERSION VERSION_LESS 2023)
set(PYTHON_REQUESTED_VERSION 2.7)
set(Python_ROOT_DIR "C:/Python27")
set(BOOST_REQUESTED_VERSION 1.67.0)
set(BOOST_ROOT "C:/local/boost_1_67_0")
elseif (MAYA_VERSION VERSION_LESS 2024)
if (MAYA_VERSION VERSION_LESS 2024)
set(PYTHON_REQUESTED_VERSION 3.9)
set(Python_ROOT_DIR "C:/Python39")
set(BOOST_REQUESTED_VERSION 1.76.0)
set(BOOST_ROOT "C:/local/boost_1_76_0")
else ()
elseif (MAYA_VERSION VERSION_LESS 2025)
set(PYTHON_REQUESTED_VERSION 3.10)
set(Python_ROOT_DIR "C:/Python310")
set(BOOST_REQUESTED_VERSION 1.80.0)
set(BOOST_ROOT "C:/local/boost_1_80_0")
elseif (MAYA_VERSION VERSION_LESS 2026)
set(PYTHON_REQUESTED_VERSION 3.11)
set(Python_ROOT_DIR "C:/Python311")
set(BOOST_REQUESTED_VERSION 1.82.0)
set(BOOST_ROOT "C:/local/boost_1_82_0")
else ()
message( FATAL_ERROR "Unsupported Maya version: ${MAYA_VERSION}" )
endif ()
message (STATUS "Python version: ${PYTHON_REQUESTED_VERSION}")
string (REPLACE "." "" PYTHON_DOTLESS_VERSION "${PYTHON_REQUESTED_VERSION}")
Expand Down Expand Up @@ -72,16 +74,18 @@ function(build_houdini_module HOUDINI_VERSION PROJECT_BUILD_TYPE)
# specifying this path.
list(APPEND CMAKE_PREFIX_PATH "${HFS}/toolkit/cmake")
find_package (Houdini REQUIRED)
if (Houdini_VERSION VERSION_LESS 19.5)
set(PYTHON_REQUESTED_VERSION 2.7)
set(Python_ROOT_DIR "C:/Python27")
set(BOOST_REQUESTED_VERSION 1.67.0)
set(BOOST_ROOT "C:/local/boost_1_67_0")
else ()
if (Houdini_VERSION VERSION_LESS 20.0)
set(PYTHON_REQUESTED_VERSION 3.9)
set(Python_ROOT_DIR "C:/Python39")
set(BOOST_REQUESTED_VERSION 1.76.0)
set(BOOST_ROOT "C:/local/boost_1_76_0")
elseif (Houdini_VERSION VERSION_LESS 20.5)
set(PYTHON_REQUESTED_VERSION 3.10)
set(Python_ROOT_DIR "C:/Python310")
set(BOOST_REQUESTED_VERSION 1.80.0)
set(BOOST_ROOT "C:/local/boost_1_80_0")
else ()
message( FATAL_ERROR "Unsupported Houdini version: ${HOUDINI_VERSION}" )
endif ()
message (STATUS "Python version: ${PYTHON_REQUESTED_VERSION}")
string (REPLACE "." "" PYTHON_DOTLESS_VERSION "${PYTHON_REQUESTED_VERSION}")
Expand Down Expand Up @@ -171,27 +175,32 @@ endfunction()


function(build_python_module PYTHON_REQUESTED_VERSION PROJECT_BUILD_TYPE)
if (PYTHON_REQUESTED_VERSION VERSION_EQUAL 2.7)
set(Python_ROOT_DIR "C:/Python27")
set(BOOST_REQUESTED_VERSION 1.67.0)
set(BOOST_ROOT "C:/local/boost_1_67_0")
elseif (PYTHON_REQUESTED_VERSION VERSION_EQUAL 3.9)
set(Python_ROOT_DIR "C:/Python39")
set(BOOST_REQUESTED_VERSION 1.76.0)
set(BOOST_ROOT "C:/local/boost_1_76_0")
string (REPLACE "." "" PYTHON_DOTLESS_VERSION "${PYTHON_REQUESTED_VERSION}")
message (STATUS "Python version: ${PYTHON_REQUESTED_VERSION}")
set (TARGET_NAME "${PROJECT_NAME}_python${PYTHON_DOTLESS_VERSION}")
set (CMAKE_BUILD_TYPE "${PROJECT_BUILD_TYPE}" CACHE INTERNAL "" FORCE)
message (STATUS "Target name: ${TARGET_NAME}")
if (PYTHON_REQUESTED_VERSION VERSION_EQUAL 3.9)
set (Python_ROOT_DIR "C:/Python39")
set (BOOST_REQUESTED_VERSION 1.76.0)
set (BOOST_ROOT "C:/local/boost_1_76_0")
elseif (PYTHON_REQUESTED_VERSION VERSION_EQUAL 3.10)
set(Python_ROOT_DIR "C:/Python310")
set(BOOST_REQUESTED_VERSION 1.80.0)
set(BOOST_ROOT "C:/local/boost_1_80_0")
set (Python_ROOT_DIR "C:/Python310")
set (BOOST_REQUESTED_VERSION 1.80.0)
set (BOOST_ROOT "C:/local/boost_1_80_0")
elseif (PYTHON_REQUESTED_VERSION VERSION_EQUAL 3.11)
set (Python_ROOT_DIR "C:/Python311")
set (BOOST_REQUESTED_VERSION 1.82.0)
set (BOOST_ROOT "C:/local/boost_1_82_0")
elseif (PYTHON_REQUESTED_VERSION VERSION_EQUAL 3.12)
set (Python_ROOT_DIR "C:/Python312")
set (BOOST_REQUESTED_VERSION 1.85.0)
set (BOOST_ROOT "C:/local/boost_1_85_0")
else ()
message( FATAL_ERROR "Unsupported Python version: ${PYTHON_REQUESTED_VERSION}" )
endif ()
message (STATUS "Python version: ${PYTHON_REQUESTED_VERSION}")
string (REPLACE "." "" PYTHON_DOTLESS_VERSION "${PYTHON_REQUESTED_VERSION}")
set (CMAKE_BUILD_TYPE "${PROJECT_BUILD_TYPE}" CACHE INTERNAL "" FORCE)
find_package (Python ${PYTHON_REQUESTED_VERSION} REQUIRED COMPONENTS Interpreter Development)
find_package (Boost ${BOOST_REQUESTED_VERSION} EXACT REQUIRED COMPONENTS python${PYTHON_DOTLESS_VERSION} system filesystem)
set (TARGET_NAME "${PROJECT_NAME}_python${PYTHON_DOTLESS_VERSION}")
add_library (${TARGET_NAME} SHARED ${SRC})
target_include_directories (
${TARGET_NAME}
Expand Down
2 changes: 1 addition & 1 deletion cmake/compiler.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (c) Andriy Babak 2020-2021
# (c) Andriy Babak 2020-2024
#
# date: 08/09/2020
# modified: 28/05/2021 16:41:32
Expand Down
7 changes: 5 additions & 2 deletions cmake/init-config.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# (c) Andriy Babak 2020-2021
# (c) Andriy Babak 2020-2024
#
# date: 08/09/2020
# modified: 20/04/2023 15:21:22
# modified: 24/07/2024 13:15:27
#
# Author: Andriy Babak
# e-mail: [email protected]
Expand All @@ -17,6 +17,9 @@ include(build_functions)

message (STATUS "CMake version: ${CMAKE_VERSION}")

set(Boost_NO_WARN_NEW_VERSIONS ON)
set(Boost_NO_BOOST_CMAKE ON)
set(Boost_USE_STATIC_RUNTIME OFF)
set(Boost_USE_STATIC_LIBS ON)
add_definitions(-DBOOST_PYTHON_STATIC_LIB)
set (Python_FIND_STRATEGY "LOCATION")
Expand Down
2 changes: 1 addition & 1 deletion cmake/maya-config.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (c) Andriy Babak 2020-2021
# (c) Andriy Babak 2020-2024
#
# date: 07/09/2020
# modified: 28/05/2021 16:41:00
Expand Down
4 changes: 3 additions & 1 deletion examples/source_exception/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ find_package (init)

project (lib_exception)
set (SRC "lib_exception.cpp")
build_python_module (2.7 "Release")
build_python_module (3.9 "Release")
build_python_module (3.10 "Release")
build_python_module (3.11 "Release")
build_python_module (3.12 "Release")

message (STATUS "CMAKE_INSTALL_PREFIX is ${CMAKE_INSTALL_PREFIX}")
4 changes: 2 additions & 2 deletions examples/source_exception/lib_exception.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* (c) Andriy Babak 2019-2022
* (c) Andriy Babak 2019-2024
*
* date: 23/01/2019
* modified: 05/08/2022 17:15:19
* modified: 30/05/2024 10:41:16
*
* Author: Andriy Babak
* e-mail: [email protected]
Expand Down
2 changes: 2 additions & 0 deletions examples/source_houdini/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ project (houdini_module)
set (SRC "houdini_module.cpp")
message (STATUS "Building module for Houdini 19.0.657")
build_houdini_module (19.0.657 "Release")
message (STATUS "Building module for Houdini 20.0.688")
build_houdini_module (20.0.688 "Release")
4 changes: 2 additions & 2 deletions examples/source_houdini/houdini_module.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* (c) Andriy Babak 2022
* (c) Andriy Babak 2022-2024
*
* date: 05/08/2022
* modified: 05/08/2022 18:55:46
* modified: 30/05/2024 10:40:58
*
* Author: Andriy Babak
* e-mail: [email protected]
Expand Down
6 changes: 4 additions & 2 deletions examples/source_maya/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ find_package (init)

project (maya_module)
set (SRC "maya_module.cpp")
message (STATUS "Building module for Maya 2020")
build_maya_module (2020 "Release")
message (STATUS "Building module for Maya 2022")
build_maya_module (2022 "Release")
message (STATUS "Building module for Maya 2023")
build_maya_module (2023 "Release")
message (STATUS "Building module for Maya 2024")
build_maya_module (2023 "Release")
message (STATUS "Building module for Maya 2025")
build_maya_module (2023 "Release")
4 changes: 2 additions & 2 deletions examples/source_maya/maya_module.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* (c) Andriy Babak 2019-2022
* (c) Andriy Babak 2019-2024
*
* date: 10/01/2019
* modified: 05/08/2022 13:12:07
* modified: 30/05/2024 10:40:42
*
* Author: Andriy Babak
* e-mail: [email protected]
Expand Down
12 changes: 6 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
(c) Andriy Babak 2021
date: 28/05/2021
modified: 04/08/2022 17:50:02
modified: 24/07/2024 10:15:50
Author: Andriy Babak
e-mail: [email protected]
Expand Down Expand Up @@ -72,7 +72,7 @@ def run(self):
docker_args = [
self.DOCKER_APP,
"build",
"--rm",
# "--rm",
"-t",
self.DOCKER_IMAGE,
".",
Expand Down Expand Up @@ -129,18 +129,18 @@ def run(self):


class BuildEgg(BuildEggCommand):
'''Custom egg build to ensure resources built.
"""Custom egg build to ensure resources built.
.. note::
Required because when this project is a dependency for another project,
only bdist_egg will be called and *not* build.
'''
"""

def run(self):
'''Run egg build ensuring build_resources called first.'''
self.run_command('build_ext')
"""Run egg build ensuring build_resources called first."""
self.run_command("build_ext")
BuildEggCommand.run(self)


Expand Down
9 changes: 5 additions & 4 deletions source/cgcpp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""
(c) Andriy Babak 2021
(c) Andriy Babak 2021-2024
date: 31/05/2021
modified: 20/04/2023 12:00:25
modified: 30/05/2024 10:40:19
Author: Andriy Babak
e-mail: [email protected]
Expand All @@ -19,11 +19,12 @@
from ._version import __version__
from . import build

__copyright__ = "(c) Andriy Babak 2021-2022"
__copyright__ = "(c) Andriy Babak 2021-2024"

lib_loader_name = "lib_loader"
lib_suffix = "_python{major}{minor}".format(
major=sys.version_info.major, minor=sys.version_info.minor,
major=sys.version_info.major,
minor=sys.version_info.minor,
)
lib_loader_path = "{folder}/{name}{suffix}.pyd".format(
folder=os.path.dirname(__file__), name=lib_loader_name, suffix=lib_suffix
Expand Down
Loading

0 comments on commit 36c6c84

Please sign in to comment.