Commit Graph

12 Commits

Author SHA1 Message Date
a11c1bbdd0 Run Black on all of tools/
Signed-off-by: Edward Z. Yang <ezyangfb.com>

Pull Request resolved: https://github.com/pytorch/pytorch/pull/76089

Approved by: https://github.com/albanD
2022-04-20 17:29:41 +00:00
ac086ca15b Update version.txt file path (#61177)
Summary:
The file version.txt is located one directory above generate_torch_version,
some platforms are unable to find this file unless given an explicit
path.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/61177

Reviewed By: pbelevich

Differential Revision: D29660334

Pulled By: ezyang

fbshipit-source-id: f66105f782aaff031e373f96a69baabb13c89337
2021-07-12 07:30:10 -07:00
737d920b21 Strictly type everything in .github and tools (#59117)
Summary:
This PR greatly simplifies `mypy-strict.ini` by strictly typing everything in `.github` and `tools`, rather than picking and choosing only specific files in those two dirs. It also removes `warn_unused_ignores` from `mypy-strict.ini`, for reasons described in https://github.com/pytorch/pytorch/pull/56402#issuecomment-822743795: basically, that setting makes life more difficult depending on what libraries you have installed locally vs in CI (e.g. `ruamel`).

Pull Request resolved: https://github.com/pytorch/pytorch/pull/59117

Test Plan:
```
flake8
mypy --config mypy-strict.ini
```

Reviewed By: malfet

Differential Revision: D28765386

Pulled By: samestep

fbshipit-source-id: 3e744e301c7a464f8a2a2428fcdbad534e231f2e
2021-06-07 14:49:36 -07:00
4b96fc060b Remove distutils (#57040)
Summary:
[distutils](https://docs.python.org/3/library/distutils.html) is on its way out and will be deprecated-on-import for Python 3.10+ and removed in Python 3.12 (see [PEP 632](https://www.python.org/dev/peps/pep-0632/)). There's no reason for us to keep it around since all the functionality we want from it can be found in `setuptools` / `sysconfig`. `setuptools` includes a copy of most of `distutils` (which is fine to use according to the PEP), that it uses under the hood, so this PR also uses that in some places.

Fixes #56527
Pull Request resolved: https://github.com/pytorch/pytorch/pull/57040

Pulled By: driazati

Reviewed By: nikithamalgifb

Differential Revision: D28051356

fbshipit-source-id: 1ca312219032540e755593e50da0c9e23c62d720
2021-04-29 12:10:11 -07:00
44b9fcfb55 Fix local version generation (#52898)
Summary:
Add "git" prefix to PyTorch local version, otherwise it might strip leading zeroes from git hashum according to https://www.python.org/dev/peps/pep-0440/#local-version-identifiers:
> If a segment consists entirely of ASCII digits then that section should be considered an integer for comparison purposes

Fixes https://github.com/pytorch/pytorch/issues/52857

Pull Request resolved: https://github.com/pytorch/pytorch/pull/52898

Reviewed By: anjali411

Differential Revision: D26681878

Pulled By: malfet

fbshipit-source-id: 0e7baa2716fc06193cfacd7c4e6cdc6f4bbac4a9
2021-02-26 10:57:07 -08:00
627ec8badf Type-annotate tools/generate_torch_version (#51637)
Summary:
And add it to mypy.ini

Pull Request resolved: https://github.com/pytorch/pytorch/pull/51637

Reviewed By: janeyx99

Differential Revision: D26225123

Pulled By: malfet

fbshipit-source-id: d70d539ae58a14321e82f4592aaa44b3ce6b6358
2021-02-03 18:07:01 -08:00
62f6e55439 Fix the missing parameter in get_sha function (#51290)
Summary:
get_sha() function didn't pass in the pytorch_root argument, so subprocess.check_output always raise exception since pytorch_root is not defined, thus always return 'Unknown'.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/51290

Reviewed By: soumith

Differential Revision: D26219051

Pulled By: malfet

fbshipit-source-id: fee2c4f5fdfc61983559eec1600b9accb344c527
2021-02-02 23:25:57 -08:00
66adfcd258 tools: Move sha check to else statement (#50773)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/50773

Moves the sha check for version generation to the else clause
since it was causing issues for users building pytorch when the .git
directory was not present and PYTORCH_BUILD_VERSION was already set

Test Plan:
CI

Closes https://github.com/pytorch/pytorch/issues/50730
Signed-off-by: Eli Uriegas <eliuriegas@fb.com>

Reviewed By: janeyx99

Differential Revision: D25963486

Pulled By: seemethere

fbshipit-source-id: ce1b315f878d074f2ffb6b658d59cbd13150f27f
2021-01-20 09:34:43 -08:00
7a2abbd8fd Revert D25416620: [pytorch][PR] Add version_info tuple
Test Plan: revert-hammer

Differential Revision:
D25416620 (e69c2f85f6)

Original commit changeset: 20b561a0c76a

fbshipit-source-id: 4d73c7ed9191137d5be92236c18c312ce25a1471
2020-12-09 18:41:24 -08:00
e69c2f85f6 Add version_info tuple (#48414)
Summary:
Add a `version_info` similar to `sys.version_info` for being able to make version tests. Example generated `version.py`:

```
__version__ = '1.8.0a0'
version_info = (1, 8, 0, 'a0')
# or version_info = (1, 8, 0, 'a0', 'deadbeef') if you're in a Git checkout
debug = False
cuda = None
git_version = '671ee71ad4b6f507218d1cad278a8e743780b716'
hip = None
```

Pull Request resolved: https://github.com/pytorch/pytorch/pull/48414

Reviewed By: zhangguanheng66

Differential Revision: D25416620

Pulled By: malfet

fbshipit-source-id: 20b561a0c76ac0b16ff92f4bd43f8b724971e444
2020-12-09 17:44:35 -08:00
058f43fc51 Fix torch.version.debug generation (#47006)
Summary:
argparser type bool returns True for any argument passed as input

Use `distutils.util.strtobool` which returns 0 for input values like "0", "no", "n", "f", "false" and 1 for "1", "yes", "y", "t", "true"

Fixes https://github.com/pytorch/pytorch/issues/46973 and https://github.com/pytorch/pytorch/issues/47003

Pull Request resolved: https://github.com/pytorch/pytorch/pull/47006

Reviewed By: samestep

Differential Revision: D24598193

Pulled By: malfet

fbshipit-source-id: e8f6688d6883011f301b49a0f03c452c611f7001
2020-10-28 12:48:30 -07:00
161490d441 Move torch/version.py generation to cmake (#44577)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/44577

I would like to to move this to cmake so that I can depend on it
happening from other parts of the build.

This PR pulls out the logic for determining the version string and
writing the version file into its own module. `setup.py` still receives
the version string and uses it as before, but now the code for writing
out `torch/version.py` lives in a custom command in torch/CMakeLists.txt

I noticed a small inconsistency in how version info is populated.
`TORCH_BUILD_VERSION` is populated from `setup.py` at configuration
time, while `torch/version.py` is written at build time. So if, e.g. you
configured cmake on a certain git rev, then built it in on another, the
two versions would be inconsistent.

This does not appear to matter, so I opted to preserve the existing
behavior.

Test Plan: Imported from OSS

Reviewed By: bertmaher

Differential Revision: D23734781

Pulled By: suo

fbshipit-source-id: 4002c9ec8058503dc0550f8eece2256bc98c03a4
2020-09-16 15:49:22 -07:00