Skip to content

Commit

Permalink
Merge pull request #538 from TUDelft-CNS-ATM/build-update
Browse files Browse the repository at this point in the history
Switched build backend to hatch
  • Loading branch information
jooste authored Dec 17, 2024
2 parents 17ca78a + 3dfa871 commit 7b6f6a9
Show file tree
Hide file tree
Showing 12 changed files with 229 additions and 336 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/build-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,65 @@ on:
release:
types:
- published

env:
CIBW_BUILD: cp310* cp311* cp312* cp313*
CIBW_ARCHS_MACOS: universal2
# CIBW_ARCHS_MACOS: auto universal2
CIBW_TEST_SKIP: "*universal2:arm64"

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
# macos-13 is an intel runner, macos-14 is apple silicon
os: [ubuntu-latest, windows-latest, macos-14]

steps:
- uses: actions/checkout@v4

- name: Build wheels
uses: pypa/[email protected]

- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Build sdist
run: pipx run build --sdist

- uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: dist/*.tar.gz

upload_pypi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
if: github.event_name == 'release' && github.event.action == 'published'
# or, alternatively, upload to PyPI on every tag starting with 'v' (remove on: release above to use this)
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/download-artifact@v4
with:
# unpacks all CIBW artifacts into dist/
pattern: cibw-*
path: dist
merge-multiple: true

- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_BLUESKY }}
106 changes: 0 additions & 106 deletions .github/workflows/python-publish.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
python-version: ["3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v3
Expand All @@ -22,7 +22,7 @@ jobs:
run: |
python -m pip install --upgrade pip setuptools wheel
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install -e .
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
Expand Down
34 changes: 34 additions & 0 deletions hatch_build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from pathlib import Path
from hatchling.builders.hooks.plugin.interface import BuildHookInterface

from setuptools import Distribution, Extension
from setuptools.command import build_ext

def get_numpy_include():
import numpy
return [numpy.get_include()]


class CustomHook(BuildHookInterface):
def initialize(self, version, build_data):
print(version, build_data)
extensions = [
Extension('bluesky.tools.geo._cgeo', ['bluesky/tools/geo/src_cpp/_cgeo.cpp']),
Extension('bluesky.traffic.asas.cstatebased', ['bluesky/traffic/asas/src_cpp/cstatebased.cpp'], include_dirs=['bluesky/tools/geo/src_cpp'])]

dist = Distribution(dict(name='extended', include_dirs=get_numpy_include(),
ext_modules=extensions))
dist.package_dir = "extended"
cmd = build_ext.build_ext(dist)
cmd.verbose = True # type: ignore
cmd.ensure_finalized() # type: ignore
cmd.run()
buildpath = Path(cmd.build_lib)

# Provide locations of compiled modules
force_include = {(buildpath / cmd.get_ext_filename('bluesky.tools.geo._cgeo')).as_posix(): cmd.get_ext_filename('bluesky.tools.geo._cgeo'),
(buildpath / cmd.get_ext_filename('bluesky.traffic.asas.cstatebased')).as_posix(): cmd.get_ext_filename('bluesky.traffic.asas.cstatebased')}

build_data['pure_python'] = False
build_data['infer_tag'] = True
build_data['force_include'].update(force_include)
36 changes: 36 additions & 0 deletions packaging/bluesky-guidata/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[project]
name = "bluesky-guidata"
version = "1.0.0"

authors = [
{ name="Joost Ellerbroek", email="[email protected]" },
{ name="Jacco Hoekstra", email="[email protected]" }
]

description = "Resources for the BlueSky Open ATM Simulator GUI"
readme = "../../README.md"
requires-python = ">=3.10"
classifiers = [
"Programming Language :: Python :: 3",
"Development Status :: 4 - Beta",

"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering",

"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",

"Operating System :: OS Independent",
]
keywords = ['ATM', 'transport', 'simulation', 'aviation', 'aircraft']

[project.urls]
Homepage = "https://github.com/TUDelft-CNS-ATM/bluesky"
Issues = "https://github.com/TUDelft-CNS-ATM/bluesky/issues"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.build.targets.sdist.force-include]
"../../bluesky/resources/graphics" = "bluesky/resources/graphics"
"../../bluesky/resources/html" = "bluesky/resources/html"
95 changes: 95 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
[project]
name = "bluesky-simulator"
# dynamic = ["version"]
version = "1.0.0"
dependencies = [
"numpy >= 2.0.0",
"scipy >= 1.13.0",
"matplotlib >= 3.9.0",
"pandas >= 2.2.0",
"msgpack >= 1.0.0",
"zmq"
]

authors = [
{ name="Joost Ellerbroek", email="[email protected]" },
{ name="Jacco Hoekstra", email="[email protected]" }
]

description = "The Open Air Traffic Simulator."
readme = "README.md"
license = {file = "LICENSE"}
requires-python = ">=3.10"
classifiers = [
"Programming Language :: Python :: 3",
"Development Status :: 4 - Beta",

"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering",

"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",

"Operating System :: OS Independent",
]
keywords = ['ATM', 'transport', 'simulation', 'aviation', 'aircraft']

[project.optional-dependencies]
pygame = ["pygame"]
qt6 = [
"pyopengl",
"PyQt6",
"PyQt6-WebEngine",
"bluesky-guidata"
]
console = ["textual"]
full =[
"pygame",
"pyopengl",
"PyQt6",
"PyQt6-WebEngine",
"textual",
"bluesky-guidata",
]
# For headless (server-only) bluesky environment: pip install bluesky-simulator[headless]
headless = [
# no extra dependencies
]

[project.scripts]
bluesky = "bluesky.__main__:main"

[project.urls]
Homepage = "https://github.com/TUDelft-CNS-ATM/bluesky"
Issues = "https://github.com/TUDelft-CNS-ATM/bluesky/issues"
Documentation = "https://github.com/TUDelft-CNS-ATM/bluesky/wiki"
Repository = "https://github.com/TUDelft-CNS-ATM/bluesky"
# Changelog = "https://github.com/me/spam/blob/master/CHANGELOG.md"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.build]
include = [
"bluesky/*",
]
exclude = [
'docs',
'utils',
'bluesky/test',
'bluesky/resources/graphics',
'bluesky/resources/html'
]


[tool.hatch.build.targets.wheel.hooks.custom]
dependencies = ["setuptools>=69.1.1", "numpy"]

# [tool.hatch.build.targets.wheel.hooks.cython]
# dependencies = ["hatch-cython"]

# [tool.hatch.build.targets.wheel.hooks.cython.options]
# # include .h or .cpp directories
# includes = []
# # include numpy headers
# include_numpy = true
13 changes: 0 additions & 13 deletions requirements-gui.txt

This file was deleted.

7 changes: 0 additions & 7 deletions requirements.txt

This file was deleted.

Loading

0 comments on commit 7b6f6a9

Please sign in to comment.