forked from pytorch/FBGEMM
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto-generate the version file (pytorch#2011)
Summary: - Auto-generate the version file in OSS, so that the `__version__` symbol is available in the package Pull Request resolved: pytorch#2011 Reviewed By: shintaro-iwasaki Differential Revision: D49174509 Pulled By: q10 fbshipit-source-id: d0dfd1ab0a2912016ad6e003bf88feeab696fa4a
- Loading branch information
1 parent
9c8f89e
commit 09e0030
Showing
10 changed files
with
80 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,15 @@ | |
# This source code is licensed under the BSD-style license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
# @licenselint-loose-mode | ||
|
||
import argparse | ||
import os | ||
import random | ||
import re | ||
import subprocess | ||
import sys | ||
import textwrap | ||
|
||
from datetime import date | ||
from typing import List, Optional | ||
|
@@ -179,6 +181,26 @@ def _get_cxx11_abi(): | |
class FbgemmGpuInstaller(PipInstall): | ||
"""FBGEMM_GPU PIP Installer""" | ||
|
||
@classmethod | ||
def generate_version_file(cls, package_version: str) -> None: | ||
with open("fbgemm_gpu/_fbgemm_gpu_version.py", "w") as file: | ||
print( | ||
f"[SETUP.PY] Generating version file at: {os.path.realpath(file.name)}" | ||
) | ||
text = textwrap.dedent( | ||
f""" | ||
#!/usr/bin/env python3 | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# All rights reserved. | ||
# | ||
# This source code is licensed under the BSD-style license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
__version__: str = "{package_version}" | ||
""" | ||
) | ||
file.write(text) | ||
|
||
@classmethod | ||
def description(cls) -> str: | ||
# Get the long description from the relevant file | ||
|
@@ -250,9 +272,15 @@ def main(argv: List[str]) -> None: | |
# Repair command line args for setup. | ||
sys.argv = [sys.argv[0]] + unknown | ||
|
||
# Determine the package version | ||
package_version = generate_package_version(args.package_name) | ||
|
||
# Generate the version file | ||
FbgemmGpuInstaller.generate_version_file(package_version) | ||
|
||
setup( | ||
name=args.package_name, | ||
version=generate_package_version(args.package_name), | ||
version=package_version, | ||
author="FBGEMM Team", | ||
author_email="[email protected]", | ||
long_description=FbgemmGpuInstaller.description(), | ||
|