Skip to content

Commit

Permalink
ckport vagrant workaround from #1677 and re-use dist_utils.py instead of
Browse files Browse the repository at this point in the history
duplicating the code across setup.py files.

Note: This file is copied over from the common location to each component
directory during the build step.
  • Loading branch information
Kami committed Sep 2, 2015
1 parent 1ef5c30 commit f427653
Show file tree
Hide file tree
Showing 23 changed files with 442 additions and 80 deletions.
17 changes: 16 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ distclean: clean
rm -rf $(VIRTUALENV_DIR)

.PHONY: requirements
requirements: virtualenv
requirements: virtualenv .sdist-requirements
@echo
@echo "==================== requirements ===================="
@echo
Expand Down Expand Up @@ -354,3 +354,18 @@ debs:
rm -Rf ~/debbuild
$(foreach COM,$(COMPONENTS), pushd $(COM); make deb; popd;)
pushd st2client && make deb && popd

# >>>>
.PHONY: .sdist-requirements
.sdist-requirements:
# Copy over shared dist utils module which is needed by setup.py
@for component in $(COMPONENTS_TEST); do\
cp -f ./scripts/dist_utils.py $$component/dist_utils.py;\
done

# Copy over CHANGELOG.RST, CONTRIBUTING.RST and LICENSE file to each component directory
#@for component in $(COMPONENTS_TEST); do\
# test -s $$component/README.rst || cp -f README.rst $$component/; \
# cp -f CONTRIBUTING.rst $$component/; \
# cp -f LICENSE $$component/; \
#done
1 change: 1 addition & 0 deletions st2actions/MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Include all files under the source tree by default.
# Another behaviour can be used in the future though.
recursive-include st2actions *.* *
include dist_utils.py
include requirements.txt
include README.rst
include CHANGELOG.rst
Expand Down
48 changes: 48 additions & 0 deletions st2actions/dist_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# -*- coding: utf-8 -*-
# Licensed to the StackStorm, Inc ('StackStorm') under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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 pip.req import parse_requirements

__all__ = [
'fetch_requirements',
'apply_vagrant_workaround'
]


def fetch_requirements(requirements_file_path):
"""
Return a list of requirements and links by parsing the provided requirements file.
"""
links = []
reqs = []
for req in parse_requirements(requirements_file_path, session=False):
if req.link:
links.append(str(req.link))
reqs.append(str(req.req))
return (reqs, links)


def apply_vagrant_workaround():
"""
Function which detects if the script is being executed inside vagrant and if it is, it deletes
"os.link" attribute.
Note: Without this workaround, setup.py sdist will fail when running inside a shared directory
(nfs / virtualbox shared folders).
"""
if os.environ.get('USER', None) == 'vagrant':
del os.link
19 changes: 6 additions & 13 deletions st2actions/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,20 @@
# limitations under the License.

import os.path
from pip.req import parse_requirements

from setuptools import setup, find_packages

from dist_utils import fetch_requirements
from dist_utils import apply_vagrant_workaround
from st2actions import __version__

BASE_DIR = os.path.dirname(os.path.abspath(__file__))
ST2_COMPONENT = os.path.basename(BASE_DIR)
REQUIREMENTS_FILE = os.path.join(BASE_DIR, 'requirements.txt')

install_reqs, dep_links = fetch_requirements(REQUIREMENTS_FILE)

def fetch_requirements():
links = []
reqs = []
for req in parse_requirements('requirements.txt', session=False):
if req.link:
links.append(str(req.link))
reqs.append(str(req.req))
return (reqs, links)

install_reqs, dep_links = fetch_requirements()


apply_vagrant_workaround()
setup(
name=ST2_COMPONENT,
version=__version__,
Expand Down
1 change: 1 addition & 0 deletions st2api/MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Include all files under the source tree by default.
# Another behaviour can be used in the future though.
recursive-include st2api *.* *
include dist_utils.py
include requirements.txt
include README.rst
include CHANGELOG.rst
Expand Down
48 changes: 48 additions & 0 deletions st2api/dist_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# -*- coding: utf-8 -*-
# Licensed to the StackStorm, Inc ('StackStorm') under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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 pip.req import parse_requirements

__all__ = [
'fetch_requirements',
'apply_vagrant_workaround'
]


def fetch_requirements(requirements_file_path):
"""
Return a list of requirements and links by parsing the provided requirements file.
"""
links = []
reqs = []
for req in parse_requirements(requirements_file_path, session=False):
if req.link:
links.append(str(req.link))
reqs.append(str(req.req))
return (reqs, links)


def apply_vagrant_workaround():
"""
Function which detects if the script is being executed inside vagrant and if it is, it deletes
"os.link" attribute.
Note: Without this workaround, setup.py sdist will fail when running inside a shared directory
(nfs / virtualbox shared folders).
"""
if os.environ.get('USER', None) == 'vagrant':
del os.link
19 changes: 6 additions & 13 deletions st2api/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,21 @@
# limitations under the License.

import os.path
from pip.req import parse_requirements

from setuptools import setup, find_packages

from dist_utils import fetch_requirements
from dist_utils import apply_vagrant_workaround
from st2api import __version__


BASE_DIR = os.path.dirname(os.path.abspath(__file__))
ST2_COMPONENT = os.path.basename(BASE_DIR)
REQUIREMENTS_FILE = os.path.join(BASE_DIR, 'requirements.txt')

install_reqs, dep_links = fetch_requirements(REQUIREMENTS_FILE)

def fetch_requirements():
links = []
reqs = []
for req in parse_requirements(REQUIREMENTS_FILE, session=False):
if req.link:
links.append(str(req.link))
reqs.append(str(req.req))
return (reqs, links)

install_reqs, dep_links = fetch_requirements()


apply_vagrant_workaround()
setup(
name=ST2_COMPONENT,
version=__version__,
Expand Down
1 change: 1 addition & 0 deletions st2auth/MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Include all files under the source tree by default.
# Another behaviour can be used in the future though.
recursive-include st2auth *.* *
include dist_utils.py
include requirements.txt
include README.rst
include CHANGELOG.rst
Expand Down
48 changes: 48 additions & 0 deletions st2auth/dist_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# -*- coding: utf-8 -*-
# Licensed to the StackStorm, Inc ('StackStorm') under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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 pip.req import parse_requirements

__all__ = [
'fetch_requirements',
'apply_vagrant_workaround'
]


def fetch_requirements(requirements_file_path):
"""
Return a list of requirements and links by parsing the provided requirements file.
"""
links = []
reqs = []
for req in parse_requirements(requirements_file_path, session=False):
if req.link:
links.append(str(req.link))
reqs.append(str(req.req))
return (reqs, links)


def apply_vagrant_workaround():
"""
Function which detects if the script is being executed inside vagrant and if it is, it deletes
"os.link" attribute.
Note: Without this workaround, setup.py sdist will fail when running inside a shared directory
(nfs / virtualbox shared folders).
"""
if os.environ.get('USER', None) == 'vagrant':
del os.link
18 changes: 6 additions & 12 deletions st2auth/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,21 @@
# limitations under the License.

import os.path
from pip.req import parse_requirements

from setuptools import setup, find_packages

from dist_utils import fetch_requirements
from dist_utils import apply_vagrant_workaround
from st2auth import __version__

BASE_DIR = os.path.dirname(os.path.abspath(__file__))
ST2_COMPONENT = os.path.basename(BASE_DIR)
REQUIREMENTS_FILE = os.path.join(BASE_DIR, 'requirements.txt')


def fetch_requirements():
links = []
reqs = []
for req in parse_requirements('requirements.txt', session=False):
if req.link:
links.append(str(req.link))
reqs.append(str(req.req))
return (reqs, links)

install_reqs, dep_links = fetch_requirements()
install_reqs, dep_links = fetch_requirements(REQUIREMENTS_FILE)


apply_vagrant_workaround()
setup(
name=ST2_COMPONENT,
version=__version__,
Expand Down
1 change: 1 addition & 0 deletions st2client/MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Include all files under the source tree by default.
# Another behaviour can be used in the future though.
recursive-include st2client *.* *
include dist_utils.py
include requirements.txt
include README.rst
include CHANGELOG.rst
Expand Down
48 changes: 48 additions & 0 deletions st2client/dist_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# -*- coding: utf-8 -*-
# Licensed to the StackStorm, Inc ('StackStorm') under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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 pip.req import parse_requirements

__all__ = [
'fetch_requirements',
'apply_vagrant_workaround'
]


def fetch_requirements(requirements_file_path):
"""
Return a list of requirements and links by parsing the provided requirements file.
"""
links = []
reqs = []
for req in parse_requirements(requirements_file_path, session=False):
if req.link:
links.append(str(req.link))
reqs.append(str(req.req))
return (reqs, links)


def apply_vagrant_workaround():
"""
Function which detects if the script is being executed inside vagrant and if it is, it deletes
"os.link" attribute.
Note: Without this workaround, setup.py sdist will fail when running inside a shared directory
(nfs / virtualbox shared folders).
"""
if os.environ.get('USER', None) == 'vagrant':
del os.link
17 changes: 4 additions & 13 deletions st2client/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,19 @@

import os.path

from pip.req import parse_requirements
from setuptools import setup, find_packages

from dist_utils import fetch_requirements
from dist_utils import apply_vagrant_workaround
from st2client import __version__

BASE_DIR = os.path.dirname(os.path.abspath(__file__))
ST2_COMPONENT = os.path.basename(BASE_DIR)
REQUIREMENTS_FILE = os.path.join(BASE_DIR, 'requirements.txt')

install_reqs, dep_links = fetch_requirements(REQUIREMENTS_FILE)

def fetch_requirements():
links = []
reqs = []
for req in parse_requirements(REQUIREMENTS_FILE, session=False):
if req.link:
links.append(str(req.link))
reqs.append(str(req.req))
return (reqs, links)

install_reqs, dep_links = fetch_requirements()


apply_vagrant_workaround()
setup(
name=ST2_COMPONENT,
version=__version__,
Expand Down
1 change: 1 addition & 0 deletions st2common/MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Include all files under the source tree by default.
# Another behaviour can be used in the future though.
recursive-include st2common *.* *
include dist_utils.py
include requirements.txt
include README.rst
include CHANGELOG.rst
Expand Down
Loading

0 comments on commit f427653

Please sign in to comment.