Skip to content

Commit 7c15064

Browse files
committed
Clean-up setup.py, README etc.
1 parent dd3b303 commit 7c15064

8 files changed

+36
-194
lines changed

Makefile

-4
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,10 @@ help:
1515
@echo ' format - Formats the python code in the folder using the black code'
1616
@echo ' formatter (github.com/ambv/black).'
1717
@echo ' help - Print this help information.'
18-
@echo ' init - Install the Phobos requirements using pip.'
1918
@echo ' install - Install the Phobos code to your Blender installation.'
2019
@echo ' This also sets up the configuration folder for Phobos.'
2120
@echo ' version - Prints some help relating to drafting a new version.'
2221

23-
init:
24-
pip3 install -r requirements.txt
25-
2622
install:
2723
pip3 install .
2824

README.md

+3-7
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,14 @@ After installation the phobos main menu can be found on the right hand side of t
5959

6060
![Small arrow to open the phobos toolbar widget.](https://github.com/dfki-ric/phobos/wiki/img/blender_phobos_menu_open.png)
6161

62-
Phobos is currently tested and running with Blender v3.2.
62+
Phobos is currently tested and running with Blender v3.3 LTS.
6363

6464
### CLI
6565
Just install it using pip:
6666
```bash
6767
cd phobos
6868
pip install .
6969
```
70-
or without pip:
71-
```bash
72-
cd phobos
73-
python setup.py install
74-
```
7570
or with autoproj:
7671
1) Add the package to your buildconf/package_set
7772
2) Install via `amake`
@@ -120,7 +115,8 @@ It will also tell you which dependencies are missing for some scripts.
120115
## Features
121116

122117
- WYSIWYG editor for robot models using Blender
123-
- CLI tool for automated model processing
118+
- CLI tools for fast and easy model handling and inspection
119+
- CI tool to run phobos headless in your CI-pipeline for atomated model processing and maintenance
124120
- Import and export of **URDF**, **SDF** **SMURF** and other
125121
[formats](https://github.com/dfki-ric/phobos/wiki/Formats)
126122
- Easy definition of robot kinematics (links and joints)

blender_requirements.json

-17
This file was deleted.

get_blender_path.py

-2
This file was deleted.

get_blender_python.py

-3
This file was deleted.

paper.bib

+12
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,15 @@ @misc{phobosrepo
1111
year = {2019},
1212
howpublished = {\url{https://github.com/dfki-ric/phobos}}
1313
}
14+
15+
@article{Szadkowski2020,
16+
url = {https://doi.org/10.21105/joss.01326},
17+
year = {2020},
18+
publisher = {The Open Journal},
19+
volume = {5},
20+
number = {45},
21+
pages = {1326},
22+
author = {Kai von Szadkowski and Simon Reichel},
23+
title = {Phobos: A tool for creating complex robot models},
24+
journal = {Journal of Open Source Software}
25+
}

requirements.txt

-21
This file was deleted.

setup.py

+21-140
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/python
1+
#!/usr/bin/python3
22

33
# -------------------------------------------------------------------------------
44
# This file is part of Phobos, a Blender Add-On to edit robot models.
@@ -9,12 +9,9 @@
99
# -------------------------------------------------------------------------------
1010
import json
1111
import os
12-
import sys
13-
import shutil
1412
import setuptools
1513
import subprocess
1614
from pathlib import Path
17-
from copy import deepcopy
1815

1916

2017
# utilities
@@ -30,105 +27,27 @@ def get_git_branch():
3027
return subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']).strip().decode("utf-8")
3128

3229

33-
def check_blender_agreement(answer):
34-
if not answer.lower() in ["y", "yes"]:
35-
print("Blender installation cancelled!")
36-
print("If you want to install the phobos blender "
37-
"add-on later or manually follow the following steps:\n"
38-
"1) Zip the phobos directory in this repository\n"
39-
"2) Open blender\n"
40-
"3) Go to preferences->Add-ons\n"
41-
"4) Click 'Install' and select the freshly zipped phobos.zip file\n"
42-
" Blender will now install the phobos add-on with all its dependencies.\n"
43-
"5) Click the checkbox to activate the phobos-add-on")
44-
sys.exit()
45-
return True
46-
47-
48-
def exec_shell_cmd(command):
49-
if sys.platform.startswith("linux"):
50-
command = [" ".join(str(x) for x in command)]
51-
proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
52-
(out, err) = proc.communicate()
53-
return out.decode().strip()
54-
55-
56-
def install_requirement(py_exec, package_name, upgrade_pip=False, lib=None):
57-
# Ensure pip is installed
58-
exec_shell_cmd([py_exec, "-m", "ensurepip", "--user"])
59-
# Update pip (not mandatory)
60-
if upgrade_pip:
61-
print(" Upgrading pip...")
62-
exec_shell_cmd([py_exec, "-m", "pip", "install", "--upgrade", "pip"])
63-
# Install package
64-
print(" Installing package", package_name)
65-
if lib is None:
66-
exec_shell_cmd([py_exec, "-m", "pip", "install", package_name])
67-
else:
68-
exec_shell_cmd([py_exec, "-m", "pip", "install", f"--target={str(lib)}", package_name])
69-
70-
71-
def check_requirements(py_exec, optional=False, upgrade_pip=False, lib=None):
72-
print("Checking requirements:")
73-
import importlib
74-
requirements = [
75-
"networkx",
76-
"numpy",
77-
"scipy",
78-
"trimesh",
79-
"pydot",
80-
"setuptools",
81-
"collada"
82-
]
83-
optional_requirements = [
84-
"pyyaml",
85-
"pybullet",
86-
"open3d",
87-
"python-fcl"
88-
]
89-
reqs = [requirements]
90-
if optional:
91-
reqs += [optional_requirements]
92-
if upgrade_pip:
93-
print(" Upgrading pip...")
94-
exec_shell_cmd([py_exec, "-m", "pip", "install", "--upgrade", "pip"])
95-
for r in reqs:
96-
for import_name, req_name in r.items():
97-
print(" Checking", import_name)
98-
install_requirement(py_exec, req_name, upgrade_pip=False, lib=lib)
99-
# try:
100-
# if importlib.util.find_spec(import_name) is None:
101-
# install_requirement(py_exec, req_name, upgrade_pip=False, lib=lib)
102-
# except AttributeError:
103-
# loader = importlib.find_loader(import_name)
104-
# if not issubclass(type(loader), importlib.machinery.SourceFileLoader):
105-
# install_requirement(py_exec, req_name, upgrade_pip=False, lib=lib)
106-
importlib.invalidate_caches()
107-
108-
109-
def fetch_path_from_blender_script(blender_exec, script, keyword="blender"):
110-
out = exec_shell_cmd([blender_exec, "--background", "--python", script])
111-
path = None
112-
for line in out.split("\n"):
113-
line = line.strip()
114-
if line == "":
115-
continue
116-
if line.endswith("\r"):
117-
line = line.replace("\r", "")
118-
if line.startswith("/") and keyword in line.lower():
119-
path = Path(line)
120-
break
121-
return path
122-
123-
12430
def main(args):
12531
# data
12632
with open("README.md", "r") as fh:
12733
long_description = fh.read()
12834
codemeta = json.load(open("codemeta.json", "r"))
129-
deps = json.load(open("blender_requirements.json", "r"))
130-
requirements = deps["requirements"]
131-
optional_requirements = deps["optional_requirements"]
35+
requirements = {
36+
"yaml": "pyyaml",
37+
"networkx": "networkx", # optional for blender
38+
"numpy": "numpy",
39+
"scipy": "scipy",
40+
"trimesh": "trimesh", # optional for blender
41+
"pkg_resources": "setuptools",
42+
"collada": "pycollada",
43+
"pydot": "pydot"
44+
}
45+
optional_requirements = {
46+
"yaml": "pyyaml",
47+
"pybullet": "pybullet", # optional for blender
48+
"open3d": "open3d", # optional for blender
49+
"python-fcl": "python-fcl", # optional for blender
50+
}
13251
this_dir = Path(__file__).parent
13352

13453
##################
@@ -160,53 +79,15 @@ def main(args):
16079
]
16180
}
16281
}
163-
# # autoproj handling
164-
# if not "AUTOPROJ_CURRENT_ROOT" in os.environ:
165-
# kwargs["install_requires"] = list(requirements.values()) #+ list(optional_requirements.keys())
82+
# autoproj handling
83+
if not "AUTOPROJ_CURRENT_ROOT" in os.environ:
84+
kwargs["install_requires"] = list(requirements.values())
85+
kwargs["extras_require"] = {'console_scripts': list(optional_requirements.keys())}
16686

16787
setuptools.setup(
16888
**kwargs
16989
)
17090

171-
if "--blender" in args:
172-
#################
173-
# blender addon #
174-
#################
175-
# autoproj installation can not handle user inputs
176-
if "AUTOPROJ_CURRENT_ROOT" in os.environ:
177-
sys.exit()
178-
179-
blender_path = None
180-
print("Thanks for installing phobos!\n\nTrying now to install blender addon")
181-
auto_found = False
182-
for cmd in ["which", "where", "Get-Command"]:
183-
out = Path(exec_shell_cmd([cmd, "blender"]))
184-
if out.exists() and "blender" in str(out).lower():
185-
if input(f"Take this blender version '{out}'? (y/n)>").lower() in ["y", "yes"]:
186-
auto_found = True
187-
break
188-
while not auto_found or not out.exists() or not "blender" in str(out).lower():
189-
auto_found = True
190-
print("Could not retrieve blender executable from this path:", out)
191-
out = Path(input("Please provide the path to your blender executable: ").strip())
192-
blender_path = deepcopy(out)
193-
scripts_path = fetch_path_from_blender_script(blender_path, this_dir/"get_blender_path.py")
194-
modules_path = scripts_path / "modules"
195-
addons_path = scripts_path / "addons"
196-
print("Found the following blender installation directories:")
197-
print(scripts_path)
198-
print(modules_path)
199-
print(addons_path)
200-
if check_blender_agreement(input("Do you want to proceed? (y/n)>").strip()):
201-
#install phobos
202-
target = addons_path/"phobos"
203-
if target.exists():
204-
shutil.rmtree(target)
205-
shutil.copytree(this_dir/"phobos", target)
206-
# install requirements
207-
python_path = fetch_path_from_blender_script(blender_path, this_dir/"get_blender_python.py")
208-
check_requirements(python_path, upgrade_pip=True, lib=modules_path)
209-
21091

21192
if __name__ == "__main__":
21293
import sys

0 commit comments

Comments
 (0)