diff --git a/.gitignore b/.gitignore index ea2a4f4..065c058 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,102 @@ +!/tests/bin/ +*$py.class +*,cover +*.bak +*.egg +*.egg-info/ +*.iws +*.launch +*.log +*.manifest +*.mo +*.pot +*.py[cod] *.pyc -/build/ -/dist/ +*.pydevproject +*.sage.py +*.so +*.spec +*.swp +*.tmp +*~.nib +.Python +.buildpath +.cache +.cache-main +.classpath +.coverage +.coverage.* +.cproject +.eggs/ +.env +.externalToolBuilders/ +.factorypath +.hypothesis/ +.idea/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/dataSources.xml +.idea/**/dataSources/ +.idea/**/dynamic.xml +.idea/**/gradle.xml +.idea/**/libraries +.idea/**/mongoSettings.xml +.idea/**/sqlDataSources.xml +.idea/**/tasks.xml +.idea/**/uiDesigner.xml +.idea/**/workspace.xml +.idea/dictionaries +.idea/replstate.xml +.idea/sonarlint +.idea/vcs.xml +.idea_modules/ +.installed.cfg +.ipynb_checkpoints +.loadpath +.metadata +.project +.pydevproject +.python-version +.recommenders +.recommenders/ +.ropeproject +.settings/ +.target +.texlipse +.tox/ +.venv +.vscode +.webassets-cache +.worksheet +/out/ +/site +ENV/ +__pycache__/ +atlassian-ide-plugin.xml +build/ +celerybeat-schedule +cmake-build-debug/ +com_crashlytics_export_strings.xml +coverage.xml +crashlytics-build.properties +crashlytics.properties +dags/*.py +develop-eggs/ +dist/ +downloads/ +eggs/ +env/ +lib/ +lib64/ +local.properties +local_settings.py +nosetests.xml +parts/ +pip-log.txt +sdist/ +target/ +tmp/ +var/ +venv/ +wheels/ /virtualenv_api.egg-info/ diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..aee39cb --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,6 @@ +include README.rst requirements.txt +exclude tests.py +recursive-exclude * __pycache__ +recursive-exclude * *.pyc +recursive-exclude * *.pyo +recursive-exclude * *.orig diff --git a/README.rst b/README.rst index bd7409e..468a53f 100644 --- a/README.rst +++ b/README.rst @@ -28,7 +28,7 @@ Installation The latest stable release is available on `PyPi`_: -:: +.. code:: bash $ pip install virtualenv-api @@ -37,7 +37,7 @@ package is named ``virtualenvapi``. Alternatively, you may fetch the latest version from git: -:: +.. code:: bash $ pip install git+https://github.com/sjkingo/virtualenv-api.git diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..93d733c --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +six +virtualenv diff --git a/setup.py b/setup.py index 1fe16ed..74f364e 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,17 @@ +import os + from setuptools import find_packages, setup from virtualenvapi import __version__ +here = os.path.abspath(os.path.dirname(__file__)) + +with open(os.path.join(here, 'README.rst'), 'r') as fh: + long_description = fh.read() + +with open(os.path.join(here,'requirements.txt'), 'r') as fh: + requirements = fh.read().split("\n") + setup( name='virtualenv-api', version=__version__, @@ -9,10 +19,11 @@ author='Sam Kingston and AUTHORS', author_email='sam@sjkwi.com.au', description='An API for virtualenv/pip', - long_description=open('README.rst', 'r').read(), + long_description=long_description, + long_description_content_type="text/x-rst", url='https://github.com/sjkingo/virtualenv-api', - install_requires=['six'], - packages=find_packages(), + install_requires=requirements, + packages=find_packages(exclude=["tests", "tests.*"]), classifiers=[ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', @@ -25,6 +36,8 @@ 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', 'Topic :: Software Development :: Libraries :: Python Modules', ], + include_package_data=True, ) diff --git a/virtualenvapi/manage.py b/virtualenvapi/manage.py index 59e04e4..6fca571 100644 --- a/virtualenvapi/manage.py +++ b/virtualenvapi/manage.py @@ -77,11 +77,6 @@ def root(self): """The root directory that this virtual environment exists in.""" return os.path.split(self.path)[0] - @property - def name(self): - """The name of this virtual environment (taken from its path).""" - return os.path.basename(self.path) - @property def _logfile(self): """Absolute path of the log file for recording installation output.""" @@ -92,22 +87,28 @@ def _errorfile(self): """Absolute path of the log file for recording installation errors.""" return os.path.join(self.path, 'build.err') + @property + def _virtualenv(self): + """The arguments used to call virtualenv.""" + + return [sys.executable, '-m', 'virtualenv'] + def _create(self): """Executes `virtualenv` to create a new environment.""" if self.readonly: raise VirtualenvReadonlyException() - args = ['virtualenv'] + + args = [] if self.system_site_packages: args.append('--system-site-packages') - if self.python is None: - args.append(self.name) - else: - args.extend(['-p', self.python, self.name]) - proc = subprocess.Popen(args, cwd=self.root, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + if self.python is not None: + args.extend(['-p', self.python]) + + proc = subprocess.Popen(self._virtualenv + args + [self.path], stdout=subprocess.PIPE, stderr=subprocess.PIPE) output, error = proc.communicate() returncode = proc.returncode if returncode: - raise VirtualenvCreationException((returncode, output, self.name)) + raise VirtualenvCreationException((returncode, output, self.path)) self._write_to_log(output, truncate=True) self._write_to_error(error, truncate=True)