From e5eac13db392f851f15e014a1c20debb22da89b2 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Wed, 6 Jul 2005 03:46:16 +0000 Subject: Added ``develop`` command to ``setuptools``-based packages. This command installs an ``.egg-link`` pointing to the package's source directory, and script wrappers that ``execfile()`` the source versions of the package's scripts. This lets you put your development checkout(s) on sys.path without having to actually install them. (To uninstall the link, use use ``setup.py develop --uninstall``.) --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041080 --- setuptools/command/develop.py | 164 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100755 setuptools/command/develop.py (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py new file mode 100755 index 00000000..fd9f2dfd --- /dev/null +++ b/setuptools/command/develop.py @@ -0,0 +1,164 @@ +from setuptools.command.easy_install import easy_install +from distutils.util import convert_path +from pkg_resources import Distribution, PathMetadata +from distutils import log +import sys, os + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +class develop(easy_install): + """Set up package for development""" + + description = "install package in 'development mode'" + + user_options = [ + ("install-dir=", "d", "link package from DIR"), + ("script-dir=", "s", "create script wrappers in DIR"), + ("multi-version", "m", "make apps have to require() a version"), + ("exclude-scripts", "x", "Don't install scripts"), + ("always-copy", "a", "Copy all needed dependencies to install dir"), + ("uninstall", "u", "Uninstall this source package"), + ] + + boolean_options = [ + 'multi-version', 'exclude-scripts', 'always-copy', 'uninstall' + ] + + command_consumes_arguments = False # override base + + def initialize_options(self): + self.uninstall = None + easy_install.initialize_options(self) + + def finalize_options(self): + ei = self.get_finalized_command("egg_info") + self.args = [ei.egg_name] + easy_install.finalize_options(self) + self.egg_link = os.path.join(self.install_dir, ei.egg_name+'.egg-link') + self.egg_base = ei.egg_base + self.egg_path = os.path.abspath(ei.egg_base) + + # Make a distribution for the package's source + self.dist = Distribution( + self.egg_path, + PathMetadata(self.egg_path, os.path.abspath(ei.egg_info)), + name = ei.egg_name + ) + + + + def run(self): + if self.uninstall: + self.multi_version = True + self.uninstall_link() + else: + self.install_for_development() + + def install_for_development(self): + # Ensure metadata is up-to-date + self.run_command('egg_info') + ei = self.get_finalized_command("egg_info") + + # Build extensions in-place + self.reinitialize_command('build_ext', inplace=1) + self.run_command('build_ext') + + + # create an .egg-link in the installation dir, pointing to our egg + log.info("Creating %s (link to %s)", self.egg_link, self.egg_base) + if not self.dry_run: + f = open(self.egg_link,"w") + f.write(self.egg_path) + f.close() + + # postprocess the installed distro, fixing up .pth, installing scripts, + # and handling requirements + self.process_distribution(None, self.dist) + + def uninstall_link(self): + if os.path.exists(self.egg_link): + log.info("Removing %s (link to %s)", self.egg_link, self.egg_base) + contents = [line.rstrip() for line in file(self.egg_link)] + if contents != [self.egg_path]: + log.warn("Link points to %s: uninstall aborted", contents) + return + if not self.dry_run: + os.unlink(self.egg_link) + self.update_pth(self.dist) # remove any .pth link to us + if self.distribution.scripts: + log.warn("Note: you must uninstall or replace scripts manually!") + + def install_egg_scripts(self, dist): + if dist is not self.dist: + # Installing a dependency, so fall back to normal behavior + return easy_install.install_egg_scripts(self,dist) + + # create wrapper scripts in the script dir, pointing to dist.scripts + for script_name in self.distribution.scripts or []: + script_path = os.path.abspath(convert_path(script_name)) + script_name = os.path.basename(script_path) + f = open(script_path,'rU') + script_text = f.read() + f.close() + self.install_script(dist, script_name, script_text, script_path) + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.1 From 87cf6767cf525bc6770b9317ce4b5f30c745dcf8 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Thu, 7 Jul 2005 01:57:59 +0000 Subject: Don't modify .pth files when in --dry-run/-n mode. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041085 --- setuptools/command/develop.py | 79 +++++++++++-------------------------------- 1 file changed, 19 insertions(+), 60 deletions(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index fd9f2dfd..9ade5aaf 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -4,41 +4,6 @@ from pkg_resources import Distribution, PathMetadata from distutils import log import sys, os - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - class develop(easy_install): """Set up package for development""" @@ -59,10 +24,21 @@ class develop(easy_install): command_consumes_arguments = False # override base + def run(self): + if self.uninstall: + self.multi_version = True + self.uninstall_link() + else: + self.install_for_development() + def initialize_options(self): self.uninstall = None easy_install.initialize_options(self) + + + + def finalize_options(self): ei = self.get_finalized_command("egg_info") self.args = [ei.egg_name] @@ -78,15 +54,6 @@ class develop(easy_install): name = ei.egg_name ) - - - def run(self): - if self.uninstall: - self.multi_version = True - self.uninstall_link() - else: - self.install_for_development() - def install_for_development(self): # Ensure metadata is up-to-date self.run_command('egg_info') @@ -108,6 +75,11 @@ class develop(easy_install): # and handling requirements self.process_distribution(None, self.dist) + + + + + def uninstall_link(self): if os.path.exists(self.egg_link): log.info("Removing %s (link to %s)", self.egg_link, self.egg_base) @@ -117,10 +89,12 @@ class develop(easy_install): return if not self.dry_run: os.unlink(self.egg_link) - self.update_pth(self.dist) # remove any .pth link to us + if not self.dry_run: + self.update_pth(self.dist) # remove any .pth link to us if self.distribution.scripts: log.warn("Note: you must uninstall or replace scripts manually!") + def install_egg_scripts(self, dist): if dist is not self.dist: # Installing a dependency, so fall back to normal behavior @@ -142,21 +116,6 @@ class develop(easy_install): - - - - - - - - - - - - - - - -- cgit v1.2.1 From 878bea056e4a1037728d5061e2e6ce4b1eaaade8 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Tue, 12 Jul 2005 16:09:00 +0000 Subject: Fix breakage of the "develop" command that was caused by the addition of ``--always-unzip`` to the ``easy_install`` command. Bump version for bug fix release. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041120 --- setuptools/command/develop.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index 9ade5aaf..a757b2e5 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -24,6 +24,8 @@ class develop(easy_install): command_consumes_arguments = False # override base + negative_opt = {} + def run(self): if self.uninstall: self.multi_version = True @@ -37,8 +39,6 @@ class develop(easy_install): - - def finalize_options(self): ei = self.get_finalized_command("egg_info") self.args = [ei.egg_name] -- cgit v1.2.1 From 30f1c5ad93e21ec007d371313e2a27e4d0efb661 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Sun, 17 Jul 2005 04:42:42 +0000 Subject: Renamings for consistent terminology; distributions and requirements now both have 'project_name' attributes, instead of one having 'name' and the other 'distname'. Requirements no longer have 'options', they have 'extras'. This is the beginning of the terminology/architecture refactoring described at: http://mail.python.org/pipermail/distutils-sig/2005-June/004652.html --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041132 --- setuptools/command/develop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index a757b2e5..40d22b28 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -51,7 +51,7 @@ class develop(easy_install): self.dist = Distribution( self.egg_path, PathMetadata(self.egg_path, os.path.abspath(ei.egg_info)), - name = ei.egg_name + project_name = ei.egg_name ) def install_for_development(self): -- cgit v1.2.1 From c7214855992b9657d6a490f46764ffaf4089c1cb Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Mon, 18 Jul 2005 01:39:45 +0000 Subject: Massive API refactoring; see setuptools.txt changelog for details. Also, add ``#egg=project-version`` link support, and docs on how to make your package available for EasyInstall to find. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041135 --- setuptools/command/develop.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index 40d22b28..1eb8bf6b 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -1,6 +1,6 @@ from setuptools.command.easy_install import easy_install from distutils.util import convert_path -from pkg_resources import Distribution, PathMetadata +from pkg_resources import Distribution, PathMetadata, normalize_path from distutils import log import sys, os @@ -49,7 +49,7 @@ class develop(easy_install): # Make a distribution for the package's source self.dist = Distribution( - self.egg_path, + normalize_path(self.egg_path), PathMetadata(self.egg_path, os.path.abspath(ei.egg_info)), project_name = ei.egg_name ) -- cgit v1.2.1 From 673ac23e93f64a287c16a0d0ea45ba9ab9379d2d Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Sat, 17 Sep 2005 01:13:02 +0000 Subject: Added support to solve the infamous "we want .py on Windows, no extension elsewhere" problem, while also bypassing the need for PATHEXT on Windows, and in fact the need to even write script files at all, for any platform. Instead, you define "entry points" in your setup script, in this case the names of the scripts you want (without extensions) and the functions that should be imported and run to implement the scripts. Setuptools will then generate platform-appropriate script files at install time, including an .exe wrapper when installing on Windows. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041246 --- setuptools/command/develop.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index 1eb8bf6b..24875467 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -101,6 +101,11 @@ class develop(easy_install): return easy_install.install_egg_scripts(self,dist) # create wrapper scripts in the script dir, pointing to dist.scripts + + # new-style... + self.install_console_scripts(dist) + + # ...and old-style for script_name in self.distribution.scripts or []: script_path = os.path.abspath(convert_path(script_name)) script_name = os.path.basename(script_path) @@ -116,8 +121,3 @@ class develop(easy_install): - - - - - -- cgit v1.2.1 From ad0eebab218118fa07e314032bd4097c44fc7eb2 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Sat, 24 Sep 2005 20:29:57 +0000 Subject: Support generating .pyw/.exe wrappers for Windows GUI scripts, and "normal" #! wrappers for GUI scripts on other platforms. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041254 --- setuptools/command/develop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index 24875467..f767ac4a 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -103,7 +103,7 @@ class develop(easy_install): # create wrapper scripts in the script dir, pointing to dist.scripts # new-style... - self.install_console_scripts(dist) + self.install_wrapper_scripts(dist) # ...and old-style for script_name in self.distribution.scripts or []: -- cgit v1.2.1 From 0db70c291a7cbe8ec9d1f509c2508b008f4fe1c9 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Fri, 4 Nov 2005 03:08:30 +0000 Subject: Made ``develop`` command accept all the same options as ``easy_install``, and use the ``easy_install`` command's configuration settings as defaults. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041394 --- setuptools/command/develop.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index f767ac4a..a1f2e763 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -9,23 +9,14 @@ class develop(easy_install): description = "install package in 'development mode'" - user_options = [ - ("install-dir=", "d", "link package from DIR"), - ("script-dir=", "s", "create script wrappers in DIR"), - ("multi-version", "m", "make apps have to require() a version"), - ("exclude-scripts", "x", "Don't install scripts"), - ("always-copy", "a", "Copy all needed dependencies to install dir"), + user_options = easy_install.user_options + [ ("uninstall", "u", "Uninstall this source package"), ] - boolean_options = [ - 'multi-version', 'exclude-scripts', 'always-copy', 'uninstall' - ] + boolean_options = easy_install.boolean_options + ['uninstall'] command_consumes_arguments = False # override base - negative_opt = {} - def run(self): if self.uninstall: self.multi_version = True @@ -37,11 +28,21 @@ class develop(easy_install): self.uninstall = None easy_install.initialize_options(self) + # Pull in any easy_install configuration options + self.distribution._set_command_options( + self, self.distribution.get_option_dict('easy_install') + ) + + + + + def finalize_options(self): ei = self.get_finalized_command("egg_info") self.args = [ei.egg_name] + easy_install.finalize_options(self) self.egg_link = os.path.join(self.install_dir, ei.egg_name+'.egg-link') self.egg_base = ei.egg_base @@ -57,13 +58,11 @@ class develop(easy_install): def install_for_development(self): # Ensure metadata is up-to-date self.run_command('egg_info') - ei = self.get_finalized_command("egg_info") # Build extensions in-place self.reinitialize_command('build_ext', inplace=1) self.run_command('build_ext') - # create an .egg-link in the installation dir, pointing to our egg log.info("Creating %s (link to %s)", self.egg_link, self.egg_base) if not self.dry_run: @@ -80,6 +79,7 @@ class develop(easy_install): + def uninstall_link(self): if os.path.exists(self.egg_link): log.info("Removing %s (link to %s)", self.egg_link, self.egg_base) @@ -92,6 +92,7 @@ class develop(easy_install): if not self.dry_run: self.update_pth(self.dist) # remove any .pth link to us if self.distribution.scripts: + # XXX should also check for entry point scripts! log.warn("Note: you must uninstall or replace scripts manually!") @@ -120,4 +121,3 @@ class develop(easy_install): - -- cgit v1.2.1 From 969bfb31eb9417ae67d5e78467aeef401dd9bb62 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Thu, 1 Dec 2005 01:45:39 +0000 Subject: Made all commands that use ``easy_install`` respect its configuration options, as this was causing some problems with ``setup.py install`` ignoring global site-dirs settings. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041573 --- setuptools/command/develop.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index a1f2e763..b6e9d3c7 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -28,10 +28,10 @@ class develop(easy_install): self.uninstall = None easy_install.initialize_options(self) - # Pull in any easy_install configuration options - self.distribution._set_command_options( - self, self.distribution.get_option_dict('easy_install') - ) + + + + -- cgit v1.2.1 From def626a4f5aa9c03da1fc2418fcad8055687f4b1 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Fri, 30 Dec 2005 16:35:42 +0000 Subject: Allow most commands to work with an existing .egg-info directory w/a '-' in it, but warn about it and refuse to run "develop" until the existing directory is renamed. This should allow older source distributions and checkouts to keep working with 0.6a9. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041857 --- setuptools/command/develop.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index b6e9d3c7..fafe60b5 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -2,6 +2,7 @@ from setuptools.command.easy_install import easy_install from distutils.util import convert_path from pkg_resources import Distribution, PathMetadata, normalize_path from distutils import log +from distutils.errors import * import sys, os class develop(easy_install): @@ -38,11 +39,14 @@ class develop(easy_install): - def finalize_options(self): ei = self.get_finalized_command("egg_info") - self.args = [ei.egg_name] - + if ei.broken_egg_info: + raise DistutilsError( + "Please rename %r to %r before using 'develop'" + % (ei.egg_info, ei.broken_egg_info) + ) + self.args = [ei.egg_name] easy_install.finalize_options(self) self.egg_link = os.path.join(self.install_dir, ei.egg_name+'.egg-link') self.egg_base = ei.egg_base @@ -76,10 +80,6 @@ class develop(easy_install): - - - - def uninstall_link(self): if os.path.exists(self.egg_link): log.info("Removing %s (link to %s)", self.egg_link, self.egg_base) -- cgit v1.2.1 From a0662830b342b51d58d9ae76881007daa6266aa7 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Fri, 10 Feb 2006 21:09:12 +0000 Subject: Implemented DWIM for PYTHONPATH. That is, ez_setup and easy_install should now "just work" if you're using a PYTHONPATH target, and if it can't "just work", you get helpful instructions and doc links. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4042308 --- setuptools/command/develop.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index fafe60b5..774b6b5f 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -67,6 +67,8 @@ class develop(easy_install): self.reinitialize_command('build_ext', inplace=1) self.run_command('build_ext') + self.install_site_py() # ensure that target dir is site-safe + # create an .egg-link in the installation dir, pointing to our egg log.info("Creating %s (link to %s)", self.egg_link, self.egg_base) if not self.dry_run: @@ -78,8 +80,6 @@ class develop(easy_install): # and handling requirements self.process_distribution(None, self.dist) - - def uninstall_link(self): if os.path.exists(self.egg_link): log.info("Removing %s (link to %s)", self.egg_link, self.egg_base) -- cgit v1.2.1 From 72930bc0b1cb2e4e193c977802e92c86f72fdd7e Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Sat, 11 Mar 2006 00:39:09 +0000 Subject: Added automatic handling of installation conflicts. Eggs are now shifted to the front of sys.path, in an order consistent with where they came from, making EasyInstall seamlessly co-operate with system package managers. The ``--delete-conflicting`` and ``--ignore-conflicts-at-my-risk`` options are now no longer necessary, and will generate warnings at the end of a run if you use them. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4042965 --- setuptools/command/develop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index 774b6b5f..f38506bb 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -24,6 +24,7 @@ class develop(easy_install): self.uninstall_link() else: self.install_for_development() + self.warn_deprecated_options() def initialize_options(self): self.uninstall = None @@ -38,7 +39,6 @@ class develop(easy_install): - def finalize_options(self): ei = self.get_finalized_command("egg_info") if ei.broken_egg_info: -- cgit v1.2.1 From 403e6845234a3eb83b5e2858edb5e204f6641842 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Fri, 14 Jul 2006 23:37:52 +0000 Subject: * Fixed ``AttributeError`` when trying to download a ``setup_requires`` dependency when a distribution lacks a ``dependency_links`` setting. * Made ``zip-safe`` and ``not-zip-safe`` flag files contain a single byte, so as to play better with packaging tools that complain about zero-length files. * Made ``setup.py develop`` respect the ``--no-deps`` option, which it previously was ignoring. (bug fixes backported from trunk) --HG-- branch : setuptools-0.6 extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/branches/setuptools-0.6%4050659 --- setuptools/command/develop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index f38506bb..49b5b3ac 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -78,7 +78,7 @@ class develop(easy_install): # postprocess the installed distro, fixing up .pth, installing scripts, # and handling requirements - self.process_distribution(None, self.dist) + self.process_distribution(None, self.dist, not self.no_deps) def uninstall_link(self): if os.path.exists(self.egg_link): -- cgit v1.2.1 From 7d8ac102b900a1934c9d710b1eea59beb7945f0e Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Wed, 6 Sep 2006 19:56:50 +0000 Subject: Make "setup.py develop" of a setuptools-using project install setuptools, if needed, instead of only downloading the egg. (backport from trunk) --HG-- branch : setuptools-0.6 extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/branches/setuptools-0.6%4051784 --- setuptools/command/develop.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index 49b5b3ac..0c20dd8d 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -51,7 +51,6 @@ class develop(easy_install): self.egg_link = os.path.join(self.install_dir, ei.egg_name+'.egg-link') self.egg_base = ei.egg_base self.egg_path = os.path.abspath(ei.egg_base) - # Make a distribution for the package's source self.dist = Distribution( normalize_path(self.egg_path), @@ -62,12 +61,13 @@ class develop(easy_install): def install_for_development(self): # Ensure metadata is up-to-date self.run_command('egg_info') - # Build extensions in-place self.reinitialize_command('build_ext', inplace=1) self.run_command('build_ext') - self.install_site_py() # ensure that target dir is site-safe + if setuptools.bootstrap_install_from: + self.easy_install(setuptools.bootstrap_install_from) + setuptools.bootstrap_install_from = None # create an .egg-link in the installation dir, pointing to our egg log.info("Creating %s (link to %s)", self.egg_link, self.egg_base) -- cgit v1.2.1 From 243812655538358387c703bbd3789d2df05ca18b Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Wed, 6 Sep 2006 21:01:13 +0000 Subject: Generated scripts now use ``-x`` on the ``#!`` line when ``sys.executable`` contains non-ASCII characters, to prevent deprecation warnings about an unspecified encoding when the script is run. (backport from trunk) --HG-- branch : setuptools-0.6 extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/branches/setuptools-0.6%4051791 --- setuptools/command/develop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index 0c20dd8d..fc35ad85 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -3,7 +3,7 @@ from distutils.util import convert_path from pkg_resources import Distribution, PathMetadata, normalize_path from distutils import log from distutils.errors import * -import sys, os +import sys, os, setuptools class develop(easy_install): """Set up package for development""" -- cgit v1.2.1 From 7a27a6f7256169366cc968f75d6854754b29585d Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Thu, 15 Feb 2007 19:22:19 +0000 Subject: Added ``--egg-path`` option to ``develop`` command, allowing you to force ``.egg-link`` files to use relative paths (allowing them to be shared across platforms on a networked drive). (backport from trunk) --HG-- branch : setuptools-0.6 extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/branches/setuptools-0.6%4053791 --- setuptools/command/develop.py | 53 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 6 deletions(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index fc35ad85..4e19e07a 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -12,6 +12,7 @@ class develop(easy_install): user_options = easy_install.user_options + [ ("uninstall", "u", "Uninstall this source package"), + ("egg-path=", None, "Set the path to be used in the .egg-link file"), ] boolean_options = easy_install.boolean_options + ['uninstall'] @@ -28,6 +29,7 @@ class develop(easy_install): def initialize_options(self): self.uninstall = None + self.egg_path = None easy_install.initialize_options(self) @@ -37,8 +39,6 @@ class develop(easy_install): - - def finalize_options(self): ei = self.get_finalized_command("egg_info") if ei.broken_egg_info: @@ -50,14 +50,36 @@ class develop(easy_install): easy_install.finalize_options(self) self.egg_link = os.path.join(self.install_dir, ei.egg_name+'.egg-link') self.egg_base = ei.egg_base - self.egg_path = os.path.abspath(ei.egg_base) + + if self.egg_path is None: + self.egg_path = os.path.abspath(ei.egg_base) + + target = normalize_path(self.egg_base) + if normalize_path(os.path.join(self.install_dir, self.egg_path)) != target: + raise DistutilsOptionError( + "--egg-path must be a relative path from the install" + " directory to "+target + ) + # Make a distribution for the package's source self.dist = Distribution( - normalize_path(self.egg_path), - PathMetadata(self.egg_path, os.path.abspath(ei.egg_info)), + target, + PathMetadata(target, os.path.abspath(ei.egg_info)), project_name = ei.egg_name ) + + + + + + + + + + + + def install_for_development(self): # Ensure metadata is up-to-date self.run_command('egg_info') @@ -75,11 +97,11 @@ class develop(easy_install): f = open(self.egg_link,"w") f.write(self.egg_path) f.close() - # postprocess the installed distro, fixing up .pth, installing scripts, # and handling requirements self.process_distribution(None, self.dist, not self.no_deps) + def uninstall_link(self): if os.path.exists(self.egg_link): log.info("Removing %s (link to %s)", self.egg_link, self.egg_base) @@ -96,6 +118,9 @@ class develop(easy_install): log.warn("Note: you must uninstall or replace scripts manually!") + + + def install_egg_scripts(self, dist): if dist is not self.dist: # Installing a dependency, so fall back to normal behavior @@ -118,6 +143,22 @@ class develop(easy_install): + + + + + + + + + + + + + + + + -- cgit v1.2.1 From fb98a95e9badb23765ea520fd5bd9e30d0f1fe4a Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Fri, 23 Feb 2007 20:29:58 +0000 Subject: Added ``--local-snapshots-ok`` flag, to allow building eggs from projects installed using ``setup.py develop``. (backport from trunk) --HG-- branch : setuptools-0.6 extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/branches/setuptools-0.6%4053877 --- setuptools/command/develop.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index 4e19e07a..dfc41764 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -31,7 +31,7 @@ class develop(easy_install): self.uninstall = None self.egg_path = None easy_install.initialize_options(self) - + self.setup_path = None @@ -61,6 +61,7 @@ class develop(easy_install): " directory to "+target ) + # Make a distribution for the package's source self.dist = Distribution( target, @@ -68,16 +69,15 @@ class develop(easy_install): project_name = ei.egg_name ) - - - - - - - - - - + p = self.egg_base.replace(os.sep,'/') + if p!= os.curdir: + p = '../' * (p.count('/')+1) + self.setup_path = p + p = normalize_path(os.path.join(self.install_dir, self.egg_path, p)) + if p != normalize_path(os.curdir): + raise DistutilsOptionError( + "Can't get a consistent path to setup script from" + " installation directory", p, normalize_path(os.curdir)) def install_for_development(self): @@ -95,7 +95,7 @@ class develop(easy_install): log.info("Creating %s (link to %s)", self.egg_link, self.egg_base) if not self.dry_run: f = open(self.egg_link,"w") - f.write(self.egg_path) + f.write(self.egg_path + "\n" + self.setup_path) f.close() # postprocess the installed distro, fixing up .pth, installing scripts, # and handling requirements @@ -106,7 +106,7 @@ class develop(easy_install): if os.path.exists(self.egg_link): log.info("Removing %s (link to %s)", self.egg_link, self.egg_base) contents = [line.rstrip() for line in file(self.egg_link)] - if contents != [self.egg_path]: + if contents not in ([self.egg_path], [self.egg_path, self.setup_path]): log.warn("Link points to %s: uninstall aborted", contents) return if not self.dry_run: -- cgit v1.2.1 From 60cf2d31c8edb39b418f522ad935320c6da9c927 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Sat, 19 Jan 2008 02:55:03 +0000 Subject: Fix interactions between the various "require" options, so that downloads aren't repeated and needed eggs are always installed, even if they were downloaded to the setup directory already. (backport from trunk) --HG-- branch : setuptools-0.6 extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/branches/setuptools-0.6%4060066 --- setuptools/command/develop.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index dfc41764..f128b803 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -3,7 +3,7 @@ from distutils.util import convert_path from pkg_resources import Distribution, PathMetadata, normalize_path from distutils import log from distutils.errors import * -import sys, os, setuptools +import sys, os, setuptools, glob class develop(easy_install): """Set up package for development""" @@ -32,7 +32,7 @@ class develop(easy_install): self.egg_path = None easy_install.initialize_options(self) self.setup_path = None - + self.always_copy_from = '.' # always copy eggs installed in curdir @@ -48,9 +48,11 @@ class develop(easy_install): ) self.args = [ei.egg_name] easy_install.finalize_options(self) + # pick up setup-dir .egg files only: no .egg-info + self.package_index.scan(glob.glob('*.egg')) + self.egg_link = os.path.join(self.install_dir, ei.egg_name+'.egg-link') self.egg_base = ei.egg_base - if self.egg_path is None: self.egg_path = os.path.abspath(ei.egg_base) @@ -60,7 +62,6 @@ class develop(easy_install): "--egg-path must be a relative path from the install" " directory to "+target ) - # Make a distribution for the package's source self.dist = Distribution( @@ -79,7 +80,6 @@ class develop(easy_install): "Can't get a consistent path to setup script from" " installation directory", p, normalize_path(os.curdir)) - def install_for_development(self): # Ensure metadata is up-to-date self.run_command('egg_info') -- cgit v1.2.1 From 1219c326683905695fbdf60c22367129075d2f8d Mon Sep 17 00:00:00 2001 From: tarek Date: Sun, 20 Sep 2009 14:47:00 +0200 Subject: merged + removed trailing spaces --HG-- branch : distribute extra : rebase_source : 343481c01063bac16767023dd7a24bb0b063b967 --- setuptools/command/develop.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index f128b803..32888056 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -46,7 +46,7 @@ class develop(easy_install): "Please rename %r to %r before using 'develop'" % (ei.egg_info, ei.broken_egg_info) ) - self.args = [ei.egg_name] + self.args = [ei.egg_name] easy_install.finalize_options(self) # pick up setup-dir .egg files only: no .egg-info self.package_index.scan(glob.glob('*.egg')) @@ -62,7 +62,7 @@ class develop(easy_install): "--egg-path must be a relative path from the install" " directory to "+target ) - + # Make a distribution for the package's source self.dist = Distribution( target, @@ -129,7 +129,7 @@ class develop(easy_install): # create wrapper scripts in the script dir, pointing to dist.scripts # new-style... - self.install_wrapper_scripts(dist) + self.install_wrapper_scripts(dist) # ...and old-style for script_name in self.distribution.scripts or []: -- cgit v1.2.1 From 3f06b14ae21d70149f4f404f2d9d82f3842c23dc Mon Sep 17 00:00:00 2001 From: agronholm Date: Sun, 27 Sep 2009 01:12:15 +0300 Subject: Changed file() calls to open() calls --HG-- branch : distribute extra : rebase_source : a2567f3f28d896dd0abbbed8a2626cc4ecb3e44e --- setuptools/command/develop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index 32888056..5643c773 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -105,7 +105,7 @@ class develop(easy_install): def uninstall_link(self): if os.path.exists(self.egg_link): log.info("Removing %s (link to %s)", self.egg_link, self.egg_base) - contents = [line.rstrip() for line in file(self.egg_link)] + contents = [line.rstrip() for line in open(self.egg_link)] if contents not in ([self.egg_path], [self.egg_path, self.setup_path]): log.warn("Link points to %s: uninstall aborted", contents) return -- cgit v1.2.1 From e95226aa273fff543d1eccfaaabf7d58d52f5e95 Mon Sep 17 00:00:00 2001 From: tarek Date: Tue, 27 Oct 2009 09:54:46 +0100 Subject: removed empty lines --HG-- branch : distribute extra : rebase_source : a13127278ab77a12def12cfabc24f436f4700f1c --- setuptools/command/develop.py | 31 ------------------------------- 1 file changed, 31 deletions(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index 5643c773..88394c48 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -34,11 +34,6 @@ class develop(easy_install): self.setup_path = None self.always_copy_from = '.' # always copy eggs installed in curdir - - - - - def finalize_options(self): ei = self.get_finalized_command("egg_info") if ei.broken_egg_info: @@ -117,10 +112,6 @@ class develop(easy_install): # XXX should also check for entry point scripts! log.warn("Note: you must uninstall or replace scripts manually!") - - - - def install_egg_scripts(self, dist): if dist is not self.dist: # Installing a dependency, so fall back to normal behavior @@ -140,25 +131,3 @@ class develop(easy_install): f.close() self.install_script(dist, script_name, script_text, script_path) - - - - - - - - - - - - - - - - - - - - - - -- cgit v1.2.1 From 05ddf95fbac925bed8a75497e48a72e1d0ff6fdb Mon Sep 17 00:00:00 2001 From: tarek Date: Tue, 27 Oct 2009 10:42:38 +0100 Subject: now develop supports the --user option fixes #58 --HG-- branch : distribute extra : rebase_source : 1f25aaecb7ff9c7b273430e68dc2bc2d2e23db7d --- setuptools/command/develop.py | 106 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 105 insertions(+), 1 deletion(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index 88394c48..2be8bb14 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -1,9 +1,20 @@ from setuptools.command.easy_install import easy_install -from distutils.util import convert_path +from distutils.util import convert_path, subst_vars from pkg_resources import Distribution, PathMetadata, normalize_path from distutils import log from distutils.errors import * import sys, os, setuptools, glob +from distutils.sysconfig import get_config_vars +from distutils.command.install import INSTALL_SCHEMES, SCHEME_KEYS + +if sys.version < "2.6": + USER_BASE = None + USER_SITE = None + HAS_USER_SITE = False +else: + from site import USER_BASE + from site import USER_SITE + HAS_USER_SITE = True class develop(easy_install): """Set up package for development""" @@ -17,6 +28,11 @@ class develop(easy_install): boolean_options = easy_install.boolean_options + ['uninstall'] + if HAS_USER_SITE: + user_options.append(('user', None, + "install in user site-package '%s'" % USER_SITE)) + boolean_options.append('user') + command_consumes_arguments = False # override base def run(self): @@ -33,6 +49,56 @@ class develop(easy_install): easy_install.initialize_options(self) self.setup_path = None self.always_copy_from = '.' # always copy eggs installed in curdir + self.user = 0 + self.install_purelib = None # for pure module distributions + self.install_platlib = None # non-pure (dists w/ extensions) + self.install_headers = None # for C/C++ headers + self.install_lib = None # set to either purelib or platlib + self.install_scripts = None + self.install_data = None + self.install_base = None + self.install_platbase = None + self.install_userbase = USER_BASE + self.install_usersite = USER_SITE + + def select_scheme(self, name): + """Sets the install directories by applying the install schemes.""" + # it's the caller's problem if they supply a bad name! + scheme = INSTALL_SCHEMES[name] + for key in SCHEME_KEYS: + attrname = 'install_' + key + if getattr(self, attrname) is None: + setattr(self, attrname, scheme[key]) + + def create_home_path(self): + """Create directories under ~.""" + if not self.user: + return + home = convert_path(os.path.expanduser("~")) + for name, path in self.config_vars.iteritems(): + if path.startswith(home) and not os.path.isdir(path): + self.debug_print("os.makedirs('%s', 0700)" % path) + os.makedirs(path, 0700) + + def _expand_attrs(self, attrs): + for attr in attrs: + val = getattr(self, attr) + if val is not None: + if os.name == 'posix' or os.name == 'nt': + val = os.path.expanduser(val) + val = subst_vars(val, self.config_vars) + setattr(self, attr, val) + + def expand_basedirs(self): + """Calls `os.path.expanduser` on install_base, install_platbase and + root.""" + self._expand_attrs(['install_base', 'install_platbase', 'root']) + + def expand_dirs(self): + """Calls `os.path.expanduser` on install dirs.""" + self._expand_attrs(['install_purelib', 'install_platlib', + 'install_lib', 'install_headers', + 'install_scripts', 'install_data',]) def finalize_options(self): ei = self.get_finalized_command("egg_info") @@ -43,6 +109,44 @@ class develop(easy_install): ) self.args = [ei.egg_name] easy_install.finalize_options(self) + + py_version = sys.version.split()[0] + prefix, exec_prefix = get_config_vars('prefix', 'exec_prefix') + self.config_vars = {'dist_name': self.distribution.get_name(), + 'dist_version': self.distribution.get_version(), + 'dist_fullname': self.distribution.get_fullname(), + 'py_version': py_version, + 'py_version_short': py_version[0:3], + 'py_version_nodot': py_version[0] + py_version[2], + 'sys_prefix': prefix, + 'prefix': prefix, + 'sys_exec_prefix': exec_prefix, + 'exec_prefix': exec_prefix, + } + + if HAS_USER_SITE: + self.config_vars['userbase'] = self.install_userbase + self.config_vars['usersite'] = self.install_usersite + + # fix the install_dir if "--user" was used + if self.user: + self.create_home_path() + if self.install_userbase is None: + raise DistutilsPlatformError( + "User base directory is not specified") + self.install_base = self.install_platbase = self.install_userbase + if os.name == 'posix': + self.select_scheme("unix_user") + else: + self.select_scheme(os.name + "_user") + + self.expand_basedirs() + self.expand_dirs() + + if self.user and self.install_purelib: + self.install_dir = self.install_purelib + self.script_dir = self.install_scripts + # pick up setup-dir .egg files only: no .egg-info self.package_index.scan(glob.glob('*.egg')) -- cgit v1.2.1 From a5c7e0b5256ce53c49dabfe709b37f9644630b96 Mon Sep 17 00:00:00 2001 From: tarek Date: Tue, 27 Oct 2009 16:23:23 +0100 Subject: make sure USER_SITE is listed as a sitedir in easy_install --HG-- branch : distribute extra : rebase_source : f632d56d77b31a6b4f2183728e770d00005b0060 --- setuptools/command/develop.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index 2be8bb14..330ba168 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -108,7 +108,7 @@ class develop(easy_install): % (ei.egg_info, ei.broken_egg_info) ) self.args = [ei.egg_name] - easy_install.finalize_options(self) + py_version = sys.version.split()[0] prefix, exec_prefix = get_config_vars('prefix', 'exec_prefix') @@ -147,6 +147,7 @@ class develop(easy_install): self.install_dir = self.install_purelib self.script_dir = self.install_scripts + easy_install.finalize_options(self) # pick up setup-dir .egg files only: no .egg-info self.package_index.scan(glob.glob('*.egg')) -- cgit v1.2.1 From c14e1a1398cf7ece7a4bcb15317868163789d879 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Thu, 11 Feb 2010 21:32:14 +0100 Subject: enable easy_install --user, *warning breaks tests* the test-isolation got borked and operates on the users home instead of the test-tempdirs --HG-- branch : distribute extra : rebase_source : 1e9bf310b6ba92629d7ba494af17f519cfe17dc5 --- setuptools/command/develop.py | 88 +++---------------------------------------- 1 file changed, 5 insertions(+), 83 deletions(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index 330ba168..d88d0990 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -2,19 +2,8 @@ from setuptools.command.easy_install import easy_install from distutils.util import convert_path, subst_vars from pkg_resources import Distribution, PathMetadata, normalize_path from distutils import log -from distutils.errors import * -import sys, os, setuptools, glob -from distutils.sysconfig import get_config_vars -from distutils.command.install import INSTALL_SCHEMES, SCHEME_KEYS - -if sys.version < "2.6": - USER_BASE = None - USER_SITE = None - HAS_USER_SITE = False -else: - from site import USER_BASE - from site import USER_SITE - HAS_USER_SITE = True +from distutils.errors import DistutilsError, DistutilsOptionError +import os, setuptools, glob class develop(easy_install): """Set up package for development""" @@ -28,11 +17,6 @@ class develop(easy_install): boolean_options = easy_install.boolean_options + ['uninstall'] - if HAS_USER_SITE: - user_options.append(('user', None, - "install in user site-package '%s'" % USER_SITE)) - boolean_options.append('user') - command_consumes_arguments = False # override base def run(self): @@ -49,36 +33,7 @@ class develop(easy_install): easy_install.initialize_options(self) self.setup_path = None self.always_copy_from = '.' # always copy eggs installed in curdir - self.user = 0 - self.install_purelib = None # for pure module distributions - self.install_platlib = None # non-pure (dists w/ extensions) - self.install_headers = None # for C/C++ headers - self.install_lib = None # set to either purelib or platlib - self.install_scripts = None - self.install_data = None - self.install_base = None - self.install_platbase = None - self.install_userbase = USER_BASE - self.install_usersite = USER_SITE - - def select_scheme(self, name): - """Sets the install directories by applying the install schemes.""" - # it's the caller's problem if they supply a bad name! - scheme = INSTALL_SCHEMES[name] - for key in SCHEME_KEYS: - attrname = 'install_' + key - if getattr(self, attrname) is None: - setattr(self, attrname, scheme[key]) - - def create_home_path(self): - """Create directories under ~.""" - if not self.user: - return - home = convert_path(os.path.expanduser("~")) - for name, path in self.config_vars.iteritems(): - if path.startswith(home) and not os.path.isdir(path): - self.debug_print("os.makedirs('%s', 0700)" % path) - os.makedirs(path, 0700) + def _expand_attrs(self, attrs): for attr in attrs: @@ -110,44 +65,11 @@ class develop(easy_install): self.args = [ei.egg_name] - py_version = sys.version.split()[0] - prefix, exec_prefix = get_config_vars('prefix', 'exec_prefix') - self.config_vars = {'dist_name': self.distribution.get_name(), - 'dist_version': self.distribution.get_version(), - 'dist_fullname': self.distribution.get_fullname(), - 'py_version': py_version, - 'py_version_short': py_version[0:3], - 'py_version_nodot': py_version[0] + py_version[2], - 'sys_prefix': prefix, - 'prefix': prefix, - 'sys_exec_prefix': exec_prefix, - 'exec_prefix': exec_prefix, - } - - if HAS_USER_SITE: - self.config_vars['userbase'] = self.install_userbase - self.config_vars['usersite'] = self.install_usersite - - # fix the install_dir if "--user" was used - if self.user: - self.create_home_path() - if self.install_userbase is None: - raise DistutilsPlatformError( - "User base directory is not specified") - self.install_base = self.install_platbase = self.install_userbase - if os.name == 'posix': - self.select_scheme("unix_user") - else: - self.select_scheme(os.name + "_user") - self.expand_basedirs() - self.expand_dirs() - - if self.user and self.install_purelib: - self.install_dir = self.install_purelib - self.script_dir = self.install_scripts easy_install.finalize_options(self) + self.expand_basedirs() + self.expand_dirs() # pick up setup-dir .egg files only: no .egg-info self.package_index.scan(glob.glob('*.egg')) -- cgit v1.2.1 From 0b3d2302b8b209c7bed8bdad6e1a6cff34889779 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Thu, 11 Feb 2010 23:57:28 +0100 Subject: move the rest of the path handling code from develop to easy_install also resuffle the path handlers a bit, hopefully everything works now --HG-- branch : distribute extra : rebase_source : dc8e4217f5832b15e8f7287c95732bc68d1e1cf5 --- setuptools/command/develop.py | 19 ------------------- 1 file changed, 19 deletions(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index d88d0990..93b7773c 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -35,25 +35,6 @@ class develop(easy_install): self.always_copy_from = '.' # always copy eggs installed in curdir - def _expand_attrs(self, attrs): - for attr in attrs: - val = getattr(self, attr) - if val is not None: - if os.name == 'posix' or os.name == 'nt': - val = os.path.expanduser(val) - val = subst_vars(val, self.config_vars) - setattr(self, attr, val) - - def expand_basedirs(self): - """Calls `os.path.expanduser` on install_base, install_platbase and - root.""" - self._expand_attrs(['install_base', 'install_platbase', 'root']) - - def expand_dirs(self): - """Calls `os.path.expanduser` on install dirs.""" - self._expand_attrs(['install_purelib', 'install_platlib', - 'install_lib', 'install_headers', - 'install_scripts', 'install_data',]) def finalize_options(self): ei = self.get_finalized_command("egg_info") -- cgit v1.2.1 From 42afe54cf9e15ef655e7ed5fef9483682fcd5af2 Mon Sep 17 00:00:00 2001 From: Lennart Regebro Date: Tue, 21 Aug 2012 20:52:16 +0200 Subject: Added fix for the develop command, #299. --HG-- branch : distribute extra : rebase_source : ef69472e5a9ce97d9102578898e81e516f06497a --- setuptools/command/develop.py | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index 93b7773c..c8bef72e 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -84,11 +84,35 @@ class develop(easy_install): " installation directory", p, normalize_path(os.curdir)) def install_for_development(self): - # Ensure metadata is up-to-date - self.run_command('egg_info') - # Build extensions in-place - self.reinitialize_command('build_ext', inplace=1) - self.run_command('build_ext') + if getattr(self.distribution, 'use_2to3', False): + # If we run 2to3 we can not do this inplace: + + # Ensure metadata is up-to-date + self.reinitialize_command('build_py', inplace=0) + self.run_command('build_py') + bpy_cmd = self.get_finalized_command("build_py") + build_path = normalize_path(bpy_cmd.build_lib) + + # Build extensions + self.reinitialize_command('egg_info', egg_base=build_path) + self.run_command('egg_info') + + self.reinitialize_command('build_ext', inplace=0) + self.run_command('build_ext') + + # Fixup egg-link and easy-install.pth + ei_cmd = self.get_finalized_command("egg_info") + self.egg_path = build_path + self.dist.location = build_path + self.dist._provider = PathMetadata(build_path, ei_cmd.egg_info) # XXX + else: + # Without 2to3 inplace works fine: + self.run_command('egg_info') + + # Build extensions in-place + self.reinitialize_command('build_ext', inplace=1) + self.run_command('build_ext') + self.install_site_py() # ensure that target dir is site-safe if setuptools.bootstrap_install_from: self.easy_install(setuptools.bootstrap_install_from) -- cgit v1.2.1 From 9dc9fea4a5661e119f30f4cdec3ef99e46b5f919 Mon Sep 17 00:00:00 2001 From: Lennart Regebro Date: Wed, 22 Aug 2012 12:32:11 +0200 Subject: Issue #306: Even if 2to3 is used, we build in-place under Python 2. --HG-- branch : distribute extra : rebase_source : db4a1a3059533ad0c894f12c31e3fe1c238f4292 --- setuptools/command/develop.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index c8bef72e..709e349c 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -3,7 +3,7 @@ from distutils.util import convert_path, subst_vars from pkg_resources import Distribution, PathMetadata, normalize_path from distutils import log from distutils.errors import DistutilsError, DistutilsOptionError -import os, setuptools, glob +import os, sys, setuptools, glob class develop(easy_install): """Set up package for development""" @@ -84,7 +84,7 @@ class develop(easy_install): " installation directory", p, normalize_path(os.curdir)) def install_for_development(self): - if getattr(self.distribution, 'use_2to3', False): + if sys.version_info >= (3,) and getattr(self.distribution, 'use_2to3', False): # If we run 2to3 we can not do this inplace: # Ensure metadata is up-to-date -- cgit v1.2.1 From 721559fe76a1cda3de639ee2aaa446595169d26b Mon Sep 17 00:00:00 2001 From: Arfrever Frehtes Taifersar Arahesis Date: Sat, 29 Dec 2012 06:23:09 +0100 Subject: Fix some ResourceWarnings. --HG-- branch : distribute extra : rebase_source : 31ac3f0135d8cfe0fabc274f1649d1c99eba2868 --- setuptools/command/develop.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index 709e349c..1d500040 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -132,7 +132,9 @@ class develop(easy_install): def uninstall_link(self): if os.path.exists(self.egg_link): log.info("Removing %s (link to %s)", self.egg_link, self.egg_base) - contents = [line.rstrip() for line in open(self.egg_link)] + egg_link_file = open(self.egg_link) + contents = [line.rstrip() for line in egg_link_file] + egg_link_file.close() if contents not in ([self.egg_path], [self.egg_path, self.setup_path]): log.warn("Link points to %s: uninstall aborted", contents) return -- cgit v1.2.1 From 8567ca65adbf927a0af5c9b7314688dfbc46ab66 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 17 May 2014 12:25:31 -0400 Subject: Use PY3 and PY2 throughout --- setuptools/command/develop.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index 1d500040..129184ca 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -5,6 +5,8 @@ from distutils import log from distutils.errors import DistutilsError, DistutilsOptionError import os, sys, setuptools, glob +from setuptools.compat import PY3 + class develop(easy_install): """Set up package for development""" @@ -84,7 +86,7 @@ class develop(easy_install): " installation directory", p, normalize_path(os.curdir)) def install_for_development(self): - if sys.version_info >= (3,) and getattr(self.distribution, 'use_2to3', False): + if PY3 and getattr(self.distribution, 'use_2to3', False): # If we run 2to3 we can not do this inplace: # Ensure metadata is up-to-date @@ -99,7 +101,7 @@ class develop(easy_install): self.reinitialize_command('build_ext', inplace=0) self.run_command('build_ext') - + # Fixup egg-link and easy-install.pth ei_cmd = self.get_finalized_command("egg_info") self.egg_path = build_path @@ -112,7 +114,7 @@ class develop(easy_install): # Build extensions in-place self.reinitialize_command('build_ext', inplace=1) self.run_command('build_ext') - + self.install_site_py() # ensure that target dir is site-safe if setuptools.bootstrap_install_from: self.easy_install(setuptools.bootstrap_install_from) -- cgit v1.2.1 From 888950096b1d4f6263a726b6cc1bef7a26bb67ef Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 14 Jun 2014 10:31:21 -0400 Subject: Reorganize imports --- setuptools/command/develop.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index 129184ca..195ec412 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -1,10 +1,12 @@ -from setuptools.command.easy_install import easy_install -from distutils.util import convert_path, subst_vars -from pkg_resources import Distribution, PathMetadata, normalize_path +import os +import glob +from distutils.util import convert_path from distutils import log from distutils.errors import DistutilsError, DistutilsOptionError -import os, sys, setuptools, glob +import setuptools +from pkg_resources import Distribution, PathMetadata, normalize_path +from setuptools.command.easy_install import easy_install from setuptools.compat import PY3 class develop(easy_install): @@ -166,4 +168,3 @@ class develop(easy_install): script_text = f.read() f.close() self.install_script(dist, script_name, script_text, script_path) - -- cgit v1.2.1 From c0c0a82890bf8d06510f563aa3d01a69491ff86e Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 14 Jun 2014 10:34:44 -0400 Subject: Normalize whitespace --- setuptools/command/develop.py | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index 195ec412..74d12949 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -38,20 +38,14 @@ class develop(easy_install): self.setup_path = None self.always_copy_from = '.' # always copy eggs installed in curdir - - def finalize_options(self): ei = self.get_finalized_command("egg_info") if ei.broken_egg_info: - raise DistutilsError( - "Please rename %r to %r before using 'develop'" - % (ei.egg_info, ei.broken_egg_info) - ) + template = "Please rename %r to %r before using 'develop'" + args = ei.egg_info, ei.broken_egg_info + raise DistutilsError(template % args) self.args = [ei.egg_name] - - - easy_install.finalize_options(self) self.expand_basedirs() self.expand_dirs() @@ -64,11 +58,12 @@ class develop(easy_install): self.egg_path = os.path.abspath(ei.egg_base) target = normalize_path(self.egg_base) - if normalize_path(os.path.join(self.install_dir, self.egg_path)) != target: + egg_path = normalize_path(os.path.join(self.install_dir, self.egg_path)) + if egg_path != target: raise DistutilsOptionError( "--egg-path must be a relative path from the install" " directory to "+target - ) + ) # Make a distribution for the package's source self.dist = Distribution( @@ -82,7 +77,7 @@ class develop(easy_install): p = '../' * (p.count('/')+1) self.setup_path = p p = normalize_path(os.path.join(self.install_dir, self.egg_path, p)) - if p != normalize_path(os.curdir): + if p != normalize_path(os.curdir): raise DistutilsOptionError( "Can't get a consistent path to setup script from" " installation directory", p, normalize_path(os.curdir)) @@ -132,7 +127,6 @@ class develop(easy_install): # and handling requirements self.process_distribution(None, self.dist, not self.no_deps) - def uninstall_link(self): if os.path.exists(self.egg_link): log.info("Removing %s (link to %s)", self.egg_link, self.egg_base) -- cgit v1.2.1 From 8e3f9d3253d1d0fb820dad4249d5110d017595c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Gr=C3=B6nholm?= Date: Wed, 18 Jun 2014 20:31:05 +0300 Subject: Fixed PEP 8 compliancy of the setuptools.command package --- setuptools/command/develop.py | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index 74d12949..368b64fe 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -1,13 +1,14 @@ -import os -import glob from distutils.util import convert_path from distutils import log from distutils.errors import DistutilsError, DistutilsOptionError +import os +import glob -import setuptools from pkg_resources import Distribution, PathMetadata, normalize_path from setuptools.command.easy_install import easy_install from setuptools.compat import PY3 +import setuptools + class develop(easy_install): """Set up package for development""" @@ -36,7 +37,7 @@ class develop(easy_install): self.egg_path = None easy_install.initialize_options(self) self.setup_path = None - self.always_copy_from = '.' # always copy eggs installed in curdir + self.always_copy_from = '.' # always copy eggs installed in curdir def finalize_options(self): ei = self.get_finalized_command("egg_info") @@ -52,29 +53,31 @@ class develop(easy_install): # pick up setup-dir .egg files only: no .egg-info self.package_index.scan(glob.glob('*.egg')) - self.egg_link = os.path.join(self.install_dir, ei.egg_name+'.egg-link') + self.egg_link = os.path.join(self.install_dir, ei.egg_name + + '.egg-link') self.egg_base = ei.egg_base if self.egg_path is None: self.egg_path = os.path.abspath(ei.egg_base) target = normalize_path(self.egg_base) - egg_path = normalize_path(os.path.join(self.install_dir, self.egg_path)) + egg_path = normalize_path(os.path.join(self.install_dir, + self.egg_path)) if egg_path != target: raise DistutilsOptionError( "--egg-path must be a relative path from the install" - " directory to "+target + " directory to " + target ) # Make a distribution for the package's source self.dist = Distribution( target, PathMetadata(target, os.path.abspath(ei.egg_info)), - project_name = ei.egg_name + project_name=ei.egg_name ) - p = self.egg_base.replace(os.sep,'/') - if p!= os.curdir: - p = '../' * (p.count('/')+1) + p = self.egg_base.replace(os.sep, '/') + if p != os.curdir: + p = '../' * (p.count('/') + 1) self.setup_path = p p = normalize_path(os.path.join(self.install_dir, self.egg_path, p)) if p != normalize_path(os.curdir): @@ -103,7 +106,8 @@ class develop(easy_install): ei_cmd = self.get_finalized_command("egg_info") self.egg_path = build_path self.dist.location = build_path - self.dist._provider = PathMetadata(build_path, ei_cmd.egg_info) # XXX + # XXX + self.dist._provider = PathMetadata(build_path, ei_cmd.egg_info) else: # Without 2to3 inplace works fine: self.run_command('egg_info') @@ -120,7 +124,7 @@ class develop(easy_install): # create an .egg-link in the installation dir, pointing to our egg log.info("Creating %s (link to %s)", self.egg_link, self.egg_base) if not self.dry_run: - f = open(self.egg_link,"w") + f = open(self.egg_link, "w") f.write(self.egg_path + "\n" + self.setup_path) f.close() # postprocess the installed distro, fixing up .pth, installing scripts, @@ -133,7 +137,8 @@ class develop(easy_install): egg_link_file = open(self.egg_link) contents = [line.rstrip() for line in egg_link_file] egg_link_file.close() - if contents not in ([self.egg_path], [self.egg_path, self.setup_path]): + if contents not in ([self.egg_path], + [self.egg_path, self.setup_path]): log.warn("Link points to %s: uninstall aborted", contents) return if not self.dry_run: @@ -147,7 +152,7 @@ class develop(easy_install): def install_egg_scripts(self, dist): if dist is not self.dist: # Installing a dependency, so fall back to normal behavior - return easy_install.install_egg_scripts(self,dist) + return easy_install.install_egg_scripts(self, dist) # create wrapper scripts in the script dir, pointing to dist.scripts @@ -158,7 +163,7 @@ class develop(easy_install): for script_name in self.distribution.scripts or []: script_path = os.path.abspath(convert_path(script_name)) script_name = os.path.basename(script_path) - f = open(script_path,'rU') + f = open(script_path, 'rU') script_text = f.read() f.close() self.install_script(dist, script_name, script_text, script_path) -- cgit v1.2.1 From b49435397a5094f94678adf3549cc8941aa469b7 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 5 Jul 2014 15:06:51 -0400 Subject: Use six for Python 2 compatibility --HG-- branch : feature/issue-229 extra : source : 7b1997ececc5772798ce33a0f8e77387cb55a977 --- setuptools/command/develop.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index 368b64fe..9f0b6f47 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -4,9 +4,10 @@ from distutils.errors import DistutilsError, DistutilsOptionError import os import glob +import six + from pkg_resources import Distribution, PathMetadata, normalize_path from setuptools.command.easy_install import easy_install -from setuptools.compat import PY3 import setuptools @@ -86,7 +87,7 @@ class develop(easy_install): " installation directory", p, normalize_path(os.curdir)) def install_for_development(self): - if PY3 and getattr(self.distribution, 'use_2to3', False): + if six.PY3 and getattr(self.distribution, 'use_2to3', False): # If we run 2to3 we can not do this inplace: # Ensure metadata is up-to-date -- cgit v1.2.1 From f4576e373b51fab07eec7f6f2cde3ffa2e04f6c0 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 24 Nov 2015 11:32:45 -0500 Subject: Add VersionlessRequirement adapter to suppress the version number in a Distribution. Ref #439. --- setuptools/command/develop.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index 368b64fe..0959d937 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -167,3 +167,26 @@ class develop(easy_install): script_text = f.read() f.close() self.install_script(dist, script_name, script_text, script_path) + + +class VersionlessRequirement(object): + """ + Adapt a pkg_resources.Distribution to simply return the project + name as the 'requirement' so that scripts will work across + multiple versions. + + >>> dist = Distribution(project_name='foo', version='1.0') + >>> str(dist.as_requirement()) + 'foo==1.0' + >>> adapted_dist = VersionlessRequirement(dist) + >>> str(adapted_dist.as_requirement()) + 'foo' + """ + def __init__(self, dist): + self.__dist = dist + + def __getattr__(self, name): + return getattr(self.__dist, name) + + def as_requirement(self): + return self.project_name -- cgit v1.2.1 From c23be8f034d8600191decd7e843ae93619d15298 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 24 Nov 2015 11:35:27 -0500 Subject: Adapt the dist to suppress the version in the requirement when installing scripts under the develop command. Fixes #439. --- setuptools/command/develop.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index 0959d937..360872fc 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -168,6 +168,10 @@ class develop(easy_install): f.close() self.install_script(dist, script_name, script_text, script_path) + def install_wrapper_scripts(self, dist): + dist = VersionlessRequirement(dist) + return super(develop, self).install_wrapper_scripts(dist) + class VersionlessRequirement(object): """ -- cgit v1.2.1 From e311cafb5305a445def27fbc79fdc5f098c76728 Mon Sep 17 00:00:00 2001 From: Ryan Kelly Date: Tue, 24 Nov 2015 13:46:26 -0500 Subject: issue #464: don't crash using super() on a old-style class --- setuptools/command/develop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index 360872fc..5ae25d71 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -170,7 +170,7 @@ class develop(easy_install): def install_wrapper_scripts(self, dist): dist = VersionlessRequirement(dist) - return super(develop, self).install_wrapper_scripts(dist) + return easy_install.install_wrapper_scripts(self, dist) class VersionlessRequirement(object): -- cgit v1.2.1 From 41112f5afd0d2b0c14899ab1cf2c27183e64d6ac Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 9 Dec 2015 03:34:35 -0500 Subject: Use io.open for future compatibility and consistency --- setuptools/command/develop.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index 5ae25d71..3a16cdc7 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -3,6 +3,7 @@ from distutils import log from distutils.errors import DistutilsError, DistutilsOptionError import os import glob +import io from pkg_resources import Distribution, PathMetadata, normalize_path from setuptools.command.easy_install import easy_install @@ -163,9 +164,8 @@ class develop(easy_install): for script_name in self.distribution.scripts or []: script_path = os.path.abspath(convert_path(script_name)) script_name = os.path.basename(script_path) - f = open(script_path, 'rU') - script_text = f.read() - f.close() + with io.open(script_path) as strm: + script_text = strm.read() self.install_script(dist, script_name, script_text, script_path) def install_wrapper_scripts(self, dist): -- cgit v1.2.1 From 76ffa368456be9ecbcb81a8ba3196f1246e444c0 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 11 Dec 2015 10:04:44 -0500 Subject: Use context manager for opening file --- setuptools/command/develop.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index 3a16cdc7..85118767 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -125,9 +125,8 @@ class develop(easy_install): # create an .egg-link in the installation dir, pointing to our egg log.info("Creating %s (link to %s)", self.egg_link, self.egg_base) if not self.dry_run: - f = open(self.egg_link, "w") - f.write(self.egg_path + "\n" + self.setup_path) - f.close() + with open(self.egg_link, "w") as f: + f.write(self.egg_path + "\n" + self.setup_path) # postprocess the installed distro, fixing up .pth, installing scripts, # and handling requirements self.process_distribution(None, self.dist, not self.no_deps) -- cgit v1.2.1 From 07037d10760792ffe616349ab7642b2fce0a0527 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 11 Dec 2015 10:07:13 -0500 Subject: Extract variable, avoiding hanging indent. --- setuptools/command/develop.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index 85118767..07b66ccb 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -54,8 +54,8 @@ class develop(easy_install): # pick up setup-dir .egg files only: no .egg-info self.package_index.scan(glob.glob('*.egg')) - self.egg_link = os.path.join(self.install_dir, ei.egg_name + - '.egg-link') + egg_link_fn = ei.egg_name + '.egg-link' + self.egg_link = os.path.join(self.install_dir, egg_link_fn) self.egg_base = ei.egg_base if self.egg_path is None: self.egg_path = os.path.abspath(ei.egg_base) -- cgit v1.2.1 From 06872bb0bbbeb953e90bd0941444b0d499056557 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 31 Dec 2015 11:51:01 -0500 Subject: Update vendoring technique to match that used for packaging. Ref #229. --HG-- branch : feature/issue-229 --- setuptools/command/develop.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index ef9ac22d..c401c8d4 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -5,7 +5,12 @@ import os import glob import io -import six +try: + from setuptools._vendor import six +except ImportError: + # fallback to naturally-installed version; allows system packagers to + # omit vendored packages. + import six from pkg_resources import Distribution, PathMetadata, normalize_path from setuptools.command.easy_install import easy_install -- cgit v1.2.1 From 952c1bafda1929c74c737646aa025e6ffad6632e Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 31 Dec 2015 16:30:47 -0500 Subject: Modeling after Astropy's technique for bundling libraries, the imports are now much cleaner. Thanks @embray. Ref #229. --HG-- branch : feature/issue-229 --- setuptools/command/develop.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index c401c8d4..11b5df10 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -5,12 +5,7 @@ import os import glob import io -try: - from setuptools._vendor import six -except ImportError: - # fallback to naturally-installed version; allows system packagers to - # omit vendored packages. - import six +from setuptools.extern import six from pkg_resources import Distribution, PathMetadata, normalize_path from setuptools.command.easy_install import easy_install -- cgit v1.2.1 From 6d11e88f938f09ef16db4c6064b6e74acba4db1d Mon Sep 17 00:00:00 2001 From: stepshal Date: Tue, 12 Jul 2016 22:00:43 +0700 Subject: Fix quantity of blank lines after code object. --- setuptools/command/develop.py | 1 + 1 file changed, 1 insertion(+) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index 11b5df10..3eb86120 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -186,6 +186,7 @@ class VersionlessRequirement(object): >>> str(adapted_dist.as_requirement()) 'foo' """ + def __init__(self, dist): self.__dist = dist -- cgit v1.2.1 From 14827711f669a830190313951ab5aef7b71ab2c6 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 6 Nov 2016 15:54:07 -0500 Subject: Install -nspkg.pth under develop command. Fixes namespace package support as long as __init__.py is omitted. --- setuptools/command/develop.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index 3eb86120..8de24fd7 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -9,10 +9,11 @@ from setuptools.extern import six from pkg_resources import Distribution, PathMetadata, normalize_path from setuptools.command.easy_install import easy_install +from setuptools import namespaces import setuptools -class develop(easy_install): +class develop(namespaces.DevelopInstaller, easy_install): """Set up package for development""" description = "install package in 'development mode'" @@ -123,6 +124,8 @@ class develop(easy_install): self.easy_install(setuptools.bootstrap_install_from) setuptools.bootstrap_install_from = None + self.install_namespaces() + # create an .egg-link in the installation dir, pointing to our egg log.info("Creating %s (link to %s)", self.egg_link, self.egg_base) if not self.dry_run: -- cgit v1.2.1 From 355603259aa37e424cf7466c3de6518375a935e3 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 6 Nov 2016 16:41:23 -0500 Subject: Add uninstall support for namespace packages --- setuptools/command/develop.py | 1 + 1 file changed, 1 insertion(+) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index 8de24fd7..aa82f959 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -31,6 +31,7 @@ class develop(namespaces.DevelopInstaller, easy_install): if self.uninstall: self.multi_version = True self.uninstall_link() + self.uninstall_namespaces() else: self.install_for_development() self.warn_deprecated_options() -- cgit v1.2.1 From ff371f18f0076bc63da05334f7e551c1cc29e10d Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 1 Jan 2017 22:34:28 -0500 Subject: Strip out vendored packages and require them instead. Ref #581. --- setuptools/command/develop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index aa82f959..1489de9e 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -5,7 +5,7 @@ import os import glob import io -from setuptools.extern import six +import six from pkg_resources import Distribution, PathMetadata, normalize_path from setuptools.command.easy_install import easy_install -- cgit v1.2.1 From e9f0e6f16b46d084bdf92606cd0217b3f12ed25a Mon Sep 17 00:00:00 2001 From: David Szotten Date: Thu, 5 Jan 2017 11:47:09 +0000 Subject: strip trailing slash from package_dir before counting slashes --- setuptools/command/develop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index aa82f959..ca05d1e3 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -79,7 +79,7 @@ class develop(namespaces.DevelopInstaller, easy_install): project_name=ei.egg_name ) - p = self.egg_base.replace(os.sep, '/') + p = self.egg_base.replace(os.sep, '/').rstrip('/') if p != os.curdir: p = '../' * (p.count('/') + 1) self.setup_path = p -- cgit v1.2.1 From 322472e4ffdc03901be1f584a548b00f1372037d Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 24 Jan 2017 10:13:24 -0500 Subject: Extract staticmethod for resolving setup path --- setuptools/command/develop.py | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index 1489de9e..97708ba3 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -79,15 +79,28 @@ class develop(namespaces.DevelopInstaller, easy_install): project_name=ei.egg_name ) - p = self.egg_base.replace(os.sep, '/') - if p != os.curdir: - p = '../' * (p.count('/') + 1) - self.setup_path = p - p = normalize_path(os.path.join(self.install_dir, self.egg_path, p)) - if p != normalize_path(os.curdir): + self.setup_path = self._resolve_setup_path( + self.egg_base, + self.install_dir, + self.egg_path, + ) + + @staticmethod + def _resolve_setup_path(egg_base, install_dir, egg_path): + """ + Generate a path from egg_base back to '.' where the + setup script resides and ensure that path points to the + setup path from $install_dir/$egg_path. + """ + path_to_setup = egg_base.replace(os.sep, '/') + if path_to_setup != os.curdir: + path_to_setup = '../' * (path_to_setup.count('/') + 1) + resolved = normalize_path(os.path.join(install_dir, egg_path, path_to_setup)) + if resolved != normalize_path(os.curdir): raise DistutilsOptionError( "Can't get a consistent path to setup script from" - " installation directory", p, normalize_path(os.curdir)) + " installation directory", resolved, normalize_path(os.curdir)) + return path_to_setup def install_for_development(self): if six.PY3 and getattr(self.distribution, 'use_2to3', False): -- cgit v1.2.1 From 3d0cc355fb5e8012cb8c72f0e25042a5a44f31d6 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 24 Feb 2017 11:49:51 -0500 Subject: Revert "Merge pull request #933 from pypa/feature/581-depend-not-bundle" This reverts commit 089cdeb489a0fa94d11b7307b54210ef9aa40511, reversing changes made to aaec654d804cb78dbb6391afff721a63f26a71cd. --- setuptools/command/develop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index ddfdc662..85b23c60 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -5,7 +5,7 @@ import os import glob import io -import six +from setuptools.extern import six from pkg_resources import Distribution, PathMetadata, normalize_path from setuptools.command.easy_install import easy_install -- cgit v1.2.1 From cb0d6a91d8df8b4c70b95432ad33364181e49c33 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 25 Oct 2017 10:09:37 -0400 Subject: Feed the hobgoblins (delint). --- setuptools/command/develop.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index 85b23c60..959c932a 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -95,7 +95,9 @@ class develop(namespaces.DevelopInstaller, easy_install): path_to_setup = egg_base.replace(os.sep, '/').rstrip('/') if path_to_setup != os.curdir: path_to_setup = '../' * (path_to_setup.count('/') + 1) - resolved = normalize_path(os.path.join(install_dir, egg_path, path_to_setup)) + resolved = normalize_path( + os.path.join(install_dir, egg_path, path_to_setup) + ) if resolved != normalize_path(os.curdir): raise DistutilsOptionError( "Can't get a consistent path to setup script from" -- cgit v1.2.1 From cca86c7f1d4040834c3265ccecdd9e21b4036df5 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 3 Jun 2018 09:50:25 -0400 Subject: Use Python 3 syntax for new-style clasess --- setuptools/command/develop.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index 959c932a..fdc9fc43 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -12,6 +12,8 @@ from setuptools.command.easy_install import easy_install from setuptools import namespaces import setuptools +__metaclass__ = type + class develop(namespaces.DevelopInstaller, easy_install): """Set up package for development""" @@ -192,7 +194,7 @@ class develop(namespaces.DevelopInstaller, easy_install): return easy_install.install_wrapper_scripts(self, dist) -class VersionlessRequirement(object): +class VersionlessRequirement: """ Adapt a pkg_resources.Distribution to simply return the project name as the 'requirement' so that scripts will work across -- cgit v1.2.1 From 760e2e1df9c9c9d1fc072e7b6ad9df4c32bfc835 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Fri, 27 Jul 2018 14:36:34 +0200 Subject: Remove spurious executable permissions --- setuptools/command/develop.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 setuptools/command/develop.py (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py old mode 100755 new mode 100644 -- cgit v1.2.1 From 0902f02d9d68f18e906e727cbafa4a05fe5c9c91 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 24 Dec 2018 13:03:58 -0500 Subject: Access pkg_resources objects through its namespace --- setuptools/command/develop.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index fdc9fc43..707494eb 100644 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -7,7 +7,7 @@ import io from setuptools.extern import six -from pkg_resources import Distribution, PathMetadata, normalize_path +import pkg_resources from setuptools.command.easy_install import easy_install from setuptools import namespaces import setuptools @@ -65,9 +65,9 @@ class develop(namespaces.DevelopInstaller, easy_install): if self.egg_path is None: self.egg_path = os.path.abspath(ei.egg_base) - target = normalize_path(self.egg_base) - egg_path = normalize_path(os.path.join(self.install_dir, - self.egg_path)) + target = pkg_resources.normalize_path(self.egg_base) + egg_path = pkg_resources.normalize_path( + os.path.join(self.install_dir, self.egg_path)) if egg_path != target: raise DistutilsOptionError( "--egg-path must be a relative path from the install" @@ -75,9 +75,9 @@ class develop(namespaces.DevelopInstaller, easy_install): ) # Make a distribution for the package's source - self.dist = Distribution( + self.dist = pkg_resources.Distribution( target, - PathMetadata(target, os.path.abspath(ei.egg_info)), + pkg_resources.PathMetadata(target, os.path.abspath(ei.egg_info)), project_name=ei.egg_name ) @@ -97,13 +97,14 @@ class develop(namespaces.DevelopInstaller, easy_install): path_to_setup = egg_base.replace(os.sep, '/').rstrip('/') if path_to_setup != os.curdir: path_to_setup = '../' * (path_to_setup.count('/') + 1) - resolved = normalize_path( + resolved = pkg_resources.normalize_path( os.path.join(install_dir, egg_path, path_to_setup) ) - if resolved != normalize_path(os.curdir): + if resolved != pkg_resources.normalize_path(os.curdir): raise DistutilsOptionError( "Can't get a consistent path to setup script from" - " installation directory", resolved, normalize_path(os.curdir)) + " installation directory", resolved, + pkg_resources.normalize_path(os.curdir)) return path_to_setup def install_for_development(self): @@ -114,7 +115,7 @@ class develop(namespaces.DevelopInstaller, easy_install): self.reinitialize_command('build_py', inplace=0) self.run_command('build_py') bpy_cmd = self.get_finalized_command("build_py") - build_path = normalize_path(bpy_cmd.build_lib) + build_path = pkg_resources.normalize_path(bpy_cmd.build_lib) # Build extensions self.reinitialize_command('egg_info', egg_base=build_path) @@ -128,7 +129,8 @@ class develop(namespaces.DevelopInstaller, easy_install): self.egg_path = build_path self.dist.location = build_path # XXX - self.dist._provider = PathMetadata(build_path, ei_cmd.egg_info) + self.dist._provider = pkg_resources.PathMetadata( + build_path, ei_cmd.egg_info) else: # Without 2to3 inplace works fine: self.run_command('egg_info') -- cgit v1.2.1 From b78994aa19ae0705f60e3b4b1e4087ecbe4ff0f5 Mon Sep 17 00:00:00 2001 From: Paul Ganssle Date: Fri, 28 Dec 2018 09:37:55 -0500 Subject: Import distribution in doctest Fixes GH issue #1612, bug introduced in commit 0902f02d9d68f18 --- setuptools/command/develop.py | 1 + 1 file changed, 1 insertion(+) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index 707494eb..009e4f93 100644 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -202,6 +202,7 @@ class VersionlessRequirement: name as the 'requirement' so that scripts will work across multiple versions. + >>> from pkg_resources import Distribution >>> dist = Distribution(project_name='foo', version='1.0') >>> str(dist.as_requirement()) 'foo==1.0' -- cgit v1.2.1 From 796abd8dbec884cedf326cb5f85512a5d5648c4e Mon Sep 17 00:00:00 2001 From: Hugo Date: Wed, 8 Jan 2020 19:10:11 +0200 Subject: Fix for Python 4: replace unsafe six.PY3 with PY2 --- setuptools/command/develop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index 009e4f93..b5619246 100644 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -108,7 +108,7 @@ class develop(namespaces.DevelopInstaller, easy_install): return path_to_setup def install_for_development(self): - if six.PY3 and getattr(self.distribution, 'use_2to3', False): + if not six.PY2 and getattr(self.distribution, 'use_2to3', False): # If we run 2to3 we can not do this inplace: # Ensure metadata is up-to-date -- cgit v1.2.1 From e4aa9070e7196975edb41f8dcaccf8eccbf83b2e Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 29 May 2020 18:21:24 -0400 Subject: Setuptools no longer installs a site.py file during easy_install or develop installs. Ref #2165. --- setuptools/command/develop.py | 1 - 1 file changed, 1 deletion(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index b5619246..e7e03cd4 100644 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -139,7 +139,6 @@ class develop(namespaces.DevelopInstaller, easy_install): self.reinitialize_command('build_ext', inplace=1) self.run_command('build_ext') - self.install_site_py() # ensure that target dir is site-safe if setuptools.bootstrap_install_from: self.easy_install(setuptools.bootstrap_install_from) setuptools.bootstrap_install_from = None -- cgit v1.2.1 From fb7ab81a3d080422687bad71f9ae9d36eeefbee2 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 16 Aug 2020 00:29:24 -0400 Subject: Remove Python 2 compatibility --- setuptools/command/develop.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index e7e03cd4..faf8c988 100644 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -5,15 +5,11 @@ import os import glob import io -from setuptools.extern import six - import pkg_resources from setuptools.command.easy_install import easy_install from setuptools import namespaces import setuptools -__metaclass__ = type - class develop(namespaces.DevelopInstaller, easy_install): """Set up package for development""" @@ -108,7 +104,7 @@ class develop(namespaces.DevelopInstaller, easy_install): return path_to_setup def install_for_development(self): - if not six.PY2 and getattr(self.distribution, 'use_2to3', False): + if getattr(self.distribution, 'use_2to3', False): # If we run 2to3 we can not do this inplace: # Ensure metadata is up-to-date -- cgit v1.2.1 From ca296ca8663a376f3c36c9f8fd86b10ba81366c2 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Sun, 18 Jul 2021 09:27:21 +0100 Subject: remove lib2to3 usage --- setuptools/command/develop.py | 47 +++++++++++-------------------------------- 1 file changed, 12 insertions(+), 35 deletions(-) (limited to 'setuptools/command/develop.py') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index faf8c988..24fb0a7c 100644 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -63,7 +63,8 @@ class develop(namespaces.DevelopInstaller, easy_install): target = pkg_resources.normalize_path(self.egg_base) egg_path = pkg_resources.normalize_path( - os.path.join(self.install_dir, self.egg_path)) + os.path.join(self.install_dir, self.egg_path) + ) if egg_path != target: raise DistutilsOptionError( "--egg-path must be a relative path from the install" @@ -74,7 +75,7 @@ class develop(namespaces.DevelopInstaller, easy_install): self.dist = pkg_resources.Distribution( target, pkg_resources.PathMetadata(target, os.path.abspath(ei.egg_info)), - project_name=ei.egg_name + project_name=ei.egg_name, ) self.setup_path = self._resolve_setup_path( @@ -99,41 +100,18 @@ class develop(namespaces.DevelopInstaller, easy_install): if resolved != pkg_resources.normalize_path(os.curdir): raise DistutilsOptionError( "Can't get a consistent path to setup script from" - " installation directory", resolved, - pkg_resources.normalize_path(os.curdir)) + " installation directory", + resolved, + pkg_resources.normalize_path(os.curdir), + ) return path_to_setup def install_for_development(self): - if getattr(self.distribution, 'use_2to3', False): - # If we run 2to3 we can not do this inplace: - - # Ensure metadata is up-to-date - self.reinitialize_command('build_py', inplace=0) - self.run_command('build_py') - bpy_cmd = self.get_finalized_command("build_py") - build_path = pkg_resources.normalize_path(bpy_cmd.build_lib) - - # Build extensions - self.reinitialize_command('egg_info', egg_base=build_path) - self.run_command('egg_info') - - self.reinitialize_command('build_ext', inplace=0) - self.run_command('build_ext') - - # Fixup egg-link and easy-install.pth - ei_cmd = self.get_finalized_command("egg_info") - self.egg_path = build_path - self.dist.location = build_path - # XXX - self.dist._provider = pkg_resources.PathMetadata( - build_path, ei_cmd.egg_info) - else: - # Without 2to3 inplace works fine: - self.run_command('egg_info') + self.run_command('egg_info') - # Build extensions in-place - self.reinitialize_command('build_ext', inplace=1) - self.run_command('build_ext') + # Build extensions in-place + self.reinitialize_command('build_ext', inplace=1) + self.run_command('build_ext') if setuptools.bootstrap_install_from: self.easy_install(setuptools.bootstrap_install_from) @@ -156,8 +134,7 @@ class develop(namespaces.DevelopInstaller, easy_install): egg_link_file = open(self.egg_link) contents = [line.rstrip() for line in egg_link_file] egg_link_file.close() - if contents not in ([self.egg_path], - [self.egg_path, self.setup_path]): + if contents not in ([self.egg_path], [self.egg_path, self.setup_path]): log.warn("Link points to %s: uninstall aborted", contents) return if not self.dry_run: -- cgit v1.2.1