LibCST/setup.py
Amethyst Reese 6a7b82e2b6 PEP 621 + hatch to run tests/lint/etc
Moves PEP 621 metadata from `setup.py` and `requirements*.txt` into the
`[project]` table of `pyproject.toml`. This enables using hatch as a
task runner for the project, where previously one would need to remember
a bunch of different commands, or repeatedly consult the readme's
developer guide to find all of the relevant commands.

This creates the following hatch commands:

- docs
- fixtures
- format
- lint
- test
- typecheck

It also updates all of the github actions workflows to use the
appropriate hatch commands, and the readme's developer guide, so that
there is only one source of truth for what constitutes running tests.

The "test" workflows now drop the matrix distinction between "pure" or
"native", and run tests in both modes from a single build.

ghstack-source-id: 8834da7825
Pull Request resolved: https://github.com/Instagram/LibCST/pull/893
2023-03-14 19:37:41 -07:00

40 lines
1.1 KiB
Python

# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from os import environ
import setuptools
from setuptools_rust import Binding, RustExtension
def no_local_scheme(version: str) -> str:
return ""
setuptools.setup(
setup_requires=["setuptools-rust", "setuptools_scm"],
use_scm_version={
"write_to": "libcst/_version.py",
**(
{"local_scheme": no_local_scheme}
if "LIBCST_NO_LOCAL_SCHEME" in environ
else {}
),
},
packages=setuptools.find_packages(),
package_data={
"libcst": ["py.typed"],
"libcst.tests.pyre": ["*"],
"libcst.codemod.tests": ["*"],
},
test_suite="libcst",
rust_extensions=[
RustExtension(
"libcst.native",
path="native/libcst/Cargo.toml",
binding=Binding.PyO3,
)
],
zip_safe=False, # for mypy compatibility https://mypy.readthedocs.io/en/latest/installed_packages.html
)