Skip to content

Commit

Permalink
pants run task implementation - first pass
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Livingston committed Jan 30, 2018
1 parent 6585142 commit 194452b
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

from pants.contrib.jax_ws.targets.jax_ws_library import JaxWsLibrary


logger = logging.getLogger(__name__)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
# hello_package is a python module within the superhello python_distribution
from hello_package import hello


if __name__ == '__main__':
hello.hello()
2 changes: 1 addition & 1 deletion src/python/pants/backend/python/tasks/pex_build_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import glob
import os
import zipfile
import shutil
import zipfile

from pex.bin import pex as pex_main
from pex.fetcher import Fetcher
Expand Down
5 changes: 3 additions & 2 deletions src/python/pants/backend/python/tasks/python_binary_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
from pex.pex_info import PexInfo

from pants.backend.python.targets.python_binary import PythonBinary
from pants.backend.python.tasks2.pex_build_util import (dump_python_distributions, dump_requirements,
dump_sources, has_python_and_c_sources,
from pants.backend.python.tasks2.pex_build_util import (dump_python_distributions,
dump_requirements, dump_sources,
has_python_and_c_sources,
has_python_requirements, has_python_sources,
has_resources)
from pants.base.build_environment import get_buildroot
Expand Down
14 changes: 5 additions & 9 deletions src/python/pants/backend/python/tasks/resolve_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@
from __future__ import (absolute_import, division, generators, nested_scopes, print_function,
unicode_literals, with_statement)

<<<<<<< 21acbf1ada8ce9d58eb5095e3e5c573b0626cf04:src/python/pants/backend/python/tasks/resolve_requirements.py
from pants.backend.python.tasks.pex_build_util import has_python_requirements
from pants.backend.python.tasks.resolve_requirements_task_base import ResolveRequirementsTaskBase
=======
from pants.backend.python.tasks2.pex_build_util import has_python_requirements, has_python_and_c_sources
from pants.backend.python.tasks2.pex_build_util import (has_python_and_c_sources,
has_python_requirements)
from pants.backend.python.tasks2.resolve_requirements_task_base import ResolveRequirementsTaskBase
>>>>>>> First stab at run task:src/python/pants/backend/python/tasks2/resolve_requirements.py


class ResolveRequirements(ResolveRequirementsTaskBase):
Expand All @@ -24,6 +20,6 @@ def product_types(cls):

def execute(self):
req_libs = self.context.targets(has_python_requirements)
if req_libs:
pex = self.resolve_requirements(req_libs)
self.context.products.register_data(self.REQUIREMENTS_PEX, pex)
python_dist_targets = self.context.targets(has_python_and_c_sources)
pex = self.resolve_requirements(req_libs, python_dist_targets=python_dist_targets)
self.context.products.register_data(self.REQUIREMENTS_PEX, pex)
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from pex.pex import PEX
from pex.pex_builder import PEXBuilder

from pants.backend.python.tasks.pex_build_util import dump_requirements
from pants.backend.python.tasks2.pex_build_util import dump_python_distributions, dump_requirements
from pants.invalidation.cache_manager import VersionedTargetSet
from pants.task.task import Task
from pants.util.dirutil import safe_concurrent_creation
Expand Down Expand Up @@ -51,7 +51,7 @@ def resolve_requirements(self, req_libs, python_dist_targets=None):
python_dist_targets=python_dist_targets)
return PEX(path, interpreter=interpreter)

def _build_requirements_pex(self, interpreter, path, req_libs, python_dist_targets=None
def _build_requirements_pex(self, interpreter, path, req_libs, python_dist_targets=None):
builder = PEXBuilder(path=path, interpreter=interpreter, copy=True)
dump_requirements(builder, interpreter, req_libs, self.context.log)
if python_dist_targets:
Expand Down

0 comments on commit 194452b

Please sign in to comment.