Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Setuptools packaging improvements - make each st2 component packagable and installable via package #1677

Closed
wants to merge 58 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
036177d
added requirements.txt for specific components
dennybaa Jun 17, 2015
93a1baa
setup.py new requirements idea
dennybaa Jun 17, 2015
159d797
fixate-requirements.py
dennybaa Jun 22, 2015
4d973be
import cleanups
dennybaa Jun 22, 2015
d3dec45
Merge branch 'master' of github.com:StackStorm/st2 into setuptools-fixes
dennybaa Jun 24, 2015
48a07a6
requirements move on, source merging with fixate-requirements.py
dennybaa Jun 24, 2015
a51c4f2
renaming requirements.txt -> in-requirements.txt, makefiles fixes
dennybaa Jun 24, 2015
68b0826
removing versions from in-requirements.txt
dennybaa Jun 26, 2015
09593f8
setup.py unify
dennybaa Jun 26, 2015
d43f06d
version bump
dennybaa Jun 26, 2015
9f3f8fa
Merge branch 'setuptools-fixes' of https://github.com/dennybaa/st2 in…
Kami Jun 28, 2015
5c94d84
Fix typos.
Kami Jun 29, 2015
905915e
Log where the requirements are written, fix typos and sort the requir…
Kami Jun 29, 2015
66f6393
Make file executable.
Kami Jun 29, 2015
35a58f8
Instead of copy and pasting code around in setup.py files, add all th…
Kami Jun 29, 2015
8e4cf58
Add new sdist-requirements Make target which copies over required fil…
Kami Jun 29, 2015
d5fba8e
Add long_description attribute to each compnent setup.py which is com…
Kami Jun 29, 2015
b7e3e58
Only copy readme over if component specific readme doesn't exist.
Kami Jun 29, 2015
37c74b8
Add license and url attribute to each setup.py file.
Kami Jun 29, 2015
a6cc390
Add new "sdist" make target which created .tar.gz and wheel archive f…
Kami Jun 29, 2015
a767ef4
Port readme to rst format.
Kami Jun 29, 2015
cbd3dde
Use __version__ attribute from package __init__.py file instead of using
Kami Jun 29, 2015
fa51157
Skip st2tests/ component for packaging.
Kami Jun 29, 2015
f339c67
Remove obsolete version file.
Kami Jun 29, 2015
e7efe46
Use new README.rst file.
Kami Jun 29, 2015
6041861
Replace dict comprehension with syntax which also works on 2.6.
Kami Jun 29, 2015
23dc8e3
README.md -> README.rst.
Kami Jun 29, 2015
cfbdafc
Make sure we run fixate-requirements script in each component directory.
Kami Jun 29, 2015
7fb6bec
Make sure we are using the latest version of pip on travis.
Kami Jun 29, 2015
1117555
Update .gitignore.
Kami Jun 29, 2015
7f0875b
Use python 2.6 compatible format syntax.
Kami Jun 29, 2015
65c9123
Remove trailing slash.
Kami Jun 29, 2015
0adc895
Merge branch 'master' into dennybaa-setuptools-fixes
Kami Jun 30, 2015
8973084
Sort the lines and not the requirements so the order is always the same.
Kami Jun 30, 2015
dac1d72
Add missing gitpython requirement to st2action requirements.
Kami Jun 30, 2015
1aa1ad8
Make sure we are using latest version of pip inside our virtualenv.
Kami Jun 30, 2015
25a8ab2
Add missing lockfile dependency.
Kami Jun 30, 2015
ca732b7
Add missing requirements needed by linux pack.
Kami Jun 30, 2015
d2a5dd8
Add "fixate-requirements" global make target which generated requirem…
Kami Jun 30, 2015
c0abf83
Add some docs on managing Python requirements.
Kami Jun 30, 2015
65d5669
Update .gitignore.
Kami Jun 30, 2015
35bb74e
Add generated requirements files.
Kami Jun 30, 2015
21304f7
Merge pull request #1668 from StackStorm/dennybaa-setuptools-fixes
Kami Jun 30, 2015
421b5d6
Use python from virtualenv when running requirements make target.
Kami Jun 30, 2015
2d9d311
Directly use pip binary from vev instead of activating it first.
Kami Jun 30, 2015
f865c35
Update .gitignore, include dist_utils.py module and __init__.py file …
Kami Jun 30, 2015
f7dfa84
Update "make debs" and "make rpms" to use virtualenv - this way we al…
Kami Jun 30, 2015
c5c37cb
Add stub README.rst file to every component directory. Update setup.p…
Kami Jun 30, 2015
d692f5d
Add classifier back to st2client setup.py.
Kami Jun 30, 2015
5c862ca
Explicitly include readme, changelog and license file in every manifest.
Kami Jun 30, 2015
02c2fa5
Update all the manifest files to exclude *.pyc files and to include
Kami Jun 30, 2015
faf502d
Update all setup.py modules to apply vagrant workaround so "make deb"…
Kami Jun 30, 2015
012630d
Merge branch 'master' into setuptools_packaging_improvements
Kami Jul 1, 2015
91635aa
Update st2client makefile to correctly purhge the tar.gz dist file.
Kami Jul 1, 2015
2570bbb
Update st2common Makefile to correctly clean up after creating a pack…
Kami Jul 1, 2015
4d2785f
Fix st2common debian install file, contrib/tests doesn't exist anymore.
Kami Jul 1, 2015
380ea5a
Merge branch 'master' into setuptools_packaging_improvements
Kami Jul 1, 2015
210fa98
Explicity specify path to python interpreter since we now build packa…
Kami Jul 1, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,8 @@ nosetests.xml
.DS_Store
._*


# Files which are copied over during sdist phase
st2*/LICENSE
st2*/CONTRIBUTING.rst
st2*/CHANGELOG.rst
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ env:
cache:
directories:
- $HOME/.pip-cache/
install:
- pip install --upgrade pip
script:
- ./scripts/travis.sh
services:
Expand Down
41 changes: 41 additions & 0 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,44 @@ documentation, examples, ...).
For more information on how to contribute and the guidelines you should follow,
please visit the Development section of our documentation -
http://docs.stackstorm.com/development/index.html

Managing Python dependencies
----------------------------

.. note::

``requirements.txt`` files are generated automatically using
``scripts/fixate-requirements.py`` script and should't be editeed manually.

To manage Python dependencies for each StackStorm component, we use the
following files:

1. ``fixed-requirements.txt`` - A file which pins all the requirements to a
specific version. Keep in mind that this file is used by all the components.
This way we make sure different components always use the same version of a
particular dependency.
2. ``st2*/in-requirements.txt`` - Component specific requirements file. This
file contains a full list of the dependencies which are needed by this
particular component.
3. ``st2*/requirements.txt`` - Final component requirements file which is
generated by processing fixed-requirements.txt and in-requirements.txt file.
Note: This file is automatically generated and should not be edited
manually.
4. ``requirements.txt`` - Final requirements file for all the components which
is generated by processing fixed-requirements.txt and all the component
in-requirements.txt files. Note: This file is automatically generated and
should not be edited manually.

Adding a new component dependency
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To add a new dependency for a particular component, you should perform the following steps:

1. Add a name / link to the dependency to component ``in-requirements.txt``
fire. For example ``st2actions/in-requirements.txt``
2. Pin this requirement to a specific version in ``fixed-requirements.txt``
file.
3. Generate final ``requirements.txt`` file for that component by running
``make requirements`` target in the component directory. For example:
``cd st2actions ; make requirements``.
4. Add a commit generated requirements.txt file.
78 changes: 67 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ COMPONENTS_TEST := $(foreach component,$(filter-out $(COMPONENT_SPECIFIC_TESTS),

PYTHON_TARGET := 2.7

REQUIREMENTS := requirements.txt test-requirements.txt st2client/requirements.txt
REQUIREMENTS := requirements.txt test-requirements.txt

PIP_OPTIONS := $(ST2_PIP_OPTIONS)

Expand Down Expand Up @@ -171,9 +171,13 @@ requirements: virtualenv $(REQUIREMENTS)
@echo
@echo "==================== requirements ===================="
@echo

# Merge into one st2 components-wide requirements.txt file.
$(VIRTUALENV_DIR)/bin/python ./scripts/fixate-requirements.py -s st2*/in-requirements.txt -f fixed-requirements.txt

for req in $(REQUIREMENTS); do \
echo "Installing $$req..." ; \
. $(VIRTUALENV_DIR)/bin/activate && pip install $(PIP_OPTIONS) $$req ; \
$(VIRTUALENV_DIR)/bin/pip install $(PIP_OPTIONS) $$req ; \
done

.PHONY: virtualenv
Expand Down Expand Up @@ -205,6 +209,12 @@ $(VIRTUALENV_DIR)/bin/activate:
echo ' functions -e old_deactivate' >> $(VIRTUALENV_DIR)/bin/activate.fish
echo 'end' >> $(VIRTUALENV_DIR)/bin/activate.fish
touch $(VIRTUALENV_DIR)/bin/activate.fish

# Make sure we use latest version of pip
$(VIRTUALENV_DIR)/bin/pip install --upgrade pip

# Install stdeb st2client build dependency
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kami what's stdeb?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a Python package we use in combination with setup.py to build a Debian package for st2client.

I wasn't aware of it before yesterday either. I added it here to make "make deb" self sustaining and now it also works in a local environment. Previously, this package would only magically get installed inside one of our CI workflows...

$(VIRTUALENV_DIR)/bin/pip install stdeb

.PHONY: tests
tests: pytests
Expand Down Expand Up @@ -268,6 +278,52 @@ itests: requirements .itests
. $(VIRTUALENV_DIR)/bin/activate; nosetests -sv $$component/tests/integration || exit 1; \
done

.PHONY: fixate-requirements
fixate-requirements:
# Fixate global requirements and requirements for each component

# Merge into one st2 components-wide requirements.txt file.
python ./scripts/fixate-requirements.py -s st2*/in-requirements.txt -f fixed-requirements.txt

# Fixate requirements for each component
@for component in $(COMPONENTS_TEST); do\
test -s $$component/Makefile && (pushd $$component && make -f Makefile requirements && popd);\
done

.PHONY: .sdist-requirements
.sdist-requirements:
# Run make requirements in each component directory
@for component in $(COMPONENTS_TEST); do\
test -s $$component/Makefile && (pushd $$component && make -f Makefile requirements && popd);\
done

# 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 __init__.py with a global shared __version__ attribute
@for component in $(COMPONENTS_TEST); do\
cp -f ./st2common/st2common/__init__.py $$component/$$component; \
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

.PHONY: sdist
sdist: .sdist-requirements .sdist

.PHONY: .sdist
.sdist:
@for component in $(COMPONENTS_TEST); do\
python $$component/setup.py sdist;\
python $$component/setup.py bdist_wheel;\
done

.PHONY: mistral-itests
mistral-itests: requirements .mistral-itests

Expand All @@ -280,27 +336,27 @@ mistral-itests: requirements .mistral-itests
. $(VIRTUALENV_DIR)/bin/activate; nosetests -s -v st2tests/integration || exit 1;

.PHONY: rpms
rpms:
rpms: virtualenv
@echo
@echo "==================== rpm ===================="
@echo
rm -Rf ~/rpmbuild
$(foreach COM,$(COMPONENTS), pushd $(COM); make rpm; popd;)
pushd st2client && make rpm && popd
$(foreach COM,$(COMPONENTS), pushd $(COM); . ../$(VIRTUALENV_DIR)/bin/activate && make rpm; popd;)
pushd st2client && . ../$(VIRTUALENV_DIR)/bin/activate && make rpm && popd

rhel-rpms:
rhel-rpms: virtualenv
@echo
@echo "==================== rpm ===================="
@echo
rm -Rf ~/rpmbuild
$(foreach COM,$(COMPONENTS), pushd $(COM); make rhel-rpm; popd;)
pushd st2client && make rhel-rpm && popd
$(foreach COM,$(COMPONENTS), pushd $(COM); . ../$(VIRTUALENV_DIR)/bin/activate && make rhel-rpm; popd;)
pushd st2client && . ../$(VIRTUALENV_DIR)/bin/activate && make rhel-rpm && popd

.PHONY: debs
debs:
debs: virtualenv
@echo
@echo "==================== deb ===================="
@echo
rm -Rf ~/debbuild
$(foreach COM,$(COMPONENTS), pushd $(COM); make deb; popd;)
pushd st2client && make deb && popd
$(foreach COM,$(COMPONENTS), pushd $(COM); . ../$(VIRTUALENV_DIR)/bin/activate && make deb; popd;)
pushd st2client && . ../$(VIRTUALENV_DIR)/bin/activate && make deb && popd
68 changes: 0 additions & 68 deletions README.md

This file was deleted.

Loading