Skip to content

Commit

Permalink
Merge pull request #1628 from borglab/python-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
varunagrawal authored Oct 8, 2023
2 parents 5d9b0cf + 3fac23b commit 3a1fe57
Show file tree
Hide file tree
Showing 167 changed files with 8,135 additions and 1,939 deletions.
2 changes: 0 additions & 2 deletions .github/scripts/python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ function install_dependencies()
if [ "${GTSAM_WITH_TBB:-OFF}" == "ON" ]; then
install_tbb
fi

$PYTHON -m pip install -r $GITHUB_WORKSPACE/python/requirements.txt
}

function build()
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/build-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,13 @@ jobs:
with:
swap-size-gb: 6

- name: Install Dependencies
- name: Install System Dependencies
run: |
bash .github/scripts/python.sh -d
- name: Install Python Dependencies
run: python$PYTHON_VERSION -m pip install -r python/dev_requirements.txt

- name: Build
run: |
bash .github/scripts/python.sh -b
Expand Down
3 changes: 0 additions & 3 deletions docker/ubuntu-gtsam-python/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ FROM borglab/ubuntu-gtsam:bionic
# Install pip
RUN apt-get install -y python3-pip python3-dev

# Install python wrapper requirements
RUN python3 -m pip install -U -r /usr/src/gtsam/python/requirements.txt

# Run cmake again, now with python toolbox on
WORKDIR /usr/src/gtsam/build
RUN cmake \
Expand Down
9 changes: 5 additions & 4 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
set(PROJECT_PYTHON_SOURCE_DIR ${PROJECT_SOURCE_DIR}/python)
set(GTSAM_PYTHON_BUILD_DIRECTORY ${PROJECT_BINARY_DIR}/python)

if (NOT GTSAM_BUILD_PYTHON)
Expand All @@ -6,11 +7,11 @@ endif()

# Generate setup.py.
file(READ "${PROJECT_SOURCE_DIR}/README.md" README_CONTENTS)
configure_file(${PROJECT_SOURCE_DIR}/python/setup.py.in
configure_file(${PROJECT_PYTHON_SOURCE_DIR}/setup.py.in
${GTSAM_PYTHON_BUILD_DIRECTORY}/setup.py)

# Supply MANIFEST.in for older versions of Python
file(COPY ${PROJECT_SOURCE_DIR}/python/MANIFEST.in
file(COPY ${PROJECT_PYTHON_SOURCE_DIR}/MANIFEST.in
DESTINATION ${GTSAM_PYTHON_BUILD_DIRECTORY})

set(WRAP_BUILD_TYPE_POSTFIXES ${GTSAM_BUILD_TYPE_POSTFIXES})
Expand Down Expand Up @@ -99,7 +100,7 @@ pybind_wrap(${GTSAM_PYTHON_TARGET} # target
"gtsam" # module_name
"gtsam" # top_namespace
"${ignore}" # ignore_classes
${PROJECT_SOURCE_DIR}/python/gtsam/gtsam.tpl
${PROJECT_PYTHON_SOURCE_DIR}/gtsam/gtsam.tpl
gtsam # libs
"gtsam;gtsam_header" # dependencies
${GTSAM_ENABLE_BOOST_SERIALIZATION} # use_boost_serialization
Expand Down Expand Up @@ -178,7 +179,7 @@ if(GTSAM_UNSTABLE_BUILD_PYTHON)
"gtsam_unstable" # module_name
"gtsam" # top_namespace
"${ignore}" # ignore_classes
${PROJECT_SOURCE_DIR}/python/gtsam_unstable/gtsam_unstable.tpl
${PROJECT_PYTHON_SOURCE_DIR}/gtsam_unstable/gtsam_unstable.tpl
gtsam_unstable # libs
"gtsam_unstable;gtsam_unstable_header" # dependencies
${GTSAM_ENABLE_BOOST_SERIALIZATION} # use_boost_serialization
Expand Down
2 changes: 1 addition & 1 deletion python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ For instructions on updating the version of the [wrap library](https://github.co
- This wrapper needs `pyparsing(>=2.4.2)`, and `numpy(>=1.11.0)`. These can be installed as follows:

```bash
pip install -r <gtsam_folder>/python/requirements.txt
pip install -r <gtsam_folder>/python/dev_requirements.txt
```

## Install
Expand Down
2 changes: 2 additions & 0 deletions python/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-r requirements.txt
pyparsing>=2.4.2
1 change: 0 additions & 1 deletion python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
numpy>=1.11.0
pyparsing>=2.4.2
15 changes: 6 additions & 9 deletions python/setup.py.in
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
"""Setup file to install the GTSAM package."""

try:
from setuptools import setup, find_packages
except ImportError:
from distutils.core import setup, find_packages
from setuptools import setup, find_namespace_packages

packages = find_packages(where=".")
packages = find_namespace_packages(
where=".",
exclude=('build', 'build.*', 'CMakeFiles', 'CMakeFiles.*',
'gtsam.notebooks', '*.preamble', '*.specializations', 'dist'))
print("PACKAGES: ", packages)

package_data = {
'': [
"./*.so",
"./*.dll",
"Data/*" # Add the data files to the package
"Data/**/*" # Add the data files in subdirectories
"./*.dll"
]
}

Expand Down Expand Up @@ -41,7 +39,6 @@ setup(
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 3',
],
packages=packages,
Expand Down
2 changes: 2 additions & 0 deletions wrap/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ __pycache__/
*dist*
*.egg-info

**/.DS_Store

# Files related to code coverage stats
**/.coverage

Expand Down
2 changes: 2 additions & 0 deletions wrap/pybind11/.clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ Checks: |
-bugprone-unused-raii,
CheckOptions:
- key: modernize-use-equals-default.IgnoreMacros
value: false
- key: performance-for-range-copy.WarnOnAllAutoCopies
value: true
- key: performance-inefficient-string-concatenation.StrictMode
Expand Down
24 changes: 24 additions & 0 deletions wrap/pybind11/.codespell-ignore-lines
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
template <op_id id, op_type ot, typename L = undefined_t, typename R = undefined_t>
template <typename ThisT>
auto &this_ = static_cast<ThisT &>(*this);
if (load_impl<ThisT>(temp, false)) {
ssize_t nd = 0;
auto trivial = broadcast(buffers, nd, shape);
auto ndim = (size_t) nd;
int nd;
ssize_t ndim() const { return detail::array_proxy(m_ptr)->nd; }
using op = op_impl<id, ot, Base, L_type, R_type>;
template <op_id id, op_type ot, typename L, typename R>
template <detail::op_id id, detail::op_type ot, typename L, typename R, typename... Extra>
class_ &def(const detail::op_<id, ot, L, R> &op, const Extra &...extra) {
class_ &def_cast(const detail::op_<id, ot, L, R> &op, const Extra &...extra) {
@pytest.mark.parametrize("access", ["ro", "rw", "static_ro", "static_rw"])
struct IntStruct {
explicit IntStruct(int v) : value(v){};
~IntStruct() { value = -value; }
IntStruct(const IntStruct &) = default;
IntStruct &operator=(const IntStruct &) = default;
py::class_<IntStruct>(m, "IntStruct").def(py::init([](const int i) { return IntStruct(i); }));
py::implicitly_convertible<int, IntStruct>();
m.def("test", [](int expected, const IntStruct &in) {
[](int expected, const IntStruct &in) {
4 changes: 2 additions & 2 deletions wrap/pybind11/.github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ directory inside your pybind11 git clone. Files will be modified in place,
so you can use git to monitor the changes.

```bash
docker run --rm -v $PWD:/mounted_pybind11 -it silkeh/clang:13
apt-get update && apt-get install -y python3-dev python3-pytest
docker run --rm -v $PWD:/mounted_pybind11 -it silkeh/clang:15-bullseye
apt-get update && apt-get install -y git python3-dev python3-pytest
cmake -S /mounted_pybind11/ -B build -DCMAKE_CXX_CLANG_TIDY="$(which clang-tidy);--use-color" -DDOWNLOAD_EIGEN=ON -DDOWNLOAD_CATCH=ON -DCMAKE_CXX_STANDARD=17
cmake --build build -j 2
```
Expand Down
22 changes: 19 additions & 3 deletions wrap/pybind11/.github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ body:
- type: markdown
attributes:
value: |
Maintainers will only make a best effort to triage PRs. Please do your best to make the issue as easy to act on as possible, and only open if clearly a problem with pybind11 (ask first if unsure).
Please do your best to make the issue as easy to act on as possible, and only submit here if there is clearly a problem with pybind11 (ask first if unsure). **Note that a reproducer in a PR is much more likely to get immediate attention.**
- type: checkboxes
id: steps
attributes:
Expand All @@ -20,6 +21,13 @@ body:
- label: Consider asking first in the [Gitter chat room](https://gitter.im/pybind/Lobby) or in a [Discussion](https:/pybind/pybind11/discussions/new).
required: false

- type: input
id: version
attributes:
label: What version (or hash if on master) of pybind11 are you using?
validations:
required: true

- type: textarea
id: description
attributes:
Expand All @@ -40,6 +48,14 @@ body:
The code should be minimal, have no external dependencies, isolate the
function(s) that cause breakage. Submit matched and complete C++ and
Python snippets that can be easily compiled and run to diagnose the
issue. If possible, make a PR with a new, failing test to give us a
starting point to work on!
issue. — Note that a reproducer in a PR is much more likely to get
immediate attention: failing tests in the pybind11 CI are the best
starting point for working out fixes.
render: text

- type: input
id: regression
attributes:
label: Is this a regression? Put the last known working version here if it is.
description: Put the last known working version here if this is a regression.
value: Not a regression
Loading

0 comments on commit 3a1fe57

Please sign in to comment.