Skip to content

Commit

Permalink
Simplify installation of pth file (#365)
Browse files Browse the repository at this point in the history
  • Loading branch information
blueyed authored Mar 10, 2020
1 parent 74c0e51 commit e3086e9
Showing 1 changed file with 7 additions and 39 deletions.
46 changes: 7 additions & 39 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from __future__ import print_function
from sysconfig import get_path

import io
import os.path
from distutils.core import Command

from setuptools import setup
from setuptools.command.install import install

PTH_HACK_FNAME = 'pdbpp_hijack_pdb.pth'

Expand All @@ -17,39 +16,6 @@

long_description = readme + '\n\n' + changelog


class install_with_pth(install):
sub_commands = install.sub_commands + [
('install_pth_hack', lambda self:
self.single_version_externally_managed)
]


class install_pth_hack(Command):
user_options = [
('install-dir=', 'd', "directory to install to"),
]

@property
def target(self):
return os.path.join(self.install_dir, PTH_HACK_FNAME)

def get_outputs(self):
return [self.target]

def initialize_options(self):
self.install_dir = None

def finalize_options(self):
self.set_undefined_options(
'install', ('install_lib', 'install_dir'))

def run(self):
with open(PTH_HACK_FNAME) as infp:
with open(self.target, 'w') as outfp:
outfp.write(infp.read())


setup(
name='pdbpp',
use_scm_version=True,
Expand Down Expand Up @@ -101,8 +67,10 @@ def run(self):
],
},
setup_requires=['setuptools_scm'],
cmdclass={
'install': install_with_pth,
'install_pth_hack': install_pth_hack,
}
data_files=[
(
os.path.relpath(get_path("purelib"), get_path("data")),
["pdbpp_hijack_pdb.pth"],
),
],
)

0 comments on commit e3086e9

Please sign in to comment.