File: setup.py

package info (click to toggle)
visp 3.6.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 119,296 kB
  • sloc: cpp: 500,914; ansic: 52,904; xml: 22,642; python: 7,365; java: 4,247; sh: 482; makefile: 237; objc: 145
file content (69 lines) | stat: -rw-r--r-- 2,133 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env python

#from distutils.core import setup
from distutils.cmd import Command
from setuptools import setup
from setuptools.command.install import install

from pathlib import Path
base_json_filename = 'megapose_variables.json'
fixed_json_filename = 'megapose_variables_final.json'

class GenerateFixedJSON(Command):
  description = 'generate JSON file with absolute paths'
  user_options = []
  def initialize_options(self):
    """Use this to set option defaults before parsing."""
    pass

  def finalize_options(self):
    """Code to validate/modify command-line/config input goes here."""
    pass

  def run(self):
    import json
    megapose_variables = None
    with open(base_json_filename, 'r') as variables:
      megapose_variables = json.load(variables)

    megapose_dir = Path(megapose_variables['megapose_dir']).absolute()
    megapose_data_dir = Path(megapose_variables['megapose_data_dir']).absolute()
    megapose_variables['megapose_dir'] = str(megapose_dir)
    megapose_variables['megapose_data_dir'] = str(megapose_data_dir)
    with open(fixed_json_filename, "w") as f:
      f.write(json.dumps(megapose_variables))

class DeleteFixedJSON(Command):
  description = 'Remove JSON file with absolute paths'
  user_options = []
  def initialize_options(self):
    pass

  def finalize_options(self):
    pass

  def run(self):
    path = Path(fixed_json_filename)
    path.unlink()

class InstallCommand(install):
  user_options = install.user_options
  def run(self):
    self.run_command('generate_fixed_json')
    install.run(self)
    #self.run_command('delete_fixed_json')
setup(
    name='megapose_server',
    version='0.2',
    description='Megapose TCP server',
    cmdclass={
        'generate_fixed_json': GenerateFixedJSON,
        'install': InstallCommand,
        'delete_fixed_json': DeleteFixedJSON
    },
    package_dir={'megapose_server': '.'},
    include_package_data=True,
    package_data={'megapose_server': [fixed_json_filename]},
    author='Samuel Felton',
    author_email='samuel.felton@irisa.fr',
)