Skip to content

Commit

Permalink
Merge branch 'master' into pip_version
Browse files Browse the repository at this point in the history
  • Loading branch information
k-okada committed Dec 21, 2019
2 parents 4514b4d + fbeb43a commit 618583a
Show file tree
Hide file tree
Showing 28 changed files with 809 additions and 117 deletions.
1 change: 1 addition & 0 deletions .travis/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ do_install()
set -e

if [[ $TRAVIS_OS_NAME == 'osx' && $PYTHON_INSTALLER == 'pyenv' ]]; then
brew update
brew install pyenv-virtualenv
pyenv versions
eval "$(pyenv init -)"
Expand Down
42 changes: 42 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,45 @@
0.18.0 (2019-11-20)
-------------------
- split -modules into separate Debian package
- https://github.com/ros-infrastructure/rosdep/pull/731
- fix macOS CI
- https://github.com/ros-infrastructure/rosdep/pull/730

0.17.0 (2019-10-18)
-------------------
- Fix TypeError on ROS Kinetic.
- https://github.com/ros-infrastructure/rosdep/issues/721
- Pip installer uses ROS_PYTHON_VERSION
- https://github.com/ros-infrastructure/rosdep/issues/709

0.16.2 (2019-10-18)
-------------------
- Bump rospkg dependency to guarantee all platforms are available..
- https://github.com/ros-infrastructure/rosdep/issues/717
- Set ROS_PYTHON_VERSION if unset.
- https://github.com/ros-infrastructure/rosdep/issues/708

0.16.1 (2019-09-19)
-------------------

- Fix problem with release uploaded to PyPI.
- https://github.com/ros-infrastructure/rosdep/issues/705

0.16.0 (2019-09-19)
-------------------
- Add support for Nix/NixOS.
- https://github.com/ros-infrastructure/rosdep/pull/697
- Update supported platforms.
- Dropped platforms older than Xenial.
- Added Ubuntu Cosmic, Disco, and Eoan.
- https://github.com/ros-infrastructure/rosdep/pull/700
- Add sudo dependency in debian packages.
- https://github.com/ros-infrastructure/rosdep/pull/680
- Improve support for AMENT_PREFIX_PATH used in ROS 2.
- https://github.com/ros-infrastructure/rosdep/pull/699
- Add support for the --ignore-src argument for the keys verb.
- https://github.com/ros-infrastructure/rosdep/pull/686

0.15.2 (2019-05-17)
-------------------
- Migrate to yaml.safe_load to avoid yaml.load vulnerabilities.
Expand Down
51 changes: 30 additions & 21 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
import os
from setuptools import setup

exec(open(os.path.join(os.path.dirname(__file__), 'src', 'rosdep2', '_version.py')).read())

setup(
name='rosdep',
version=__version__, # noqa:F821
packages=['rosdep2', 'rosdep2.platforms'],
package_dir={'': 'src'},
install_requires=['catkin_pkg >= 0.4.0', 'rospkg >= 1.1.8', 'rosdistro >= 0.7.0', 'PyYAML >= 3.1'],
test_suite='nose.collector',
test_requires=['mock', 'nose >= 1.0'],
scripts=['scripts/rosdep', 'scripts/rosdep-source'],
author='Tully Foote, Ken Conley',
author_email='tfoote@osrfoundation.org',
url='http://wiki.ros.org/rosdep',
keywords=['ROS'],
classifiers=[
kwargs = {
'name': 'rosdep',
# same version as in:
# - src/rosdep2/__init__.py
# - stdeb.cfg
'version': '0.18.0',
'packages': ['rosdep2', 'rosdep2.ament_packages', 'rosdep2.platforms'],
'package_dir': {'': 'src'},
'install_requires': ['catkin_pkg >= 0.4.0', 'rospkg >= 1.1.10', 'rosdistro >= 0.7.5', 'PyYAML >= 3.1'],
'test_suite': 'nose.collector',
'test_requires': ['mock', 'nose >= 1.0'],
'scripts': ['scripts/rosdep', 'scripts/rosdep-source'],
'author': 'Tully Foote, Ken Conley',
'author_email': 'tfoote@osrfoundation.org',
'url': 'http://wiki.ros.org/rosdep',
'keywords': ['ROS'],
'classifiers': [
'Programming Language :: Python',
'License :: OSI Approved :: BSD License'],
description='rosdep package manager abstraction tool for ROS',
long_description='Command-line tool for installing system '
'dependencies on a variety of platforms.',
license='BSD'
)
'description': 'rosdep package manager abstraction tool for ROS',
'long_description': 'Command-line tool for installing system '
'dependencies on a variety of platforms.',
'license': 'BSD',
}
if 'SKIP_PYTHON_MODULES' in os.environ:
kwargs['packages'] = []
kwargs['package_dir'] = {}
if 'SKIP_PYTHON_SCRIPTS' in os.environ:
kwargs['name'] += '_modules'
kwargs['scripts'] = {}

setup(**kwargs)
5 changes: 3 additions & 2 deletions src/rosdep2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ def create_default_installer_context(verbose=False):
from .platforms import arch
from .platforms import cygwin
from .platforms import debian
from .platforms import openembedded
from .platforms import gentoo
from .platforms import nix
from .platforms import openembedded
from .platforms import opensuse
from .platforms import osx
from .platforms import pip
Expand All @@ -70,7 +71,7 @@ def create_default_installer_context(verbose=False):
from .platforms import slackware
from .platforms import source

platform_mods = [alpine, arch, cygwin, debian, gentoo, openembedded, opensuse, osx, redhat, slackware, freebsd]
platform_mods = [alpine, arch, cygwin, debian, gentoo, nix, openembedded, opensuse, osx, redhat, slackware, freebsd]
installer_mods = [source, pip, gem] + platform_mods

context = InstallerContext()
Expand Down
5 changes: 4 additions & 1 deletion src/rosdep2/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
__version__ = '0.15.2'
# same version as in:
# - setup.py
# - stdeb.cfg
__version__ = '0.18.0'
5 changes: 5 additions & 0 deletions src/rosdep2/ament_packages/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Code within is folder is essentially copied directly from the `ament_package` repo, or more specificity the `ament_index_python` package. See original source here:

https://github.com/ament/ament_index/tree/86f5a6712690830fe3e19752f70cfcdb00a3d223/ament_index_python/ament_index_python

TODO: reconcile duplicate code via shared codebase
27 changes: 27 additions & 0 deletions src/rosdep2/ament_packages/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2015 Open Source Robotics Foundation, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from .constants import AMENT_PREFIX_PATH_ENV_VAR
from .constants import RESOURCE_INDEX_SUBFOLDER
from .packages import get_packages_with_prefixes
from .resources import get_resources
from .search_paths import get_search_paths

__all__ = [
'get_packages_with_prefixes',
'get_resources',
'get_search_paths',
'AMENT_PREFIX_PATH_ENV_VAR',
'RESOURCE_INDEX_SUBFOLDER',
]
17 changes: 17 additions & 0 deletions src/rosdep2/ament_packages/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2015 Open Source Robotics Foundation, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


RESOURCE_INDEX_SUBFOLDER = 'share/ament_index/resource_index'
AMENT_PREFIX_PATH_ENV_VAR = 'AMENT_PREFIX_PATH'
27 changes: 27 additions & 0 deletions src/rosdep2/ament_packages/packages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2017 Open Source Robotics Foundation, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os

from .resources import get_resources


def get_packages_with_prefixes():
"""
Return a dict of package names to the prefixes in which they are found.
:returns: dict of package names to their prefixes
:rtype: dict
"""
return get_resources('packages')
43 changes: 43 additions & 0 deletions src/rosdep2/ament_packages/resources.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright 2015 Open Source Robotics Foundation, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os

from .constants import RESOURCE_INDEX_SUBFOLDER

from .search_paths import get_search_paths


def get_resources(resource_type):
"""
Get the resource names of all resources of the specified type.
:param resource_type: the type of the resource
:type resource_type: str
:returns: dict of resource names to the prefix path they are in
:raises: :exc:`EnvironmentError`
"""
assert resource_type, 'The resource type must not be empty'
resources = {}
for path in get_search_paths():
resource_path = os.path.join(path, RESOURCE_INDEX_SUBFOLDER, resource_type)
if os.path.isdir(resource_path):
for resource in os.listdir(resource_path):
# Ignore subdirectories, and anything starting with a dot
if os.path.isdir(os.path.join(resource_path, resource)) \
or resource.startswith('.'):
continue
if resource not in resources:
resources[resource] = path
return resources
33 changes: 33 additions & 0 deletions src/rosdep2/ament_packages/search_paths.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2015 Open Source Robotics Foundation, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os

from .constants import AMENT_PREFIX_PATH_ENV_VAR


def get_search_paths():
"""
Get the paths from the environment variable '{AMENT_PREFIX_PATH_ENV_VAR}'.
:returns: list of paths
:raises: :exc:`EnvironmentError`
""".format(AMENT_PREFIX_PATH_ENV_VAR=AMENT_PREFIX_PATH_ENV_VAR)
ament_prefix_path = os.environ.get(AMENT_PREFIX_PATH_ENV_VAR)
if not ament_prefix_path:
raise EnvironmentError(
"Environment variable '{}' is not set or empty".format(AMENT_PREFIX_PATH_ENV_VAR))

paths = ament_prefix_path.split(os.pathsep)
return [p for p in paths if p and os.path.exists(p)]
101 changes: 101 additions & 0 deletions src/rosdep2/cache_tools.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Copyright (c) 2012, Willow Garage, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the Willow Garage, Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

import hashlib
import os
import tempfile

from .core import CachePermissionError

try:
import cPickle as pickle
except ImportError:
import pickle

PICKLE_CACHE_EXT = '.pickle'


def compute_filename_hash(key_filenames):
sha_hash = hashlib.sha1()
if isinstance(key_filenames, list):
for key in key_filenames:
sha_hash.update(key.encode())
else:
sha_hash.update(key_filenames.encode())
return sha_hash.hexdigest()


def write_cache_file(source_cache_d, key_filenames, rosdep_data):
"""
:param source_cache_d: directory to write cache file to
:param key_filenames: filename (or list of filenames) to be used in hashing
:param rosdep_data: dictionary of data to serialize as YAML
:returns: name of file where cache is stored
:raises: :exc:`OSError` if cannot write to cache file/directory
:raises: :exc:`IOError` if cannot write to cache file/directory
"""
if not os.path.exists(source_cache_d):
os.makedirs(source_cache_d)
key_hash = compute_filename_hash(key_filenames)
filepath = os.path.join(source_cache_d, key_hash)
try:
write_atomic(filepath + PICKLE_CACHE_EXT, pickle.dumps(rosdep_data, 2), True)
except OSError as e:
raise CachePermissionError('Failed to write cache file: ' + str(e))
try:
os.unlink(filepath)
except OSError:
pass
return filepath


def write_atomic(filepath, data, binary=False):
# write data to new file
fd, filepath_tmp = tempfile.mkstemp(prefix=os.path.basename(filepath) + '.tmp.', dir=os.path.dirname(filepath))

if (binary):
fmode = 'wb'
else:
fmode = 'w'

with os.fdopen(fd, fmode) as f:
f.write(data)
f.close()

try:
# switch file atomically (if supported)
os.rename(filepath_tmp, filepath)
except OSError:
# fall back to non-atomic operation
try:
os.unlink(filepath)
except OSError:
pass
try:
os.rename(filepath_tmp, filepath)
except OSError:
os.unlink(filepath_tmp)

0 comments on commit 618583a

Please sign in to comment.