Skip to content

Two resolves 19812 - #1

Open
gauthamnair wants to merge 2 commits into
mainfrom
two-resolves-19812
Open

gauthamnair wants to merge 2 commits into
mainfrom
two-resolves-19812

Conversation

@gauthamnair

Copy link
Copy Markdown
Owner

relates to pantsbuild/pants#19812

This is an adaptation of the example-python repo to simulate a case like in the issue. There is a common bit of code and two services that consume that code but otherwise have a need for different resolves.

There is also the possibility that the common bit of code needs to be packaged for distribution to consumers outside of the pants-controlled monorepo.

In this example:

  • the two resolves just have different versions of ansicolors.
  • The common code is helloworld/greeter and helloworld/translator.
  • service1 is simulated as helloworld/main.py
  • service2 is simulated as helloworld/main2.py which is identical but should print a different version number of ansicolors when run.
  • helloworld/translator is distributable as a package

The result is:

~/code/pantsbuild/example-python (two-resolves-19812) $ pants run helloworld/main.py
main1.py: Hola, pantsbuild! with colors.__version__ = 1.1.8
~/code/pantsbuild/example-python (two-resolves-19812) $ pants run helloworld/main2.py
main2.py: Hallo, pantsbuild! with colors.__version__ = 1.1.6

pex binaries:

~/code/pantsbuild/example-python (two-resolves-19812) $ pants run helloworld:pex_binary_main
main1.py: 晚安, pantsbuild! with colors.__version__ = 1.1.8
~/code/pantsbuild/example-python (two-resolves-19812) $ pants run helloworld:pex_binary_main2
main2.py: Спокойной ночи, pantsbuild! with colors.__version__ = 1.1.6

Distribution. Note there is just 1 distribution, not one per resolve.

~/code/pantsbuild/example-python (two-resolves-19812) $ pants package helloworld/translator:dist
05:39:27.09 [INFO] Wrote dist/helloworld.translator-0.0.1-py3-none-any.whl
05:39:27.09 [INFO] Wrote dist/helloworld.translator-0.0.1.tar.gz

test for completeness

~/code/pantsbuild/example-python (two-resolves-19812) $ pants test ::
...
✓ helloworld/greet/greeting_test.py:tests@resolve=python-default succeeded in 0.72s.
✓ helloworld/greet/greeting_test.py:tests@resolve=service-main2 succeeded in 0.72s.
✓ helloworld/translator/translator_test.py:tests@resolve=python-default succeeded in 0.65s.
✓ helloworld/translator/translator_test.py:tests@resolve=service-main2 succeeded in 0.65s.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant