Skip to content

Commit

Permalink
Automatically detect python location
Browse files Browse the repository at this point in the history
  • Loading branch information
overfl0 committed Sep 16, 2021
1 parent 6c93e69 commit 1439bc3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ jobs:
with:
python-version: '3.7'
architecture: ${{ matrix.arch }}
- run: new-item -itemtype Junction -path c:\python37-x64 -target C:\hostedtoolcache\windows\Python\3.7.9\${{ matrix.arch }}
- run: new-item -itemtype Junction -path c:\python37 -target C:\hostedtoolcache\windows\Python\3.7.9\${{ matrix.arch }}

- name: Check out repository code
uses: actions/checkout@v2
Expand Down
24 changes: 9 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
###############################################################################
# Set your Python version here:
###############################################################################
set(PYTHON_VERSION_MAJOR "3")
set(PYTHON_VERSION_MINOR "7")

cmake_minimum_required(VERSION 3.14.7)
project(PythiaProject)

message(STATUS "Cmake version: ${CMAKE_VERSION}")
message(STATUS "Setting MSVC flags")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++latest")

Expand All @@ -21,24 +28,11 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin")

###############################################################################
# Set your Python version here:
###############################################################################
set(PYTHON_VERSION_MAJOR "3")
set(PYTHON_VERSION_MINOR "7")

add_compile_definitions(PYTHON_VERSION="${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}")
add_compile_definitions(PYTHON_VERSION_DOTTED="${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}")

# The python executables and libraries are in the same directories as they are on an AppVeyor machine:
# https://www.appveyor.com/docs/windows-images-software/#python
# Create a symlink if you don't want to move your python installation here, for example:
# mklink /j c:\my_path\Python36-64 c:\Python36-x64
if(CMAKE_CL_64)
set(PYTHON_PATH "C:\\Python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}-x64")
else()
set(PYTHON_PATH "C:\\Python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}")
endif()
find_package (Python3 "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}" EXACT REQUIRED COMPONENTS Development)
set(PYTHON_PATH "${Python3_RUNTIME_LIBRARY_DIRS}")

add_subdirectory(src/Pythia)
add_subdirectory(src/PythiaSetPythonPath)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ Building requirements
---------------------

- Python 3.7 64-bit and 32-bit (you need to build both the 32-bit and 64-bit extensions)
- Visual Studio Community 2017
- Visual Studio Community 2019

Building
--------
Expand Down

0 comments on commit 1439bc3

Please # to comment.