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
Python{2,3} plugins: Make site-packages link relative. #169
Merged
sergiusens
merged 1 commit into
canonical:master
from
kyrofa:bugfix/1523384/make_site_packages_relative_link
Dec 18, 2015
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- | ||
# | ||
# Copyright (C) 2015 Canonical Ltd | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License version 3 as | ||
# published by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
import os | ||
|
||
from unittest import mock | ||
|
||
from snapcraft import tests | ||
from snapcraft.plugins import python2 | ||
|
||
|
||
class Python2PluginTestCase(tests.TestCase): | ||
|
||
def setUp(self): | ||
super().setUp() | ||
|
||
class Options: | ||
requirements = '' | ||
python_packages = [] | ||
|
||
self.options = Options() | ||
|
||
@mock.patch.object(python2.Python2Plugin, 'run') | ||
@mock.patch.object(python2.Python2Plugin, 'run_output', | ||
return_value='python2.7') | ||
def test_pip_relative_site_packages_symlink(self, run_output_mock, | ||
run_mock): | ||
plugin = python2.Python2Plugin('test-part', self.options) | ||
os.makedirs(plugin.sourcedir) | ||
os.makedirs(os.path.join(plugin.installdir, 'usr', 'lib', 'python2.7', | ||
'dist-packages')) | ||
|
||
open(os.path.join(plugin.sourcedir, 'setup.py'), 'w').close() | ||
|
||
plugin._pip() | ||
|
||
link = os.readlink(os.path.join(plugin.installdir, 'usr', 'lib', | ||
'python2.7', 'site-packages')) | ||
self.assertEqual(link, 'dist-packages', | ||
'Expected site-packages to be a relative link to ' | ||
'"dist-packages", but it was a link to "{}"' | ||
.format(link)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- | ||
# | ||
# Copyright (C) 2015 Canonical Ltd | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License version 3 as | ||
# published by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
import os | ||
|
||
from unittest import mock | ||
|
||
from snapcraft import tests | ||
from snapcraft.plugins import python3 | ||
|
||
|
||
class Python3PluginTestCase(tests.TestCase): | ||
|
||
def setUp(self): | ||
super().setUp() | ||
|
||
class Options: | ||
requirements = '' | ||
python_packages = [] | ||
|
||
self.options = Options() | ||
|
||
@mock.patch.object(python3.Python3Plugin, 'run') | ||
@mock.patch.object(python3.Python3Plugin, 'run_output', | ||
return_value='python3.4') | ||
def test_pip_relative_site_packages_symlink(self, run_output_mock, | ||
run_mock): | ||
plugin = python3.Python3Plugin('test-part', self.options) | ||
os.makedirs(plugin.sourcedir) | ||
os.makedirs(os.path.join(plugin.installdir, 'usr', 'lib', 'python3.4')) | ||
os.makedirs(os.path.join(plugin.installdir, 'usr', 'lib', 'python3', | ||
'dist-packages')) | ||
|
||
open(os.path.join(plugin.sourcedir, 'setup.py'), 'w').close() | ||
|
||
plugin._pip() | ||
|
||
link = os.readlink(os.path.join(plugin.installdir, 'usr', 'lib', | ||
'python3.4', 'site-packages')) | ||
expected = os.path.join('..', 'python3', 'dist-packages') | ||
self.assertEqual(link, expected, | ||
'Expected site-packages to be a relative link to ' | ||
'"{}", but it was a link to "{}"'.format(expected, | ||
link)) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we do the same for python3?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, good call, I didn't even look at python3. Fixing now. I'm going to go ahead and include the fix in this PR since it's small and I'd say it's the same bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.