Skip to content

Commit 6aef3d6

Browse files
authored
Merge pull request #395 from alphaville/feature/python-packaging
Python packaging with pyproject.toml
2 parents 25ea76c + 9e41f01 commit 6aef3d6

6 files changed

Lines changed: 120 additions & 88 deletions

File tree

.github/pull_request_template.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,31 @@
11
## Main Changes
22

3-
- Describe main changes
3+
Give a summary of the key changes
44

55

66
## Associated Issues
77

88
- Closes #1
99
- Addresses #2
1010

11+
12+
## Merge Dependencies
13+
14+
Either:
15+
- This PR has no merge dependencies, or
16+
- Depends on: ..., or
17+
- Should be merged before: ...
18+
1119
## Target versions
1220

1321
- OpEn version ...
1422
- opengen version ...
1523

24+
1625
## Checklist
1726

18-
- [ ] Documentation
19-
- [ ] All tests must pass
27+
- [ ] API documentation updated
28+
- [ ] Appropriate testing
2029
- [ ] Update `CHANGELOG`(s)
21-
- [ ] Update webpage documentation
22-
- [ ] Bump versions (in `CHANGELOG`, `Cargo.toml` and `VERSION`)
30+
- [ ] Update webpage documentation, if necessary
31+
- [ ] Bump versions (in `CHANGELOG`, `Cargo.toml` and `VERSION`), if necessary

open-codegen/CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
88
Note: This is the Changelog file of `opengen` - the Python interface of OpEn
99

1010

11+
## [0.10.1] - 2026-03-25
12+
13+
14+
### Changed
15+
16+
- Introduced `pyproject.toml` for packaging the Python library; constrained the versions of dependencies therein
17+
18+
1119
## [0.10.0] - 2026-03-19
1220

1321

@@ -280,6 +288,7 @@ Note: This is the Changelog file of `opengen` - the Python interface of OpEn
280288
* Fixed `lbfgs` typo
281289

282290

291+
[0.10.1]: https://github.com/alphaville/optimization-engine/compare/opengen-0.10.0...opengen-0.10.1
283292
[0.10.0]: https://github.com/alphaville/optimization-engine/compare/opengen-0.9.6...opengen-0.10.0
284293
[0.9.6]: https://github.com/alphaville/optimization-engine/compare/opengen-0.9.5...opengen-0.9.6
285294
[0.9.5]: https://github.com/alphaville/optimization-engine/compare/opengen-0.9.4...opengen-0.9.5

open-codegen/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.10.0
1+
0.10.1

open-codegen/publish-pypi.sh

100755100644
Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,42 @@
11
#!/bin/sh
2-
# This is a script to faciliate the release of new versions
3-
# Make sure you have created a virtual environment, `venv`
4-
# and that you have installed twine
5-
2+
set -eu
3+
4+
# This script facilitates releasing a new version of opengen to PyPI.
5+
# It expects a local virtual environment at ./venv with publishing tools.
6+
67
echo "[OpEnGen] Checking out master"
78
git checkout master
89
git pull origin master
910

10-
echo "[OpEnGen] Clean build"
11-
rm -rf ./build ./dist opengen.egg-info
11+
echo "[OpEnGen] Cleaning previous build artifacts"
12+
rm -rf ./build ./dist ./opengen.egg-info
13+
14+
echo "[OpEnGen] Activating virtual environment"
15+
. venv/bin/activate
1216

13-
echo "[OpEnGen] Build (within a virtual environment)"
14-
source venv/bin/activate
15-
pip install .
17+
echo "[OpEnGen] Installing packaging tools"
18+
python -m pip install --upgrade pip build twine
1619

17-
echo "[OpEnGen] Build dist"
18-
python setup.py sdist bdist_wheel
20+
echo "[OpEnGen] Building source and wheel distributions"
21+
python -m build
1922

20-
echo "[OpEnGen] Check..."
21-
ok=`twine check dist/** | grep PASSED | wc -l`
22-
echo $ok
23-
if [ $ok -eq 2 ]; then
24-
echo "[OpEnGen] twine check: all passed"
25-
else
26-
echo "[OpEnGen] twine: some checks did not pass"
27-
exit 2
28-
fi
23+
echo "[OpEnGen] Checking distributions with twine"
24+
python -m twine check dist/*
2925

30-
echo "[OpEnGen] Uploading to pypi..."
31-
read -r -p "Are you sure? [y/N] " response
26+
echo "[OpEnGen] Uploading to PyPI..."
27+
printf "Are you sure? [y/N] "
28+
read -r response
3229
case "$response" in
33-
[yY][eE][sS]|[yY])
34-
echo "[OpEnGen] Thanks, uploading to PyPi now"
35-
twine upload dist/*
30+
[yY][eE][sS]|[yY])
31+
echo "[OpEnGen] Uploading to PyPI now"
32+
python -m twine upload dist/*
3633
;;
3734
*)
38-
echo "---"
35+
echo "[OpEnGen] Upload cancelled"
3936
;;
4037
esac
4138

4239
echo "[OpEnGen] Don't forget to create a tag; run:"
43-
a=`cat VERSION`
44-
echo "\$ git tag -a opengen-$a -m 'opengen-$a'"
45-
echo "\$ git push --tags"
40+
version=$(cat VERSION)
41+
echo "\$ git tag -a opengen-$version -m 'opengen-$version'"
42+
echo "\$ git push --tags"

open-codegen/pyproject.toml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
[build-system]
2+
requires = ["setuptools>=61"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "opengen"
7+
dynamic = ["version"]
8+
description = "Optimization Engine Code Generator"
9+
readme = { file = "README.md", content-type = "text/markdown" }
10+
requires-python = ">=3.10"
11+
authors = [
12+
{ name = "Pantelis Sopasakis", email = "[email protected]" },
13+
{ name = "Emil Fresk" },
14+
]
15+
license = "MIT OR Apache-2.0"
16+
keywords = [
17+
"optimization",
18+
"code-generation",
19+
"optimal-control",
20+
"mpc",
21+
"nmpc",
22+
"embedded",
23+
]
24+
classifiers = [
25+
"Development Status :: 4 - Beta",
26+
"Programming Language :: Python",
27+
"Programming Language :: Python :: 3",
28+
"Programming Language :: Python :: 3.10",
29+
"Programming Language :: Python :: 3.11",
30+
"Programming Language :: Python :: 3.12",
31+
"Programming Language :: Python :: 3.13",
32+
"Programming Language :: Rust",
33+
"Intended Audience :: Science/Research",
34+
"Topic :: Software Development :: Libraries",
35+
"Topic :: Scientific/Engineering",
36+
"Topic :: Scientific/Engineering :: Mathematics",
37+
"Topic :: Software Development :: Code Generators",
38+
"Topic :: Software Development :: Embedded Systems",
39+
]
40+
dependencies = [
41+
"jinja2>=3.1,<4",
42+
"casadi>=3.6,<4",
43+
"pyyaml>=6,<7",
44+
"retry>=0.9,<1",
45+
"numpy>=1.26,<3",
46+
]
47+
48+
[project.urls]
49+
Homepage = "https://github.com/alphaville/optimization-engine"
50+
Documentation = "https://alphaville.github.io/optimization-engine/"
51+
Repository = "https://github.com/alphaville/optimization-engine"
52+
Changelog = "https://github.com/alphaville/optimization-engine/blob/master/open-codegen/CHANGELOG.md"
53+
54+
[project.optional-dependencies]
55+
dev = [
56+
"build>=1",
57+
"twine>=5",
58+
]
59+
60+
[tool.setuptools]
61+
include-package-data = true
62+
zip-safe = false
63+
64+
[tool.setuptools.dynamic]
65+
version = { file = ["VERSION"] }
66+
67+
[tool.setuptools.packages.find]
68+
include = ["opengen*"]

open-codegen/setup.py

Lines changed: 2 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,6 @@
11
#!/usr/bin/env python
22

3-
from setuptools import setup, find_packages
4-
import io
5-
import os
3+
from setuptools import setup
64

7-
here = os.path.abspath(os.path.dirname(__file__))
85

9-
NAME = 'opengen'
10-
11-
# Import version from file
12-
version_file = open(os.path.join(here, 'VERSION'))
13-
VERSION = version_file.read().strip()
14-
15-
DESCRIPTION = 'Optimization Engine Code Generator'
16-
17-
18-
# Import the README and use it as the long-description.
19-
# Note: this will only work if 'README.md' is present in your MANIFEST.in file!
20-
try:
21-
with io.open(os.path.join(here, 'README.md'), encoding='utf-8') as f:
22-
long_description = '\n' + f.read()
23-
except FileNotFoundError:
24-
long_description = DESCRIPTION
25-
26-
setup(name=NAME,
27-
version=VERSION,
28-
description=DESCRIPTION,
29-
long_description=long_description,
30-
long_description_content_type='text/markdown',
31-
author=['Pantelis Sopasakis', 'Emil Fresk'],
32-
author_email='[email protected]',
33-
license='MIT License',
34-
packages=find_packages(
35-
exclude=["icasadi", "templates"]),
36-
include_package_data=True,
37-
install_requires=[
38-
'jinja2', 'casadi', 'pyyaml', 'retry', 'numpy', 'setuptools'
39-
],
40-
classifiers=[
41-
'Development Status :: 4 - Beta',
42-
'License :: OSI Approved :: MIT License',
43-
'License :: OSI Approved :: Apache Software License',
44-
'Programming Language :: Python',
45-
'Programming Language :: Rust',
46-
'Intended Audience :: Science/Research',
47-
'Topic :: Software Development :: Libraries',
48-
'Topic :: Scientific/Engineering',
49-
'Topic :: Scientific/Engineering :: Mathematics',
50-
'Topic :: Software Development :: Code Generators',
51-
'Topic :: Software Development :: Embedded Systems'
52-
],
53-
keywords=['optimization', 'nonconvex', 'embedded'],
54-
url=(
55-
'https://github.com/alphaville/optimization-engine'
56-
),
57-
zip_safe=False)
6+
setup()

0 commit comments

Comments
 (0)