Skip to content

Commit

Permalink
Disallow dependencies on a python_dist target
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Livingston committed Jan 30, 2018
1 parent 3024a34 commit 7f757c0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from pants.backend.python.tasks2.pex_build_util import is_local_python_dist
from pants.backend.python.tasks2.setup_py import SetupPyRunner
from pants.base.build_environment import get_buildroot
from pants.base.exceptions import TaskError
from pants.base.exceptions import TargetDefinitionException, TaskError
from pants.base.fingerprint_strategy import DefaultFingerprintStrategy
from pants.task.task import Task
from pants.util.dirutil import safe_mkdir
Expand Down Expand Up @@ -50,6 +50,11 @@ def execute(self):
if vt.valid:
built_dists.add(self._get_whl_from_dir(os.path.join(vt.results_dir, 'dist')))
else:
if vt.target.dependencies :
raise TargetDefinitionException(
vt.target, 'The `dependencies` field is disallowed on `python_dist` targets. List any 3rd '
'party requirements in the install_requirements argument of your setup function.'
)
built_dists.add(self._create_dist(vt.target, vt.results_dir))

self.context.products.register_data(self.PYTHON_DISTS, built_dists)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ def test_pants_test(self):
def test_with_install_requires(self):
command=['run', '{}:main_with_no_conflict'.format(self.superhello_install_requires)]
pants_run = self.run_pants(command=command)
self.assert_success()
self.assert_success(pants_run)
self.assertIn('United States', pants_run.stdout_data)
command=['binary', '{}:main_with_no_conflict'.format(self.superhello_install_requires)]
pants_run = self.run_pants(command=command)
self.assert_success()
pex = os.path.join(get_buildroot(), 'dist', 'main.pex')
self.assert_success(pants_run)
pex = os.path.join(get_buildroot(), 'dist', 'main_with_no_conflict.pex')
output = subprocess.check_output(pex)
self.assertIn('United States', output)
os.remove(pex)
Expand Down

0 comments on commit 7f757c0

Please sign in to comment.