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

Use editable install of datadog_checks_base for tests #2036

Closed
wants to merge 1 commit into from
Closed

Conversation

ofek
Copy link
Contributor

@ofek ofek commented Aug 10, 2018

Motivation

Additional Notes

Script (Python 3 only)

import os
import re

CORE_DIR = r'C:\Users\ofek.lev\Desktop\code\integrations-core'
CHECKS_BASE_PATTERN = re.compile(rb'(?<!-e)..(/|\\)datadog_checks_base$', re.M)
PACKAGES_PATTERN = re.compile(rb'packages *=.*,$', re.M)


def get_setup_file(check_name):
    f = os.path.join(CORE_DIR, check_name, 'setup.py')
    if os.path.isfile(f):
        return f


def get_tox_file(check_name):
    f = os.path.join(CORE_DIR, check_name, 'tox.ini')
    if os.path.isfile(f):
        return f


def main():
    for check_name in os.listdir(CORE_DIR):
        setup_file = get_setup_file(check_name)
        if setup_file and not check_name.startswith('datadog_checks'):
            with open(setup_file, 'rb') as f:
                setup_contents = f.read()

            setup_contents = PACKAGES_PATTERN.sub(
                "packages=['datadog_checks', 'datadog_checks.{}'],".format(check_name).encode('utf-8'),
                setup_contents
            )

            with open(setup_file, 'wb') as f:
                f.write(setup_contents)

        tox_file = get_tox_file(check_name)
        if tox_file:
            with open(tox_file, 'rb') as f:
                tox_contents = f.read()

            tox_contents = CHECKS_BASE_PATTERN.sub(
                b'-e../datadog_checks_base',
                tox_contents
            )

            with open(tox_file, 'wb') as f:
                f.write(tox_contents)


if __name__ == '__main__':
    main()

Copy link
Contributor

@gzussa gzussa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is everywhere, shouldn't we create a constant for datadog_checks and make it part of the "template" for the setup.py file?
Also, would it be possible to factorize the deps block instead of doing so many copy past (maybe with a global tox.ini file)?

@ofek
Copy link
Contributor Author

ofek commented Aug 13, 2018

There is odd behavior here for some checks, sometimes, on Python 2.

pypa/setuptools#230
pypa/pip#3

These work https://github.com/GoogleCloudPlatform/google-cloud-python/blob/master/datastore/setup.py

@stale
Copy link

stale bot commented Sep 27, 2018

This issue has been automatically marked as stale because it has not had activity in the last 30 days. Note that the issue will not be automatically closed, but this notification will remind us to investigate why there's been inactivity. Thank you for participating in the Datadog open source community.

@stale stale bot added the stale label Sep 27, 2018
@gzussa gzussa closed this Oct 5, 2018
@gzussa gzussa deleted the ofek/ei branch October 5, 2018 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants