Skip to content

Commit

Permalink
Don't import ever from setuptools._distutils, and remove Clean command.
Browse files Browse the repository at this point in the history
See gh#pypa/setuptools#4034 and gh#pypa/setuptools!4062, the
world after The Fall is totally depraved and hates stable simple
solutions.

Replaces: !298
  • Loading branch information
mcepl committed Sep 26, 2023
1 parent 5d9674f commit cd7d897
Showing 1 changed file with 7 additions and 32 deletions.
39 changes: 7 additions & 32 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,14 @@
import shutil
import subprocess
import sys
import setuptools

if sys.version_info[:2] < (3, 10):
from distutils.command import build
from distutils.command.clean import clean
from distutils.dir_util import mkpath
else:
from setuptools._distutils.command import build
from setuptools._distutils.command.clean import clean
from setuptools._distutils.dir_util import mkpath
from setuptools.command import build

import setuptools
from setuptools.command import build_ext

logging.basicConfig(format='%(levelname)s:%(funcName)s:%(message)s',
Expand Down Expand Up @@ -247,7 +244,10 @@ def finalize_options(self):
# Someday distutils will be fixed and this won't be needed.
self.library_dirs += [os.path.join(self.openssl, 'bin')]

mkpath(os.path.join(self.build_lib, 'M2Crypto'))
if sys.version_info[:2] < (3, 2):
mkpath(os.path.join(self.build_lib, 'M2Crypto'))
else:
os.makedirs(os.path.join(self.build_lib, 'M2Crypto'), exist_ok=True)

def run(self):
"""
Expand Down Expand Up @@ -302,30 +302,6 @@ def run(self):
)


class Clean(clean):
def __init__(self, dist):
clean.__init__(self, dist)

def initialize_options(self):
clean.initialize_options(self)
self.all = True

def finalize_options(self):
clean.finalize_options(self)

def run(self):
clean.run(self)
garbage_list = [
os.path.join('src', 'M2Crypto', '*.so'),
os.path.join('src', 'M2Crypto', '*.pyd'),
os.path.join('src', 'M2Crypto', '*.dll')
]
for p in garbage_list:
for f in glob.glob(p):
if os.path.exists(f):
os.unlink(f)


def __get_version(): # noqa
with open('src/M2Crypto/__init__.py') as init_file:
for line in init_file:
Expand Down Expand Up @@ -384,7 +360,6 @@ def __get_version(): # noqa
include_package_data=True,
cmdclass={
'build_ext': _M2CryptoBuildExt,
'build': _M2CryptoBuild,
'clean': Clean
'build': _M2CryptoBuild
}
)

0 comments on commit cd7d897

Please sign in to comment.