Skip to content

Commit

Permalink
Merge branch 'issues/migrate-python3' into github-develop
Browse files Browse the repository at this point in the history
* issues/migrate-python3:
  Finished migration of the code to Python3.
  • Loading branch information
jcpassy committed Oct 16, 2019
2 parents b8cb50b + 4c4100e commit 1b1fa5d
Show file tree
Hide file tree
Showing 82 changed files with 6,011 additions and 502 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
build/*
*.pyc
temporary_test
dist
MANIFEST
*.xml
*.egg-info
doc/build
.eggs
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
recursive-include mesh/src *
recursive-include mesh/ressources *
146 changes: 30 additions & 116 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,134 +1,48 @@
# Copyright (c) 2018 Max Planck Society for non-commercial scientific research
# This file is part of psbody.mesh project which is released under MPI License.
# See file LICENSE.txt for full license details.

tmpdirbuild := temporary_test
venv_dir := $(tmpdirbuild)/venv
activate := $(venv_dir)/bin/activate
# Makefile for mesh package
package_name := mesh_package

.DEFAULT_GOAL := all

# we have to add an option for locating boost on some platforms
ifeq ($(OS),Windows_NT)
$(error not supported platform)
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
libboost_version := $(shell dpkg -l libboost-dev | tail -n 1 | awk '{print $$3}' )
check_boost_version := $(shell dpkg --compare-versions "${libboost_version}" ">=" 1.54 ; echo $$?)
ifneq ($(check_boost_version), 0)
additional_install_cmd := --boost-location=$$BOOST_ROOT
else
additional_install_cmd :=
endif
else ifeq ($(UNAME_S),Darwin)
additional_install_cmd := --boost-location=$$BOOST_ROOT
else
$(error "NOT SUPPORTED")
endif
endif

ifneq ($(additional_install_cmd),)
$(info [INSTALL] Overriding the default install command with [${additional_install_cmd}])
# cannot use install otherwise it installs it on bdist_wheel command and messes with
# the virtualenv. build_ext and install use the same "boost-location" option
additional_install_cmd_for_setup := build_ext ${additional_install_cmd}
additional_install_cmd_for_pip := --install-option="${additional_install_cmd}"
else
additional_install_cmd_for_setup :=
additional_install_cmd_for_pip :=
endif
#$(shell exit 0)

$(tmpdirbuild):
mkdir -p $(tmpdirbuild)

$(tmpdirbuild)/package_creation: $(tmpdirbuild)
@echo "\033[0;36m"
@echo "********"
@echo "********"
@echo "********" $(package_name) ": Building the virtualenv for installation"
@echo "********"
@echo "********"
@echo "\033[0m"
@virtualenv --system-site-packages $(venv_dir) -p python3
@ . $(activate) && pip install --upgrade pip
@ . $(activate) && pip install --upgrade virtualenv
@ . $(activate) && pip install nose2
@ . $(activate) && echo `which pip` && pip -V
@ . $(activate) && pip install --upgrade setuptools && echo `which pip` && pip -V
@ . $(activate) && pip install --upgrade wheel && echo `which pip` && pip -V
@ . $(activate) && pip install numpy
@ . $(activate) && pip install scipy pyopengl pillow pyzmq pyyaml && echo `which pip` && pip -V
####### PACKAGE: creating SDIST target
@echo "\033[0;33m----- [" ${package_name} "] Creating the source distribution\033[0m"
@ . $(activate) && python setup.py sdist
####### PACKAGE: creating WHEEL target
@echo "\033[0;33m----- [" ${package_name} "] Creating the wheel distribution\033[0m"
@ . $(activate) && python setup.py --verbose ${additional_install_cmd_for_setup} bdist_wheel
####### INSTALLING
@echo "\033[0;33m----- [" ${package_name} "] Installing on the local virtual environment\033[0m"
@ . $(activate) && pip install --no-deps ${additional_install_cmd_for_pip} --verbose --no-cache-dir .
####### Cleaning some artifacts
@rm -rf psbody_mesh.egg-info
####### Touching the result
@touch $@

all: $(tmpdirbuild)/package_creation

# TEST_ROOT_DIR is given by the parent process, and points to the location where the xml files should be stored.
# In our case, it also contains the "body" package which is needed by the package
all:
@echo "\033[0;36m----- [" ${package_name} "] Installing on the local virtual environment `which python`\033[0m"
@pip install --upgrade -r requirements.txt && pip list
@pip install --no-deps --install-option="--boost-location=$$BOOST_ROOT" --verbose --no-cache-dir .

import_tests:
# not hidding the command of this line
@echo "********" $(package_name) ": performing import tests"
unset PYTHONPATH && . $(activate) && PSBODY_MESH_CACHE=`mktemp -d -t mesh_package.XXXXXXXXXX` python -c "from psbody.mesh.mesh import Mesh" && python -c "from psbody.mesh.meshviewer import MeshViewers" ;
@echo "********" $(package_name) ": performing import tests - ok"
@echo "\033[0;33m----- [" ${package_name} "] Performing import tests\033[0m"
@PSBODY_MESH_CACHE=`mktemp -d -t mesh_package.XXXXXXXXXX` python -c "from psbody.mesh.mesh import Mesh"
@python -c "from psbody.mesh.meshviewer import MeshViewers"
@echo "\033[0;33m----- [" ${package_name} "] OK import tests\033[0m"

# this package is independant from the rest of the repository, we do not set the PYTHONPATH to
# any other directory.
unit_tests:
@if test "$(USE_NOSE)" = "" ; then \
echo "********" $(package_name) ": Running tests using unittest, no report file" ; \
. $(activate) && PSBODY_MESH_CACHE=`mktemp -d -t mesh_package.XXXXXXXXXX` python -m unittest discover -vvv ; \
echo "\033[0;33m----- [" ${package_name} "] Running tests using unittest, no report file\033[0m" ; \
PSBODY_MESH_CACHE=`mktemp -d -t mesh_package.XXXXXXXXXX` python -m unittest -v ; \
else \
echo "********" $(package_name) ": Running tests using Nose2, report file is $(TEST_ROOT_DIR)nose2_$(package_name).xml" ; \
. $(activate) && PSBODY_MESH_CACHE=`mktemp -d -t mesh_package.XXXXXXXXXX` nose2 -v ; \
echo "********" $(package_name) ": Running tests using Nose2 - ok" ; \
echo "\033[0;33m----- [" ${package_name} "] Running tests using nosetests\033[0m" ; \
pip install nose ; \
PSBODY_MESH_CACHE=`mktemp -d -t mesh_package.XXXXXXXXXX` nosetests -v --with-xunit; \
fi ;

tests: import_tests unit_tests

# tests the packages installation
packages_tests:
@echo "********" $(package_name) ": Building the virtualenv for checking source distribution"
@rm -rf $(tmpdirbuild)/venv_sdist ;
@virtualenv $(tmpdirbuild)/venv_sdist ;
@ . $(tmpdirbuild)/venv_sdist/bin/activate && pip install --upgrade pip ;
cd dist && dirsdist=$$(python -c "import os; print [i[:os.path.basename(i).find('.tar')] for i in os.listdir('.') if os.path.basename(i).find('.tar')>-1][0] ") && cd - ; \
# we do not want to install those packages with potential "additional_install_cmd_for_pip" options ; \
. $(tmpdirbuild)/venv_sdist/bin/activate && pip install numpy pyopengl pyzmq scipy pyyaml ; \
. $(tmpdirbuild)/venv_sdist/bin/activate && cd dist && tar xzf *.tar.gz && cd $$dirsdist && pip install ${additional_install_cmd_for_pip} --verbose --no-cache-dir . ;
@
@
@echo "********" $(package_name) ": Building the virtualenv for checking wheel distribution"
@
@rm -rf $(tmpdirbuild)/venv_wheel ;
@virtualenv $(tmpdirbuild)/venv_wheel ;
@ . $(tmpdirbuild)/venv_wheel/bin/activate && pip install --upgrade pip ;
@ . $(tmpdirbuild)/venv_wheel/bin/activate && cd dist && pip install --verbose --no-cache-dir *.whl ;

# TODO add a simple and robust way to run the import_tests target
test: import_tests unit_tests packages_tests
# Creating source distribution
sdist:
@echo "\033[0;33m----- [" ${package_name} "] Creating the source distribution\033[0m"
@python setup.py sdist

# Creating wheel distribution
wheel:
@echo "\033[0;33m----- [" ${package_name} "] Creating the wheel distribution\033[0m"
@pip install wheel
@python setup.py --verbose build_ext --boost-location=$$BOOST_ROOT bdist_wheel

install:
@echo "********" $(package_name) ": installation"
@echo "** installing " $(package_name) && cd dist && pip install --verbose --no-cache-dir *.whl ;
# Build documentation
documentation:
@echo "\033[0;33m----- [" ${package_name} "] Building Sphinx documentation\033[0m"
@pip install -U sphinx sphinx_bootstrap_theme
@cd doc && make html

clean:
@rm -rf $(tmpdirbuild)
@find . -name "*.pyc" -delete
@rm -rf build
@rm -rf dist
@rm -rf psbody_mesh.egg-info
@rm -rf *.xml
32 changes: 0 additions & 32 deletions README.md

This file was deleted.

3 changes: 3 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Perceiving Systems Mesh Package
===============================

38 changes: 38 additions & 0 deletions data/unittest/cylinder.obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Blender v2.61 (sub 0) OBJ File: ''
# www.blender.org
g Cylinder
v 0.000000 -1.000000 -1.000000
v 0.000000 -1.000000 1.000000
v -0.382683 -1.000000 0.923880
v -0.707107 -1.000000 0.707107
v -0.923880 -1.000000 0.382684
v -1.000000 -1.000000 -0.000000
v -0.923879 -1.000000 -0.382684
v -0.707107 -1.000000 -0.707107
v -0.382683 -1.000000 -0.923880
v 0.000001 1.000000 -1.000000
v -0.000002 1.000000 1.000000
v -0.382685 1.000000 0.923879
v -0.707108 1.000000 0.707105
v -0.923880 1.000000 0.382681
v -1.000000 1.000000 -0.000003
v -0.923878 1.000000 -0.382686
v -0.707105 1.000000 -0.707109
v -0.382681 1.000000 -0.923881
s off
f 10 1 18
f 1 9 18
f 8 17 9
f 17 18 9
f 7 16 8
f 16 17 8
f 6 15 7
f 15 16 7
f 5 14 6
f 14 15 6
f 4 13 5
f 13 14 5
f 3 12 4
f 12 13 4
f 2 11 3
f 11 12 3
38 changes: 38 additions & 0 deletions data/unittest/cylinder_trans.obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Blender v2.61 (sub 0) OBJ File: ''
# www.blender.org
g Cylinder
v 1.057678 -1.000000 -1.000000
v 1.057678 -1.000000 1.000000
v 0.674994 -1.000000 0.923880
v 0.350571 -1.000000 0.707107
v 0.133798 -1.000000 0.382684
v 0.057678 -1.000000 -0.000000
v 0.133798 -1.000000 -0.382684
v 0.350571 -1.000000 -0.707107
v 0.674995 -1.000000 -0.923880
v 1.057678 1.000000 -1.000000
v 1.057676 1.000000 1.000000
v 0.674992 1.000000 0.923879
v 0.350569 1.000000 0.707105
v 0.133797 1.000000 0.382681
v 0.057678 1.000000 -0.000003
v 0.133799 1.000000 -0.382686
v 0.350573 1.000000 -0.707109
v 0.674997 1.000000 -0.923881
s off
f 10 1 18
f 1 9 18
f 8 17 9
f 17 18 9
f 7 16 8
f 16 17 8
f 6 15 7
f 15 16 7
f 5 14 6
f 14 15 6
f 4 13 5
f 13 14 5
f 3 12 4
f 12 13 4
f 2 11 3
f 11 12 3
46 changes: 46 additions & 0 deletions data/unittest/self_intersecting_cyl.obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Blender v2.61 (sub 0) OBJ File: ''
# www.blender.org
g Plane
v 0.000000 -0.500000 -1.000000
v 0.707107 -0.500000 -0.707107
v 1.000000 -0.500000 0.000000
v 0.707107 -0.500000 0.707107
v -0.000000 -0.500000 1.000000
v -0.707107 -0.500000 0.707107
v -1.000000 -0.500000 -0.000000
v -0.707107 -0.500000 -0.707107
v -0.000000 0.500000 -1.000000
v 0.707106 0.500000 -0.707107
v 1.000000 0.500000 -0.000001
v 0.707107 0.500000 0.707107
v -0.000000 0.500000 1.000000
v -0.707107 0.500000 0.707107
v -1.000000 0.500000 -0.000001
v -0.707106 0.500000 -0.707107
v 0.000000 -0.500000 0.000000
v 0.000000 -0.835754 0.000000
s off
f 17 1 2
f 18 10 9
f 17 2 3
f 18 11 10
f 17 3 4
f 18 12 11
f 17 4 5
f 18 13 12
f 17 5 6
f 18 14 13
f 17 6 7
f 18 15 14
f 17 7 8
f 18 16 15
f 8 1 17
f 18 9 16
f 1 9 10 2
f 2 10 11 3
f 3 11 12 4
f 4 12 13 5
f 5 13 14 6
f 6 14 15 7
f 7 15 16 8
f 9 1 8 16
Loading

0 comments on commit 1b1fa5d

Please sign in to comment.