From 886a8a720835caa4525db481c96faf46d63647fa Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Wed, 10 Jan 2018 08:32:46 -0500 Subject: [PATCH] basics Signed-off-by: Kenneth Reitz --- Pipfile | 15 +++++++++ Pipfile.lock | 59 +++++++++++++++++++++++++++++++++++ pipenvlib.py | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++ t.py | 4 +++ 4 files changed, 165 insertions(+) create mode 100644 Pipfile create mode 100644 Pipfile.lock create mode 100644 pipenvlib.py create mode 100644 t.py diff --git a/Pipfile b/Pipfile new file mode 100644 index 0000000..5de7880 --- /dev/null +++ b/Pipfile @@ -0,0 +1,15 @@ +[[source]] + +url = "https://pypi.python.org/simple" +verify_ssl = true +name = "pypi" + + +[packages] + +toml = "*" +"delegator.py" = "*" + + +[dev-packages] + diff --git a/Pipfile.lock b/Pipfile.lock new file mode 100644 index 0000000..3594da8 --- /dev/null +++ b/Pipfile.lock @@ -0,0 +1,59 @@ +{ + "_meta": { + "hash": { + "sha256": "f9296f30d25f044a7cb4eb5d10aecda5f64806b41f0126200adece0c27c37335" + }, + "host-environment-markers": { + "implementation_name": "cpython", + "implementation_version": "3.6.4", + "os_name": "posix", + "platform_machine": "x86_64", + "platform_python_implementation": "CPython", + "platform_release": "17.3.0", + "platform_system": "Darwin", + "platform_version": "Darwin Kernel Version 17.3.0: Thu Nov 9 18:09:22 PST 2017; root:xnu-4570.31.3~1/RELEASE_X86_64", + "python_full_version": "3.6.4", + "python_version": "3.6", + "sys_platform": "darwin" + }, + "pipfile-spec": 6, + "requires": {}, + "sources": [ + { + "name": "pypi", + "url": "https://pypi.python.org/simple", + "verify_ssl": true + } + ] + }, + "default": { + "delegator.py": { + "hashes": [ + "sha256:2575c4adc923ad0b8fdaa433f862b2b7cf21982717fb23cc895fd8f249ea820c", + "sha256:495e11ada66648650171a6c9a188df4eb050b235abff8771f41ee8a064eb9ded" + ], + "version": "==0.0.13" + }, + "pexpect": { + "hashes": [ + "sha256:144939a072a46d32f6e5ecc866509e1d613276781f7182148a08df52eaa7b022", + "sha256:8e287b171dbaf249d0b06b5f2e88cb7e694651d2d0b8c15bccb83170d3c55575" + ], + "version": "==4.3.1" + }, + "ptyprocess": { + "hashes": [ + "sha256:e8c43b5eee76b2083a9badde89fd1bbce6c8942d1045146e100b7b5e014f4f1a", + "sha256:e64193f0047ad603b71f202332ab5527c5e52aa7c8b609704fc28c0dc20c4365" + ], + "version": "==0.5.2" + }, + "toml": { + "hashes": [ + "sha256:8e86bd6ce8cc11b9620cb637466453d94f5d57ad86f17e98a98d1f73e3baab2d" + ], + "version": "==0.9.4" + } + }, + "develop": {} +} diff --git a/pipenvlib.py b/pipenvlib.py new file mode 100644 index 0000000..8a76b0f --- /dev/null +++ b/pipenvlib.py @@ -0,0 +1,87 @@ +import os + +import toml +import delegator + + +class Dependency(object): + """A Dependency.""" + def __init__(self, name, constraint, locked=False): + self.name = name + self.constraint = constraint + self.locked = locked + + +class PipenvProject(object): + """A Pipenv project.""" + def __init__(self, home, pipfile='Pipfile'): + self.home = home + self.pipfile = pipfile + + # Assert that the Pipfile exists. + self.assert_has_pipfile() + + @property + def _pipfile_path(self): + return os.path.sep.join([self.home, self.pipfile]) + + @property + def _lockfile_path(self): + return os.path.sep.join([self.home, '{0}.lock'.format(self.pipfile)]) + + def assert_has_pipfile(self): + """Asserts that the Pipfile exists.""" + assert os.path.isfile(self._pipfile_path) + + def assert_has_lockfile(self): + """Asserts that the Pipfile.lock exists.""" + assert os.path.isfile(self._pipfile_path) + + @property + def lockfile_is_latest(self): + pass + + @property + def packages(self): + pass + + @property + def dev_packages(self): + pass + + @property + def locked_packages(self): + pass + + @property + def locked_dev_packages(self): + pass + + def _assert_pipenv_is_installed(self): + pass + + def _run(self, cmd): + """Run a Pipenv command.""" + pass + + def install(package_name): + pass + + def uninstall(package_name): + pass + + @property + def virtualenv_location(self): + pass + + # @property + # def site_packages_location(self): + # pass + + # @property + # def python_home_location(self): + # pass + + + + diff --git a/t.py b/t.py new file mode 100644 index 0000000..dd1fb60 --- /dev/null +++ b/t.py @@ -0,0 +1,4 @@ +import pipenvlib + +p = pipenvlib.PipenvProject('.') +print(p.lockfile_is_latest) \ No newline at end of file