Skip to content

Commit

Permalink
fix: change setup.py to build_py cmd_class and update link of OTB com…
Browse files Browse the repository at this point in the history
…piled libs to add local build functional path
  • Loading branch information
duboise-cnes committed Sep 4, 2022
1 parent 33698bb commit 795d463
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ A new section Unreleased is opened then for next dev phase.
### Fixed

- Fix dask upgrade bug [#436]
- Fix temporarely local path to CARS OTB installed apps [#434]

## 0.5.0 Refacto CARS (August 2022)

Expand Down
3 changes: 3 additions & 0 deletions env_cars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
export ROOT_PATH="$(dirname $( cd "$(dirname "${BASH_SOURCE[0]}")"; pwd -P ))"

# CARS OTB applications PATH
# Because link to installed libs doesn't always work with setuptools, link to build directory
export OTB_APPLICATION_PATH=$OTB_APPLICATION_PATH:$ROOT_PATH/../build/lib/otb/applications/
# Complement with link to installed libs path (in sys.prefix of venv or main standard root)
export OTB_APPLICATION_PATH=$OTB_APPLICATION_PATH:$ROOT_PATH/lib/

# add PATH and LD_LIBRARY_PATH for CARS OTB added apps to work in shell
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# pyproject.toml
[build-system]
requires = ["setuptools>= 45", "wheel", "setuptools_scm[toml]>=6.2"]
requires = ["setuptools>=52", "wheel", "setuptools_scm[toml]>=6.2"]
build-backend = "setuptools.build_meta"

# enable setuptools_scm version
Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ classifiers =
python_requires = >=3.8

setup_requires =
setuptools
setuptools_scm # Following https://pypi.org/project/setuptools-scm/
setuptools>=52
setuptools_scm[toml]>=6.2 # Following https://pypi.org/project/setuptools-scm/

# cars packages dependencies
install_requires =
Expand Down
23 changes: 10 additions & 13 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"""
CARS setup.py
Most of the configuration is in setup.cfg except :
- Surcharging subcommand install and develop with cars OTB build
- Enabling setuptools_scm
- Surcharging subcommand build_py with cars OTB build
TODO: add OTB build to wheel
"""
import os
import sys
Expand All @@ -31,8 +31,7 @@
from subprocess import run

from setuptools import setup
from setuptools.command.develop import develop
from setuptools.command.install import install
from setuptools.command.build_py import build_py


def cars_otb_build(command_subclass):
Expand Down Expand Up @@ -77,6 +76,7 @@ def cars_otb_build_install():
run(cmd, check=True)
# Install OTB applications in sys.prefix/lib (path in env_cars.sh)
run(["make", "install"], check=True)
# Check installation in sys.prefix/lib !
os.chdir(current_dir)

def modified_run(self):
Expand All @@ -92,19 +92,16 @@ def modified_run(self):


# Apply same cars specific setup decorator to custom setup commands:
# develop : pip install -e .
# install : pip install .
@cars_otb_build
class CustomDevelopCommand(develop):
pass

# build_py used in pip editable install -e . and pip standard install .

@cars_otb_build
class CustomInstallCommand(install):
pass
class CustomBuildPyCommand(build_py):
pass


# Setup with setup.cfg config
setup(
cmdclass={"install": CustomInstallCommand, "develop": CustomDevelopCommand},
cmdclass={
"build_py": CustomBuildPyCommand
}
)

0 comments on commit 795d463

Please sign in to comment.