Skip to content

Commit 5e92335

Browse files
committed
Merge pull request #7 from cloudify-cosmo/logger-fix
changed module to package and now no longer overriding user's logger
2 parents 21f000c + 7d60140 commit 5e92335

File tree

10 files changed

+195
-193
lines changed

10 files changed

+195
-193
lines changed

CHANGELOG

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
a42e364 (HEAD, origin/CFY-3709-add-module-exclusion, CFY-3709-add-module-exclusion) CFY-3709 added module exclusion, fixed a bug in validation and added showmeta cli func
2-
c083124 (origin/master, origin/HEAD, master) Update README.md
1+
21f000c (HEAD, tag: 0.2.1, origin/master, origin/HEAD, master, logger-fix) Update README.md
2+
e8b78eb Update README.md
3+
0a8a55d Update README.md
4+
95b384b Merge pull request #6 from cloudify-cosmo/CFY-3709-add-module-exclusion
5+
0adc2fa (origin/CFY-3709-add-module-exclusion, CFY-3709-add-module-exclusion) CFY-3709 added module exclusion, fixed a bug in validation and added showmeta cli func
6+
c083124 Update README.md
37
6391892 Merge pull request #5 from cloudify-cosmo/refine-meta-properties
48
f9f5691 (origin/refine-meta-properties, refine-meta-properties) Added support for user provided python versions, ignoring the supported platform check and linux specific handling.
59
5fd3336 (tag: 0.2.0, tag: 0.1.2) Merge pull request #4 from cloudify-cosmo/add-installation-validation

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ files:
2727
git log --oneline --decorate --color > CHANGELOG
2828

2929
test:
30-
pip install tox==1.7.1
30+
pip install tox
3131
tox
3232

3333
docs:

README.md

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,18 @@ wagon create --help
3131
#### Examples
3232

3333
```shell
34-
# 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.
34+
# 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.
3535
wagon create -s cloudify-script-plugin==1.2 --keep-wheels -v --exclude cloudify-plugins-common --exclude cloudify-rest-client
3636
# 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.
3737
wagon create -s http://github.com/cloudify-cosmo/cloudify-script-plugin/archive/1.2.tar.gz -r . --validate
38-
# 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.)
39-
wagon create -s ~/modules/cloudify-script-plugin/ -o /tmp/ --pyver 33 --pyver 26 --pyver 27
38+
# 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.)
39+
wagon create -s ~/packages/cloudify-script-plugin/ -o /tmp/ --pyver 33 --pyver 26 --pyver 27
4040
```
4141

42-
Regarding exclusions, note that excluding modules 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.
42+
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.
4343

44-
Also note that Wagon doesn't currently provide a way for packaging modules that are in editable mode.
45-
So, for instance, providing a dev-requirements file which contains a `-e DEPENDENCY` requirement will not be taken into consideration. This is not related to wagon but rather to the default `pip wheel` implementation stating that it will be "Skipping bdist_wheel for #MODULE#, due to being editable". We might allow processing editable provided dependencies in the future.
44+
Also note that Wagon doesn't currently provide a way for packaging packages that are in editable mode.
45+
So, for instance, providing a dev-requirements file which contains a `-e DEPENDENCY` requirement will not be taken into consideration. This is not related to wagon but rather to the default `pip wheel` implementation stating that it will be "Skipping bdist_wheel for #PACKAGE#, due to being editable". We might allow processing editable provided dependencies in the future.
4646

4747
### Install Packages
4848

@@ -53,9 +53,9 @@ wagon install --help
5353
#### Examples
5454

5555
```shell
56-
# 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.
56+
# 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.
5757
wagon install -s ~/tars/cloudify_script_plugin-1.2-py27-none-any.tar.gz --upgrade --ignore-platform
58-
# install a module from a url into an existing virtualenv.
58+
# install a package from a url into an existing virtualenv.
5959
wagon install -s http://me.com/cloudify_script_plugin-1.2-py27-none-any-none-none.tar.gz --virtualenv my_venv -v
6060
```
6161

@@ -64,7 +64,7 @@ Note that `--pre` is appended to the installation command to enable installation
6464

6565
#### Installing Manually
6666

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

6969
```shell
7070
tar -xzvf http://me.com/cloudify_script_plugin-1.2-py27-none-any-none-none.tar.gz
@@ -78,7 +78,7 @@ pip install --no-index --find-links cloudify-script-plugin/wheels cloudify-scrip
7878
wagon validate --help
7979
```
8080

81-
The `validate` function provides shallow validation of a Wagon archive. Basically, it checks that some keys in the metadata are found, that all required wheels for a module are present and that the module is installable. It obviously does not check for a module's functionality.
81+
The `validate` function provides shallow validation of a Wagon archive. Basically, it checks that some keys in the metadata are found, that all required wheels for a package are present and that the package is installable. It obviously does not check for a package's functionality.
8282

8383
This shallow validation should, at the very least, allow a user to be sure that a Wagon archive is not corrupted.
8484

@@ -113,7 +113,7 @@ wagon showmeta -s http://me.com/cloudify_script_plugin-1.2-py27-none-any-none-no
113113
## Naming and Versioning
114114

115115
### Source: PyPI
116-
When providing a PyPI source, it must be supplied as MODULE_NAME==MODULE_VERSION. wagon then applies the correct name and version to the archive according to the two parameters.
116+
When providing a PyPI source, it must be supplied as PACKAGE_NAME==PACKAGE_VERSION. wagon then applies the correct name and version to the archive according to the two parameters.
117117

118118
### Source: Else
119119
For local path and URL sources, the name and version are automatically extracted from the setup.py file.
@@ -135,23 +135,23 @@ A Metadata file is generated for the archive and looks somewhat like this:
135135
"distribution_release": "trusty",
136136
"distribution_version": "14.04"
137137
},
138-
"module_name": "cloudify-script-plugin",
139-
"module_source": "cloudify-script-plugin==1.2",
140-
"module_version": "1.2",
138+
"package_name": "cloudify-script-plugin",
139+
"package_source": "cloudify-script-plugin==1.2",
140+
"package_version": "1.2",
141141
"supported_platform": "any",
142142
"supported_python_versions": [
143143
"py26",
144144
"py27"
145145
],
146146
"wheels": [
147-
"proxy_tools-0.1.0-py2-none-any.whl",
148-
"pyzmq-14.7.0-cp27-none-linux_x86_64.whl",
149-
"bottle-0.12.7-py2-none-any.whl",
150-
"networkx-1.8.1-py2-none-any.whl",
151-
"requests-2.5.1-py2.py3-none-any.whl",
152-
"PyYAML-3.10-cp27-none-linux_x86_64.whl",
153-
"pika-0.9.13-py2-none-any.whl",
154-
"jsonschema-2.3.0-py2.py3-none-any.whl",
147+
"proxy_tools-0.1.0-py2-none-any.whl",
148+
"pyzmq-14.7.0-cp27-none-linux_x86_64.whl",
149+
"bottle-0.12.7-py2-none-any.whl",
150+
"networkx-1.8.1-py2-none-any.whl",
151+
"requests-2.5.1-py2.py3-none-any.whl",
152+
"PyYAML-3.10-cp27-none-linux_x86_64.whl",
153+
"pika-0.9.13-py2-none-any.whl",
154+
"jsonschema-2.3.0-py2.py3-none-any.whl",
155155
"cloudify_dsl_parser-3.2-py2-none-any.whl",
156156
"cloudify_rest_client-3.2-py2-none-any.whl",
157157
"cloudify_script_plugin-1.2-py2-none-any.whl"
@@ -163,9 +163,9 @@ A Metadata file is generated for the archive and looks somewhat like this:
163163
```
164164

165165
* The wheels to be installed reside in the tar.gz file under 'wheels/*.whl'.
166-
* The Metadata file resides in the tar.gz file under 'module.json'.
167-
* The installer uses the metadata file to check that the platform fits the machine the module is being installed on.
168-
* OS Properties only appear when creating compiled Linux modules (see Linux Distributions section). In case of a non-linux platform (e.g. win32, any), null values will be supplied for OS properties.
166+
* The Metadata file resides in the tar.gz file under 'package.json'.
167+
* The installer uses the metadata file to check that the platform fits the machine the package is being installed on.
168+
* OS Properties only appear when creating compiled Linux packages (see Linux Distributions section). In case of a non-linux platform (e.g. win32, any), null values will be supplied for OS properties.
169169

170170

171171
## Archive naming convention and Platform
@@ -174,8 +174,8 @@ The archive is named according to the Wheel naming convention described in [PEP0
174174

175175
Example Output Archive: `cloudify_fabric_plugin-1.2.1-py27-none-any-none-none.tar.gz`
176176

177-
* `{python tag}`: The Python version is set by the Python running the packaging process. That means that while a module might run on both py27 and py33 (for example), since the packaging process took place using Python 2.7, only py27 will be appended to the name. A user can also explicitly provide the supported Python versions for the module via the `pyver` flag.
178-
* `{platform tag}`: The platform (e.g. `linux_x86_64`, `win32`) is set each specific wheel. To know which platform the module with its dependencies can be installed on, all wheels are checked. If a specific wheel has a platform property other than `any`, that platform will be used as the platform of the package. Of course, we assume that there can't be wheels downloaded or created on a specific machine platform that belongs to two different platforms.
177+
* `{python tag}`: The Python version is set by the Python running the packaging process. That means that while a package might run on both py27 and py33 (for example), since the packaging process took place using Python 2.7, only py27 will be appended to the name. A user can also explicitly provide the supported Python versions for the package via the `pyver` flag.
178+
* `{platform tag}`: The platform (e.g. `linux_x86_64`, `win32`) is set each specific wheel. To know which platform the package with its dependencies can be installed on, all wheels are checked. If a specific wheel has a platform property other than `any`, that platform will be used as the platform of the package. Of course, we assume that there can't be wheels downloaded or created on a specific machine platform that belongs to two different platforms.
179179
* `{abi tag}`: Note that the ABI tag is currently ignored and will always be `none`. This might be changed in the future to support providing an ABI tag.
180180
* For Linux (see below), two additional tags are added: `{distribution tag}` and `{release tag}`. Note that these tags are NOT a part of the PEP.
181181

@@ -186,11 +186,11 @@ Example Output Archive: `cloudify_fabric_plugin-1.2.1-py27-none-linux_x86_64-ubu
186186

187187
Wheels which require compilation of C extensions and are compiled on Linux are not uploaded to PyPI due to variations between compilation environments on different distributions and links to varying system libraries.
188188

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

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

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

195195

196196
## Testing

TODO.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
- wagon/wagon.py:290: # TODO: maybe we don't want to be that explicit and allow using >=
2-
- wagon/wagon.py:291: # TODO: or just a module name...
3-
- wagon/wagon.py:366: # TODO: Let the user provide supported Python versions.
4-
- wagon/wagon.py:367: # TODO: Let the user provide supported Architectures.
5-
- wagon/logger.py:60: # TODO: (IMPRV) only perform file related actions if file handler is
6-
- wagon/logger.py:61: # TODO: (IMPRV) defined.
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.
75
- 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.1',
15+
version='0.2.2',
1616
url='https://github.com/cloudify-cosmo/wagon',
1717
author='Gigaspaces',
1818
author_email='cosmo-admin@gigaspaces.com',

wagon/codes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
'failed_to_wheel': 207,
1010
'could_not_install_module': 208,
1111
'failed_to_create_virtualenv': 209,
12-
'cannot_exclude_main_module': 210
12+
'cannot_exclude_main_package': 210
1313
}

wagon/logger.py

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -40,41 +40,33 @@
4040

4141

4242
def init(base_level=DEFAULT_BASE_LOGGING_LEVEL,
43-
verbose_level=DEFAULT_VERBOSE_LOGGING_LEVEL,
44-
logging_config=None):
45-
"""initializes a base logger
43+
verbose_level=DEFAULT_VERBOSE_LOGGING_LEVEL):
44+
"""Initializes a base logger
45+
"""
46+
lgr = logging.getLogger('user')
47+
lgr.setLevel(base_level)
48+
return lgr
4649

47-
you can use this to init a logger in any of your files.
48-
this will use config.py's LOGGER param and logging.dictConfig to configure
49-
the logger for you.
5050

51-
:param int|logging.LEVEL base_level: desired base logging level
52-
:param int|logging.LEVEL verbose_level: desired verbose logging level
53-
:param dict logging_dict: dictConfig based configuration.
54-
used to override the default configuration from config.py
55-
:rtype: `python logger`
51+
def configure():
52+
"""Configures the logger using the default configuration.
5653
"""
57-
if logging_config is None:
58-
logging_config = {}
59-
logging_config = logging_config or LOGGER
60-
# TODO: (IMPRV) only perform file related actions if file handler is
61-
# TODO: (IMPRV) defined.
62-
63-
log_file = LOGGER['handlers']['file']['filename']
54+
try:
55+
log_file = LOGGER['handlers']['file']['filename']
56+
except KeyError as ex:
57+
sys.exit('Failed retrieving log file path ({0}).'.format(str(ex)))
6458
log_dir = os.path.dirname(os.path.expanduser(log_file))
6559
if os.path.isfile(log_dir):
66-
sys.exit('file {0} exists - log directory cannot be created '
67-
'there. please remove the file and try again.'
68-
.format(log_dir))
60+
sys.exit('File {0} exists - log directory cannot be created '
61+
'there. please remove the file and try again.'.format(
62+
log_dir))
6963
try:
7064
if not os.path.exists(log_dir) and not len(log_dir) == 0:
7165
os.makedirs(log_dir)
72-
dictconfig.dictConfig(logging_config)
73-
lgr = logging.getLogger('user')
74-
lgr.setLevel(base_level)
75-
return lgr
76-
except ValueError as e:
77-
sys.exit('could not initialize logger.'
66+
dictconfig.dictConfig(LOGGER)
67+
68+
except ValueError as ex:
69+
sys.exit('Could not configure logger.'
7870
' verify your logger config'
79-
' and permissions to write to {0} ({1})'
80-
.format(log_file, e))
71+
' and permissions to write to {0} ({1})'.format(
72+
log_file, str(ex)))

0 commit comments

Comments
 (0)