File: utils.py

package info (click to toggle)
jupyter-packaging 0.12.3-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 260 kB
  • sloc: python: 1,533; sh: 15; makefile: 14
file content (33 lines) | stat: -rw-r--r-- 695 bytes parent folder | download | duplicates (3)
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
import site
from pathlib import Path

from setuptools.dist import Distribution


def mock_dist():
    return Distribution(
        dict(
            script_name="setup.py",
            packages=["foo"],
            name="foo",
        )
    )


def run_command(cmd):
    """Run a setuptools Command"""
    dist = mock_dist()
    instance = cmd(dist)
    instance.initialize_options()
    instance.finalize_options()
    return instance.run()


site_packages = Path(site.getsitepackages()[0])
try:
    target = site_packages / "jupyter_packaging_test.txt"
    site_packages.touch()
    site_packages.unlink()
    site_packages_readonly = False
except Exception:
    site_packages_readonly = True