Skip to content

Commit

Permalink
Merge pull request #59 from openalea/issue49
Browse files Browse the repository at this point in the history
Move from path.py to pathlib
  • Loading branch information
thomasarsouze authored Oct 28, 2024
2 parents 21f47e5 + 3f8bdbd commit 457935b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 18 deletions.
28 changes: 18 additions & 10 deletions src/openalea/deploy/multisetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
import re
from subprocess import PIPE, Popen

from path import Path
# issue 49 : replace path by pathlib
# from path import Path
from pathlib import Path

#from openalea.deploy.console import color_terminal, nocolor, bold, purple, red, green, underline

Expand Down Expand Up @@ -71,7 +73,8 @@ def __init__(self, commands, packages=None, curdir='.', verbose=True):
>>> Multisetup(["install","--keep-going"], ['deploy', 'visualea'], '.', verbose=True)
"""
#default
self.curdir = Path(curdir).abspath()
#self.curdir = Path(curdir).abspath()
self.curdir = Path(curdir).resolve()
if isinstance(commands, list):
self.commands = list(commands)
elif isinstance(commands, str):
Expand Down Expand Up @@ -247,27 +250,32 @@ def run(self, color=True):

print('Will process the following directories: ',)
for directory in directories:
print(bold(directory.basename()), end=' ')
print(bold(directory.name), end=' ') # pathlib
# print(bold(directory.basename()), end=' ') # path.py
print('')

try:
for directory in directories:
try:
os.chdir(directory)
print(underline('Entering %s package'
% directory.basename()))
#print(underline('Entering %s package'
# % directory.basename()))
print(underline(f'Entering {directory.name} package'))

except OSError as e:
print(underline('Entering %s package'
% directory.basename()), end=' ')
print(red("cannot find this directory (%s)"
% directory.basename()))
#print(underline('Entering %s package'
# % directory.basename()), end=' ')
#print(red("cannot find this directory (%s)"
# % directory.basename()))
print(underline(f'Entering {directory.name} package'), end=' ')
print(red(f"cannot find this directory ({directory.name})"))
print(e)

print('Python exec : ', sys.executable)

#print underline('Entering %s package' % directory.basename())
for cmd in self.commands:
setup_command = '%s setup.py %s ' % (sys.executable, cmd)
setup_command = f'{sys.executable} setup.py {cmd} ' # % (sys.executable, cmd)
print("\tExecuting " + setup_command + '...processing', end=' ')

#Run setup.py with user commands
Expand Down
19 changes: 13 additions & 6 deletions src/openalea/deploy/shared_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
import os
from os.path import join as pj
from os.path import realpath, isdir, isfile

from pathlib import Path

"""
try:
from path import Path
except ImportError:
Expand All @@ -31,6 +35,7 @@
from openalea.core.path import path as Path
except ImportError:
from IPython.external.path import path as Path
"""

__license__ = "Cecill-C"
__revision__ = " $Id: gforge.py 2243 2010-02-08 17:08:47Z cokelaer $ "
Expand Down Expand Up @@ -86,22 +91,24 @@ def shared_data(package_path, filename=None, pattern=None,
package_path = package_path[0]
package_path = Path(package_path)
ff = package_path / share_path
ff = ff.realpath()
# ff = ff.realpath() # path.py
ff = ff.resolve()
shared_data_path = None
if ff.isdir():
#if ff.isdir():
if ff.is_dir():
if filename is None:
shared_data_path = ff
if pattern:
l = ff.glob(pattern)
l = list(ff.glob(pattern))
if l:
shared_data_path = l
else:
ff = ff / filename
ff = ff.realpath()
if ff.isfile():
ff = ff.resolve()
if ff.is_file():
shared_data_path = ff

if shared_data_path is None and (package_path / '__init__.py').isfile():
if shared_data_path is None and (package_path / '__init__.py').is_file():
shared_data_path = shared_data(package_path.parent, filename, pattern,
share_path)
if shared_data_path is None:
Expand Down
4 changes: 2 additions & 2 deletions src/openalea/deploy/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
major = 3
"""(int) Version major component."""

minor = 1
minor = 2
"""(int) Version minor component."""

post = 2
post = 0
"""(int) Version post or bugfix component."""

__version__ = ".".join([str(s) for s in (major, minor, post)])
Expand Down

0 comments on commit 457935b

Please sign in to comment.