Skip to content

Commit

Permalink
setuptools-scm does not work with symlinks, stick to setuptools-git
Browse files Browse the repository at this point in the history
And add a test for that.
  • Loading branch information
sbidoul committed Apr 9, 2017
1 parent c65bcc2 commit 8cf5e37
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 2 deletions.
1 change: 0 additions & 1 deletion CHANGES.rst
Expand Up @@ -7,7 +7,6 @@ Changes
1.0.2 (2017-??-??)
------------------
- [IMP] use setuptools-scm instead of setuptools-git for finding files
- [IMP] update base addons list for Odoo 10.0
- [IMP] when setuptools extends a list-type keyword, prevent duplicate items

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -31,7 +31,7 @@
],
install_requires=[
'setuptools',
'setuptools_scm',
'setuptools-git!=1.2',
],
setup_requires=[
'setuptools_scm'
Expand Down
3 changes: 3 additions & 0 deletions tests/data/addon5/data/somedata.xml
@@ -0,0 +1,3 @@
<odoo>
<data></data>
</odoo>
47 changes: 47 additions & 0 deletions tests/test_setup_keywords.py
Expand Up @@ -2,11 +2,14 @@
# Copyright © 2015 ACSONE SA/NV
# License LGPLv3 (http://www.gnu.org/licenses/lgpl-3.0-standalone.html)

import glob
import os
import shutil
import subprocess
import sys
import tempfile
import unittest
from zipfile import ZipFile

import pkg_resources

Expand Down Expand Up @@ -88,6 +91,50 @@ def test_odoo_addon5(self):
finally:
shutil.rmtree(egg_info_dir)

def test_odoo_addon5_wheel(self):
addon5_dir = os.path.join(DATA_DIR, 'setup_reusable_addons', 'addon5')
# add a file that is not under git control
notingit_fname = os.path.join(
addon5_dir, 'odoo_addons', 'addon5', 'data', 'notingit.xml')
with open(notingit_fname, 'w') as f:
f.write('<stuff/>')
self.assertTrue(os.path.isfile(notingit_fname))
try:
bdist_dir = tempfile.mkdtemp()
assert os.path.isdir(bdist_dir)
try:
dist_dir = tempfile.mkdtemp()
assert os.path.isdir(dist_dir)
try:
subprocess.check_call([sys.executable,
'setup.py', 'bdist_wheel',
'-b', bdist_dir, '-d', dist_dir],
cwd=addon5_dir)
wheel_fname = glob.glob(os.path.join(dist_dir, '*.whl'))[0]
with ZipFile(wheel_fname) as zf:
namelist = zf.namelist()
assert 'odoo_addons/addon5/__openerp__.py' \
in namelist
# some non python file was included because #
# it is under git control
assert 'odoo_addons/addon5/data/somedata.xml' \
in namelist
# this file is not under git control,
# so its not in the wheel
assert 'odoo_addons/addon5/data/notingit.xml' \
not in namelist
finally:
shutil.rmtree(dist_dir)
shutil.rmtree(os.path.join(
addon5_dir, 'build'))
shutil.rmtree(os.path.join(
addon5_dir, 'odoo8_addon_addon5.egg-info'))
finally:
if os.path.isdir(bdist_dir):
shutil.rmtree(bdist_dir)
finally:
os.unlink(notingit_fname)

def test_custom_project(self):
project_dir = os.path.join(DATA_DIR, 'setup_custom_project')
subprocess.check_call([sys.executable, 'setup.py', 'egg_info'],
Expand Down

0 comments on commit 8cf5e37

Please sign in to comment.