Skip to content

Commit

Permalink
Restore traditional setup.py for compatibility with older setuptools
Browse files Browse the repository at this point in the history
Signed-off-by: Michel Alexandre Salim <[email protected]>
  • Loading branch information
michel-slm committed Apr 8, 2022
1 parent b21fef8 commit a2eccde
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 4 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include legacy_setup.py
include *.md
include tests/*.json
include tests/*.py
Expand Down
13 changes: 12 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
USE_BUILD=0
USE_LEGACY=0

black: dcrpm/*.py tests/*.py
black $?

check-release: dist
twine check dist/*

dist: dcrpm/*.py
python -m build --sdist --wheel
ifeq ($(USE_BUILD), 1)
python -m build
else
ifeq ($(USE_LEGACY), 1)
python legacy_setup.py sdist bdist_wheel --universal
else
python setup.py sdist bdist_wheel --universal
endif
endif

clean:
rm -rf build dist dcrpm.egg-info
Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Run `dcrpm` with no option to detect and correct any outstanding issues with RPM
## Requirements
dcrpm requires Python 2.7 and above and the package psutil. It also requires `lsof` to be in `$PATH`. It should work on any Linux distribution with RPM and on Mac OS X.

To use `setup.py` you need setuptools >= 40.9.0 (see [setup.cfg-only projects](https://setuptools.pypa.io/en/latest/setuptools.html#setup-cfg-only-projects)).
Substitute `legacy_setup.py` if you have an older setuptools (e.g. when building on EL 8).

## Installing dcrpm
dcrpm is packaged in Fedora as of Fedora 32 and in EPEL as of EPEL 8. It can be installed with:

Expand Down Expand Up @@ -45,13 +48,13 @@ Then create the source distribution and the wheel:

### Old style

python setup.py sdist bdist_wheel
python setup.py sdist bdist_wheel --universal

### With the build module

This has the advantage of performing the build in an isolated virtual environment
This has the advantage of performing the build in an isolated virtual environment. However, it does not build a universal (py2/py3) wheel anymore.

python -m build --sdist --wheel
python -m build

Then verify them:

Expand All @@ -60,6 +63,8 @@ Then verify them:
A `Makefile` is provided to simplify this

make dist
make dist USE_BUILD=1 # use the build module, soon to be default
make dist USE_LEGACY=1 # use legacy_setup.py
make check-release

## Contribute
Expand Down
60 changes: 60 additions & 0 deletions legacy_setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env python
#
# Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the GPLv2 license found in the LICENSE
# file in the root directory of this source tree.
#

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import sys

from setuptools import setup, find_packages

import dcrpm.__version__

if sys.version_info.major < 3 or (
sys.version_info.major == 3 and sys.version_info.minor < 6
):
tests_require = ["mock", "typing"]
else:
tests_require = []

tests_require.append("TestSlide")

setup(
name="dcrpm",
version=dcrpm.__version__,
packages=find_packages(exclude=["tests"]),
author="Sean Karlage",
author_email="[email protected]",
url="https://github.com/facebookincubator/dcrpm",
classifiers=[
"Operating System :: POSIX :: Linux",
"Intended Audience :: Developers",
"Intended Audience :: System Administrators",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Development Status :: 3 - Alpha",
"Topic :: Utilities",
"License :: OSI Approved :: GNU General Public License v2 (GPLv2)",
],
keywords=["dcrpm", "dnf", "rpm", "yum", "db_recover", "db4", "bdb"],
description="A tool to detect and correct common issues around RPM database corruption.",
long_description=open("README.md", "r").read(),
long_description_content_type="text/markdown",
license="GPLv2",
install_requires=["psutil"],
tests_require=tests_require,
test_suite="tests",
entry_points={"console_scripts": ["dcrpm=dcrpm.main:main"]},
)

0 comments on commit a2eccde

Please sign in to comment.