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

Improve build process for PJRT plugins #6314

Merged
merged 11 commits into from
Jan 23, 2024
Merged

Conversation

will-cromar
Copy link
Collaborator

@will-cromar will-cromar commented Jan 18, 2024

Note: directly running setup.py is now deprecated. Both plugins are now installable by running pip install plugin/..., which runs setuptools/setup.py in the background. We'll have to deal with this problem in our main setup.py build soon too.

  • Build plugins within each setup.py
    • Note: BazelExtension and BuildBazelExtension are not necessary for the plugins because they don't expose any functions to Python like _XLAC does. Instead, I opted to run bazel in a subprocess before running setup. According to setuptools's docs, the "right" way to extend setuptools is to add commands, but custom setup.py commands are being deprecated (since you have to invoke it through pip). The documentation doesn't make it clear what the right thing to do here is, so I opted for the most straightforward solution. (Not to mention, the documentation about how to actually write custom commands is also sparse.)
  • Move some common bazel setup code to build_util and symlink it to plugin directories
    • Note: I can't figure out how to use a local file in a setup.py with pip's build isolation, so I disabled isolation with --no-build-isolation. The only way I see how to do this is to install our build-time library as a package, but it seems silly to create a package that will only be used to build our real packages in the same repository.

The current state of Python packaging is kind of a mess. See these three blog posts for a pretty good summary of grievances with the current situation. I'm very open to feedback on this PR, since I'm not at all convinced I'm using the new tools the "right" way (if there even is one).

The bright side is, pyproject.toml will make it much easier to get away from setuptools if we want to do that. Especially when we have to deal with our main setup.py, we should look to see if any of the alternatives better support our use case with less hackery. (I did some research this week, but most alternatives, including PyPA's hatch do not support C++ extensions).

@will-cromar will-cromar force-pushed the wcromar/plugin-packaging branch from e4c3d85 to ef4016c Compare January 18, 2024 21:28
@will-cromar will-cromar changed the base branch from wcromar/configure-plugin to master January 18, 2024 21:29
@will-cromar will-cromar marked this pull request as ready for review January 18, 2024 21:31
@will-cromar will-cromar requested a review from JackCaoG January 18, 2024 22:00
@will-cromar
Copy link
Collaborator Author

baf70be adds the CUDA plugin to the CI build, but the default behavior will remain the same. If it unnecessarily extends the build time, I'll revert it.

@will-cromar
Copy link
Collaborator Author

The build failed, so I reverted the change. I'll debug this in a future PR.

Comment on lines -205 to -210
IS_DARWIN = (platform.system() == 'Darwin')
IS_WINDOWS = sys.platform.startswith('win')
IS_LINUX = (platform.system() == 'Linux')
GCLOUD_KEY_FILE = os.getenv('GCLOUD_SERVICE_KEY_FILE', default='')
CACHE_SILO_NAME = os.getenv('SILO_NAME', default='dev')
BAZEL_JOBS = os.getenv('BAZEL_JOBS', default='')
Copy link
Collaborator

Choose a reason for hiding this comment

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

are these no longer needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The OS flags are irrelevant since we only support linux. The others were moved into local variables

@will-cromar will-cromar merged commit 61bd1d2 into master Jan 23, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants