Skip to content
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

Handle several packages with sdist or isolated build. #1162

Closed
proofit404 opened this issue Feb 10, 2019 · 4 comments
Closed

Handle several packages with sdist or isolated build. #1162

proofit404 opened this issue Feb 10, 2019 · 4 comments

Comments

@proofit404
Copy link

Hi,

First of all, I want to say thanks to the whole tox team for an awesome project.

This issue may be related to #715

Working on dry-python project requires a lot of library API prototyping.

In short we have this structure in our projects

.
├── pyproject.toml
├── src
│   └── library
│       ├── __init__.py
│       └── core.py
├── tests
│   ├── helpers
│   │   ├── examples
│   │   │   ├── __init__.py
│   │   │   └── usage.py
│   │   └── setup.py
│   └── test_library.py
└── tox.ini

Usually, our tests run some checks against code written with our library.

This is head of the test_library file.

from examples.usage import SomeClass

def test_some_class():
    assert SomeClass.some_thing

We use poetry to deal with packaging for our library.

This is content of the pyproject.toml

[tool.poetry]
name = "library"

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

Also, we need to install examples package in the virtual environment to make it available for tests.

This is content of the tests/helpers/setup.py file.

from setuptools import setup

setup(name="examples", packages=["examples"])

We use isolated_build option to install our project in the virtual environment.

Also, we need to reinstall examples package before each run without rebuild of the whole environment. To develop rapidly.

This is content of the tox.ini

[tox]
envlist = py{27,34,35,36,37}
isolated_build=true

[testenv]
deps =
     pytest
     coverage
commands_pre = python -m pip install --quiet --force-reinstall --no-binary :all: ./tests/helpers/.
commands = coverage run -m pytest []

I want migrate examples package to the poetry as well.

And I want to be able to build it in the same isolated build as the main package.

Are there any possibilities to build several packages with isolated build?

Regards, Artem.

@gaborbernat
Copy link
Member

Hi, sadly there isn't possible to generate and install multiple packages. You're only option would be to use pip to build wheel as isolated package with the pip wheel command (probably part of the pre command) and then install that wheel.

@gaborbernat
Copy link
Member

Alternatively, you could write a tox plugin that overloads the packaging phase and achieves what you want. You could reuse the built in isolated packaging system, and invoke it multiple times with different folder/packages.

@gaborbernat
Copy link
Member

I would say overall though this runs out of the core tox scope. I'm happy to help though to implement this as a plugin. 👍 let me know if you need help with it

@obestwalter
Copy link
Member

obestwalter commented Feb 11, 2019

Hi @proofit404, I assume you have good resons, why you do it that way, but as a general note: the "usual" (in my world) way to work around the problem of having non trivial test helpers that are not part of the actual code but should be importable in the tests is to have a module (or even package if necessary) that is part of the main package. It is usually marked private and named acordingly (see e.g. in tox itself: https://github.com/tox-dev/tox/blob/984ce025ad8e75e323877fb5f34128abcfba950d/src/tox/_pytestplugin.py). This way there is no extra work necessary to access the test helpers.

GitHub
Command line driven CI frontend and development task automation tool - tox-dev/tox

@tox-dev tox-dev locked and limited conversation to collaborators Jan 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants