Skip to content

Commit f36101d

Browse files
committed
Merge pull request #10 from cloudify-cosmo/allow-passing-arbitrary-pip-arguments
added the ability to pass additional pip wheel and pip install arguments
2 parents f67b4bf + a01b005 commit f36101d

File tree

8 files changed

+110
-44
lines changed

8 files changed

+110
-44
lines changed

CHANGELOG

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
21f000c (HEAD, tag: 0.2.1, origin/master, origin/HEAD, master, logger-fix) Update README.md
1+
f67b4bf (HEAD, tag: 0.2.3, origin/master, origin/HEAD, master, allow-passing-arbitrary-pip-arguments) Merge pull request #9 from cloudify-cosmo/fix-requirement-files-not-being-dealt-with-correctly
2+
8d87e55 (origin/fix-requirement-files-not-being-dealt-with-correctly, fix-requirement-files-not-being-dealt-with-correctly) fixed failure when trying to wheel a package that has dependencies in a requirements file
3+
5e92335 (tag: 0.2.2) Merge pull request #7 from cloudify-cosmo/logger-fix
4+
7d60140 (origin/logger-fix, logger-fix) changed module to package and now no longer overriding user's logger
5+
21f000c (tag: 0.2.1) Update README.md
26
e8b78eb Update README.md
37
0a8a55d Update README.md
48
95b384b Merge pull request #6 from cloudify-cosmo/CFY-3709-add-module-exclusion

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ wagon create -s cloudify-script-plugin==1.2 --keep-wheels -v --exclude cloudify-
3737
wagon create -s http://github.com/cloudify-cosmo/cloudify-script-plugin/archive/1.2.tar.gz -r . --validate
3838
# create an archive by retrieving the source from a local path and output the tar.gz file to /tmp/<PACKAGE>.tar.gz (defaults to <cwd>/<PACKAGE>.tar.gz) and provides explicit Python versions supported by the package (which usually defaults to the first two digits of the Python version used to create the archive.)
3939
wagon create -s ~/packages/cloudify-script-plugin/ -o /tmp/ --pyver 33 --pyver 26 --pyver 27
40+
# pass additional args to `pip wheel` (NOTE that conflicting arguments are not handled by wagon.)
41+
wagon create -s cloudify-script-plugin==1.2 -a '--retries 5'
4042
```
4143

4244
Regarding exclusions, note that excluding packages can result in an archive being non-installable. The user will be warned about this but creation will succeed. Creation validation, though (i.e. using the `--validate` flag), will fail and show an error incase the archive cannot be installed.
@@ -57,6 +59,8 @@ wagon install --help
5759
wagon install -s ~/tars/cloudify_script_plugin-1.2-py27-none-any.tar.gz --upgrade --ignore-platform
5860
# install a package from a url into an existing virtualenv.
5961
wagon install -s http://me.com/cloudify_script_plugin-1.2-py27-none-any-none-none.tar.gz --virtualenv my_venv -v
62+
# pass additional args to `pip install` (NOTE that conflicting arguments are not handled by wagon.)
63+
wagon create -s cloudify-script-plugin==1.2 -a '--no-cache-dir'
6064
```
6165

6266
Note that `--pre` is appended to the installation command to enable installation of prerelease versions.

README.rst

Lines changed: 53 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,29 @@ Examples
4343

4444
.. code:: shell
4545
46-
# create an archive by retrieving the source from PyPI and keep the downloaded wheels (kept under <cwd>/plugin) and exclude the cloudify-plugins-common and cloudify-rest-client modules from the archive.
46+
# create an archive by retrieving the source from PyPI and keep the downloaded wheels (kept under <cwd>/plugin) and exclude the cloudify-plugins-common and cloudify-rest-client packages from the archive.
4747
wagon create -s cloudify-script-plugin==1.2 --keep-wheels -v --exclude cloudify-plugins-common --exclude cloudify-rest-client
4848
# create an archive by retrieving the source from a URL and creating wheels from requirement files found within the archive. Then, validation of the archive takes place.
4949
wagon create -s http://github.com/cloudify-cosmo/cloudify-script-plugin/archive/1.2.tar.gz -r . --validate
50-
# create an archive by retrieving the source from a local path and output the tar.gz file to /tmp/<MODULE>.tar.gz (defaults to <cwd>/<MODULE>.tar.gz) and provides explicit Python versions supported by the module (which usually defaults to the first two digits of the Python version used to create the archive.)
51-
wagon create -s ~/modules/cloudify-script-plugin/ -o /tmp/ --pyver 33 --pyver 26 --pyver 27
50+
# create an archive by retrieving the source from a local path and output the tar.gz file to /tmp/<PACKAGE>.tar.gz (defaults to <cwd>/<PACKAGE>.tar.gz) and provides explicit Python versions supported by the package (which usually defaults to the first two digits of the Python version used to create the archive.)
51+
wagon create -s ~/packages/cloudify-script-plugin/ -o /tmp/ --pyver 33 --pyver 26 --pyver 27
52+
# pass additional args to `pip wheel`
53+
wagon create -s cloudify-script-plugin==1.2 -a '--retries 5'
5254
53-
Regarding exclusions, note that excluding modules can result in an
55+
Regarding exclusions, note that excluding packages can result in an
5456
archive being non-installable. The user will be warned about this but
5557
creation will succeed. Creation validation, though (i.e. using the
5658
``--validate`` flag), will fail and show an error incase the archive
5759
cannot be installed.
5860

61+
Also note that Wagon doesn't currently provide a way for packaging
62+
packages that are in editable mode. So, for instance, providing a
63+
dev-requirements file which contains a ``-e DEPENDENCY`` requirement
64+
will not be taken into consideration. This is not related to wagon but
65+
rather to the default ``pip wheel`` implementation stating that it will
66+
be "Skipping bdist\_wheel for #PACKAGE#, due to being editable". We
67+
might allow processing editable provided dependencies in the future.
68+
5969
Install Packages
6070
~~~~~~~~~~~~~~~~
6171

@@ -68,17 +78,22 @@ Examples
6878

6979
.. code:: shell
7080
71-
# install a module from a local archive tar file and upgrade if already installed. Also, ignore the platform check which would force a module (whether it is or isn't compiled for a specific platform) to be installed.
81+
# install a package from a local archive tar file and upgrade if already installed. Also, ignore the platform check which would force a package (whether it is or isn't compiled for a specific platform) to be installed.
7282
wagon install -s ~/tars/cloudify_script_plugin-1.2-py27-none-any.tar.gz --upgrade --ignore-platform
73-
# install a module from a url into an existing virtualenv.
83+
# install a package from a url into an existing virtualenv.
7484
wagon install -s http://me.com/cloudify_script_plugin-1.2-py27-none-any-none-none.tar.gz --virtualenv my_venv -v
85+
# pass additional args to `pip install`
86+
wagon create -s cloudify-script-plugin==1.2 -a '--no-cache-dir'
87+
88+
Note that ``--pre`` is appended to the installation command to enable
89+
installation of prerelease versions.
7590

7691
Installing Manually
7792
^^^^^^^^^^^^^^^^^^^
7893

7994
While wagon provides a generic way of installing wagon created archives,
8095
you might not want to use the installer as you might not wish to install
81-
wagon on your application servers. Installing the module manually via
96+
wagon on your application servers. Installing the package manually via
8297
pip is as easy as running (for example):
8398

8499
.. code:: shell
@@ -95,8 +110,9 @@ Validate Packages
95110
96111
The ``validate`` function provides shallow validation of a Wagon
97112
archive. Basically, it checks that some keys in the metadata are found,
98-
that all required wheels for a module are present and that the module is
99-
installable. It obviously does not check for a module's functionality.
113+
that all required wheels for a package are present and that the package
114+
is installable. It obviously does not check for a package's
115+
functionality.
100116

101117
This shallow validation should, at the very least, allow a user to be
102118
sure that a Wagon archive is not corrupted.
@@ -137,7 +153,7 @@ Source: PyPI
137153
~~~~~~~~~~~~
138154

139155
When providing a PyPI source, it must be supplied as
140-
MODULE\_NAME==MODULE\_VERSION. wagon then applies the correct name and
156+
PACKAGE\_NAME==PACKAGE\_VERSION. wagon then applies the correct name and
141157
version to the archive according to the two parameters.
142158

143159
Source: Else
@@ -162,38 +178,44 @@ this:
162178
::
163179

164180
{
165-
"archive_name": "cloudify_script_plugin-1.2-py27-none-any-ubuntu-trusty.tar.gz",
181+
"archive_name": "cloudify_script_plugin-1.2-py27-none-linux_x86_64-ubuntu-trusty.tar.gz",
166182
"build_server_os_properties": {
167183
"distribution": "ubuntu",
168184
"distribution_release": "trusty",
169185
"distribution_version": "14.04"
170186
},
171-
"module_name": "cloudify-script-plugin",
172-
"module_source": "cloudify-script-plugin==1.2",
173-
"module_version": "1.2",
187+
"package_name": "cloudify-script-plugin",
188+
"package_source": "cloudify-script-plugin==1.2",
189+
"package_version": "1.2",
174190
"supported_platform": "any",
175191
"supported_python_versions": [
176192
"py26",
177193
"py27"
178194
],
179195
"wheels": [
180196
"proxy_tools-0.1.0-py2-none-any.whl",
197+
"pyzmq-14.7.0-cp27-none-linux_x86_64.whl",
181198
"bottle-0.12.7-py2-none-any.whl",
182199
"networkx-1.8.1-py2-none-any.whl",
200+
"requests-2.5.1-py2.py3-none-any.whl",
201+
"PyYAML-3.10-cp27-none-linux_x86_64.whl",
183202
"pika-0.9.13-py2-none-any.whl",
184-
"cloudify_plugins_common-3.2.1-py2-none-any.whl",
185-
"requests-2.7.0-py2.py3-none-any.whl",
186-
"cloudify_rest_client-3.2.1-py2-none-any.whl",
203+
"jsonschema-2.3.0-py2.py3-none-any.whl",
204+
"cloudify_dsl_parser-3.2-py2-none-any.whl",
205+
"cloudify_rest_client-3.2-py2-none-any.whl",
187206
"cloudify_script_plugin-1.2-py2-none-any.whl"
207+
],
208+
"excluded_wheels": [
209+
"cloudify_plugins_common-3.2-py2-none-any.whl"
188210
]
189211
}
190212

191213
- The wheels to be installed reside in the tar.gz file under
192214
'wheels/\*.whl'.
193-
- The Metadata file resides in the tar.gz file under 'module.json'.
215+
- The Metadata file resides in the tar.gz file under 'package.json'.
194216
- The installer uses the metadata file to check that the platform fits
195-
the machine the module is being installed on.
196-
- OS Properties only appear when creating compiled Linux modules (see
217+
the machine the package is being installed on.
218+
- OS Properties only appear when creating compiled Linux packages (see
197219
Linux Distributions section). In case of a non-linux platform (e.g.
198220
win32, any), null values will be supplied for OS properties.
199221

@@ -208,18 +230,21 @@ Example Output Archive:
208230
``cloudify_fabric_plugin-1.2.1-py27-none-any-none-none.tar.gz``
209231

210232
- ``{python tag}``: The Python version is set by the Python running the
211-
packaging process. That means that while a module might run on both
233+
packaging process. That means that while a package might run on both
212234
py27 and py33 (for example), since the packaging process took place
213235
using Python 2.7, only py27 will be appended to the name. A user can
214-
also explicitly provide the supported Python versions for the module
236+
also explicitly provide the supported Python versions for the package
215237
via the ``pyver`` flag.
216238
- ``{platform tag}``: The platform (e.g. ``linux_x86_64``, ``win32``)
217-
is set each specific wheel. To know which platform the module with
239+
is set each specific wheel. To know which platform the package with
218240
its dependencies can be installed on, all wheels are checked. If a
219241
specific wheel has a platform property other than ``any``, that
220242
platform will be used as the platform of the package. Of course, we
221243
assume that there can't be wheels downloaded or created on a specific
222244
machine platform that belongs to two different platforms.
245+
- ``{abi tag}``: Note that the ABI tag is currently ignored and will
246+
always be ``none``. This might be changed in the future to support
247+
providing an ABI tag.
223248
- For Linux (see below), two additional tags are added:
224249
``{distribution tag}`` and ``{release tag}``. Note that these tags
225250
are NOT a part of the PEP.
@@ -235,26 +260,26 @@ Linux are not uploaded to PyPI due to variations between compilation
235260
environments on different distributions and links to varying system
236261
libraries.
237262

238-
To overcome that (partially), if running Wagon on Linux and the module
263+
To overcome that (partially), if running Wagon on Linux and the package
239264
requires compilation, the metadata and archive name both provide the
240265
distribution and release of the OS that the archive was created on (via
241266
platform.linux\_distribution()). Statistically speaking, this should
242267
provide the user with the information they need to know which OS the
243-
module can be installed on. Obviously, this is not true for cases where
268+
package can be installed on. Obviously, this is not true for cases where
244269
non-generic compilation methods are used on the creating OS but
245270
otherwise should work, and should specifically always work when both
246271
compilation environment and Python version are similar on the creating
247272
and installing OS - which, we generally recommend.
248273

249274
What this practically means, is that in most cases, using the metadata
250275
to compare the distro, release and the Python version under which the
251-
module is installed would allow a user to use Wagon rather safely. Of
276+
package is installed would allow a user to use Wagon rather safely. Of
252277
course, Wagon provides no guarantee whatsoever as to whether this will
253278
actually work or not and users must test their archives.
254279

255280
That being said, Wagon is completely safe for creating and installing
256-
Pure Python module archives for any platform, and, due to the nature of
257-
Wheels, modules compiled for OS X or Windows.
281+
Pure Python package archives for any platform, and, due to the nature of
282+
Wheels, packages compiled for OS X or Windows.
258283

259284
Testing
260285
-------

TODO.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
- wagon/wagon.py:360: # TODO: maybe we don't want to be that explicit and allow using >=
2-
- wagon/wagon.py:361: # TODO: or just a package name...
3-
- wagon/wagon.py:436: # TODO: Let the user provide supported Python versions.
4-
- wagon/wagon.py:437: # TODO: Let the user provide supported Architectures.
1+
- wagon/wagon.py:361: # TODO: maybe we don't want to be that explicit and allow using >=
2+
- wagon/wagon.py:362: # TODO: or just a package name...
3+
- wagon/wagon.py:440: # TODO: Let the user provide supported Python versions.
4+
- wagon/wagon.py:441: # TODO: Let the user provide supported Architectures.
55
- wagon/utils.py:48: # TODO: implement using sh

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def read(*parts):
1212

1313
setup(
1414
name='wagon',
15-
version='0.2.3',
15+
version='0.2.4',
1616
url='https://github.com/cloudify-cosmo/wagon',
1717
author='Gigaspaces',
1818
author_email='cosmo-admin@gigaspaces.com',

wagon/tests/test_wagon.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,22 @@ def test_create_archive_from_pypi(self):
211211
m = self._test()
212212
self.assertEqual(m['package_source'], TEST_PACKAGE)
213213

214+
def test_create_archive_from_pypi_with_additional_wheel_args(self):
215+
fd, reqs_file_path = tempfile.mkstemp()
216+
os.write(fd, 'virtualenv==13.1.2')
217+
params = {
218+
'-s': TEST_PACKAGE,
219+
'-v': None,
220+
'-f': None,
221+
'-a': '-r {0}'.format(reqs_file_path)
222+
}
223+
result = _invoke_click('create', params)
224+
self.assertEqual(str(result), '<Result okay>')
225+
m = self._test()
226+
self.assertEqual(m['package_source'], TEST_PACKAGE)
227+
self.assertIn('virtualenv-13.1.2-py2.py3-none-any.whl', m['wheels'])
228+
os.close(fd)
229+
214230
def test_create_archive_from_url_with_requirements(self):
215231
self.wagon.platform = utils.get_machine_platform()
216232
self.archive_name = self.wagon.set_archive_name(

wagon/utils.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ def run(cmd, suppress_errors=False, suppress_output=False):
7575

7676

7777
def wheel(package, requirement_files=False, wheels_path='package',
78-
excluded_packages=None):
78+
excluded_packages=None, wheel_args=None):
79+
# wheel_args = wheel_args or []
80+
7981
lgr.info('Downloading Wheels for {0}...'.format(package))
8082
wheel_cmd = ['pip', 'wheel']
8183
wheel_cmd.append('--wheel-dir={0}'.format(wheels_path))
@@ -89,6 +91,8 @@ def wheel(package, requirement_files=False, wheels_path='package',
8991
lgr.error('Could not download wheels for: {0}. '
9092
'Please verify that the file you are trying '
9193
'to wheel is wheelable.'.format(req_file))
94+
if wheel_args:
95+
wheel_cmd.append(wheel_args)
9296
wheel_cmd.append(package)
9397
p = run(' '.join(wheel_cmd))
9498
if not p.returncode == 0:
@@ -118,7 +122,8 @@ def get_wheel_for_package(wheels_path, package):
118122

119123

120124
def install_package(package, wheels_path, virtualenv_path=None,
121-
requirements_file=None, upgrade=False):
125+
requirements_file=None, upgrade=False,
126+
install_args=None):
122127
"""This will install a Python package.
123128
124129
Can specify a specific version.
@@ -128,6 +133,8 @@ def install_package(package, wheels_path, virtualenv_path=None,
128133
Can specify a local wheels_path to use for offline installation.
129134
Can request an upgrade.
130135
"""
136+
# install_args = install_args or []
137+
131138
lgr.info('Installing {0}...'.format(package))
132139

133140
pip_cmd = ['pip', 'install']
@@ -136,6 +143,8 @@ def install_package(package, wheels_path, virtualenv_path=None,
136143
_get_env_bin_path(virtualenv_path), pip_cmd[0])
137144
if requirements_file:
138145
pip_cmd.extend(['-r', requirements_file])
146+
if install_args:
147+
pip_cmd.append(install_args)
139148
pip_cmd.append(package)
140149
pip_cmd.extend(['--use-wheel', '--no-index', '--find-links', wheels_path])
141150
# pre allows installing both prereleases and regular releases depending

0 commit comments

Comments
 (0)