Skip to content

Commit

Permalink
Build a source package for JSBSim Python module compatible with all p…
Browse files Browse the repository at this point in the history
…latforms (Windows, MacOSX, Linux)

Until now, the CI workflow was building 2 different source packages (1 for Windows and 1 for MacOSX/Linux). Unfortunately, PyPI allows only one source package to be uploaded. This commit allows to produce just one source package that is compatible with all platforms.
  • Loading branch information
bcoconni committed Jan 24, 2021
1 parent f302d82 commit 366b9d4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 23 deletions.
26 changes: 6 additions & 20 deletions .github/workflows/cpp-python-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,6 @@ jobs:
- name: Test JSBSim
working-directory: build
run: ctest -j2 -E TestInputSocket --build-config RelWithDebInfo --output-on-failure
- name: Build source package for Python
if: env.release == 'true'
working-directory: build
run: python python/setup.py sdist --format=zip

# On failure, upload logs
- name: On failure - Upload logs
Expand Down Expand Up @@ -263,7 +259,6 @@ jobs:
build\src\RelWithDebInfo\JSBSim.lib
build\python\jsbsim.cxx
build\python\setup.py
build\python\dist\*.zip
MacOSX:
strategy:
Expand Down Expand Up @@ -347,26 +342,18 @@ jobs:
python-version: '3.7'
- name: Install Python packages
run: pip install -U cython numpy
- name: Download binary files (Linux & MacOSX)
id: UnixFiles
if: runner.os != 'Windows'
- name: Download binary files
uses: actions/download-artifact@v2
with:
name: macos-10.15.binaries
- name: Build Python module from sources (Linux & MacOSX)
if: steps.UnixFiles.outcome == 'success'
run: pip install python/dist/*.tar.gz
- name: Download binary files (Windows)
id: WindowsFiles
if: runner.os == 'Windows'
uses: actions/download-artifact@v2
with:
name: ${{ matrix.os }}.binaries
if: runner.os != 'Windows'
run: pip install python/dist/*.tar.gz -vv
- name: Build Python module from sources (Windows)
if: steps.WindowsFiles.outcome == 'success'
if: runner.os == 'Windows'
run: |
$PyPackage = Get-ChildItem -Path python\dist -Filter *.zip | Select-Object -First 1
pip install $PyPackage.FullName
$PyPackage = Get-ChildItem -Path python\dist -Filter *.tar.gz | Select-Object -First 1
pip install $PyPackage.FullName -vv
- name: Test Python module
shell: python
run: |
Expand Down Expand Up @@ -483,7 +470,6 @@ jobs:
pip install -U twine
twine upload dist/*.whl
twine upload dist/*.tar.gz
twine upload dist/*.zip
# Deploy stable release to GitHub
- name: Get JSBSim version
Expand Down
11 changes: 8 additions & 3 deletions python/setup.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ if compiler.compiler_type == 'unix':
else:
cpp_compile_flag = []

if compiler.compiler_type == 'msvc':
link_libraries = ['wsock32', 'ws2_32']
else:
link_libraries = [${JSBSIM_LINK_LIBRARIES}]

# Update the JSBSim library path according to the --config option
if args.config:
if compiler.compiler_type == 'msvc':
Expand All @@ -167,7 +172,7 @@ if 'sdist' not in dist.commands and compiler.find_library_file([library_path],
# the Python module.
ext_kwargs = { 'sources': ['${JSBSIM_CXX}'],
'include_dirs': ['src'],
'libraries': ['JSBSim', ${JSBSIM_LINK_LIBRARIES}],
'libraries': ['JSBSim'] + link_libraries,
'library_dirs': [library_path],
'extra_compile_args': cpp_compile_flag }
setup_kwargs = { 'cmdclass' : {'build_ext': QuietBuild,
Expand All @@ -176,13 +181,13 @@ else:
# We cannot find the JSBSim library so the Python module must be built from
# the sources.
if compiler.compiler_type == 'msvc':
compile_flags = [('/D'+flag).replace('"', '\\"') for flag in [${JSBSIM_FLAGS}]]
compile_flags = [('/D'+flag).replace('"', '\\"') for flag in ['_USE_MATH_DEFINES', 'NOMINMAX', ${JSBSIM_FLAGS}]]
else:
compile_flags = ['-D'+flag for flag in [${JSBSIM_FLAGS}]]


ext_kwargs = { 'sources': ['jsbsim.pyx', ${JSBSIM_SOURCE_FILES}],
'libraries': [${JSBSIM_LINK_LIBRARIES}],
'libraries': link_libraries,
'include_dirs': ['src', 'src/simgear/xml'],
'extra_compile_args': compile_flags }
# List of required modules to build the JSBSim module from the sources.
Expand Down

0 comments on commit 366b9d4

Please sign in to comment.