Skip to content

Commit

Permalink
Add python embedding examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
furby-tm committed Jul 9, 2024
1 parent 4235044 commit 8234cc1
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Sources/Examples/Examples.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ enum USDExamples
GalahInterpreterExamples.run()
#endif /* WITH_GALAH */

PythonInterpreterExamples.run()

// scene description examples.
SceneDescriptionExamples.run()

Expand Down
56 changes: 56 additions & 0 deletions Sources/Examples/PythonInterpreter.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/* ----------------------------------------------------------------
* :: : M E T A V E R S E : ::
* ----------------------------------------------------------------
* This software is Licensed under the terms of the Apache License,
* version 2.0 (the "Apache License") with the following additional
* modification; you may not use this file except within compliance
* of the Apache License and the following modification made to it.
* Section 6. Trademarks. is deleted and replaced with:
*
* Trademarks. This License does not grant permission to use any of
* its trade names, trademarks, service marks, or the product names
* of this Licensor or its affiliates, except as required to comply
* with Section 4(c.) of this License, and to reproduce the content
* of the NOTICE file.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND without even an
* implied warranty of MERCHANTABILITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the Apache License for more details.
*
* You should have received a copy for this software license of the
* Apache License along with this program; or, if not, please write
* to the Free Software Foundation Inc., with the following address
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (C) 2024 Wabi Foundation. All Rights Reserved.
* ----------------------------------------------------------------
* . x x x . o o o . x x x . : : : . o x o . : : : .
* ---------------------------------------------------------------- */

import Foundation
import PixarUSD
#if canImport(PyBundle)
import PyBundle
#endif /* canImport(PyBundle) */

func embedPython()
{
#if canImport(PyBundle)
/* embed & init python. */
PyBundler.shared.pyInit()
PyBundler.shared.pyInfo()
#endif /* canImport(PyBundle) */
}

enum PythonInterpreterExamples
{
static func run()
{
Msg.logger.info("running python interpreter examples...")

embedPython()

Msg.logger.info("python interpreter examples complete.")
}
}

0 comments on commit 8234cc1

Please sign in to comment.